File indexing completed on 2024-05-05 17:43:53

0001 /*
0002     SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QByteArray>
0010 #include <QHash>
0011 #include <QObject>
0012 #include <QWindow> // for WId
0013 
0014 #include <xcb/xcb_atom.h>
0015 
0016 class QDBusServiceWatcher;
0017 class QTimer;
0018 
0019 class KDirWatch;
0020 
0021 class Window;
0022 
0023 class MenuProxy : public QObject
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     MenuProxy();
0029     ~MenuProxy() override;
0030 
0031 private Q_SLOTS:
0032     void onWindowAdded(WId id);
0033     void onWindowRemoved(WId id);
0034 
0035 private:
0036     bool init();
0037     void teardown();
0038 
0039     static QString gtkRc2Path();
0040     static QString gtk3SettingsIniPath();
0041 
0042     void enableGtkSettings(bool enabled);
0043 
0044     void writeGtk2Settings();
0045     void writeGtk3Settings();
0046 
0047     void addOrRemoveAppMenuGtkModule(QStringList &list);
0048 
0049     xcb_connection_t *m_xConnection;
0050 
0051     QByteArray getWindowPropertyString(WId id, const QByteArray &name);
0052     void writeWindowProperty(WId id, const QByteArray &name, const QByteArray &value);
0053     xcb_atom_t getAtom(const QByteArray &name);
0054 
0055     QHash<WId, Window *> m_windows;
0056 
0057     QDBusServiceWatcher *m_serviceWatcher;
0058 
0059     KDirWatch *m_gtk2RcWatch;
0060     QTimer *m_writeGtk2SettingsTimer;
0061 
0062     bool m_enabled = false;
0063 };