File indexing completed on 2024-05-05 17:45:24

0001 /*
0002     Registers as a embed container
0003     SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QAbstractNativeEventFilter>
0011 #include <QHash>
0012 #include <QObject>
0013 
0014 #include <xcb/xcb.h>
0015 
0016 class KSelectionOwner;
0017 class SNIProxy;
0018 
0019 class FdoSelectionManager : public QObject, public QAbstractNativeEventFilter
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     FdoSelectionManager();
0025     ~FdoSelectionManager() override;
0026 
0027 protected:
0028 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0029     bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
0030 #else
0031     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
0032 #endif
0033 
0034 private Q_SLOTS:
0035     void onClaimedOwnership();
0036     void onFailedToClaimOwnership();
0037     void onLostOwnership();
0038 
0039 private:
0040     void init();
0041     bool addDamageWatch(xcb_window_t client);
0042     void dock(xcb_window_t embed_win);
0043     void undock(xcb_window_t client);
0044     void setSystemTrayVisual();
0045 
0046     uint8_t m_damageEventBase;
0047 
0048     QHash<xcb_window_t, u_int32_t> m_damageWatches;
0049     QHash<xcb_window_t, SNIProxy *> m_proxies;
0050     KSelectionOwner *m_selectionOwner;
0051 };