File indexing completed on 2024-05-05 05:37:32
0001 /* 0002 SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr> 0003 SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com> 0004 SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de> 0005 0006 SPDX-License-Identifier: MIT 0007 */ 0008 0009 #pragma once 0010 0011 #include <config-X11.h> 0012 #ifdef HAVE_X11 0013 #include <xcb/xcb.h> 0014 #endif 0015 0016 #include <kdedmodule.h> 0017 0018 #include "menuimporter.h" 0019 #include <QPointer> 0020 0021 class QDBusServiceWatcher; 0022 class KDBusMenuImporter; 0023 class AppmenuDBus; 0024 class VerticalMenu; 0025 namespace KWayland 0026 { 0027 namespace Client 0028 { 0029 class PlasmaShell; 0030 }; 0031 }; 0032 0033 class AppMenuModule : public KDEDModule, protected QDBusContext 0034 { 0035 Q_OBJECT 0036 public: 0037 AppMenuModule(QObject *parent, const QList<QVariant> &list); 0038 ~AppMenuModule() override; 0039 bool eventFilter(QObject *object, QEvent *event) override; 0040 0041 Q_SIGNALS: 0042 /** 0043 * We do not know where is menu decoration button, so tell kwin to show menu 0044 */ 0045 void showRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId); 0046 /** 0047 * This signal is emitted whenever popup menu/menubar is shown 0048 * Useful for decorations to know if menu button should look pressed 0049 */ 0050 void menuShown(const QString &service, const QDBusObjectPath &objectPath); 0051 /** 0052 * This signal is emitted whenever popup menu/menubar is hidden 0053 * Useful for decorations to know if menu button should be release 0054 */ 0055 void menuHidden(const QString &service, const QDBusObjectPath &objectPath); 0056 0057 private Q_SLOTS: 0058 /** 0059 * A new window was registered to AppMenu 0060 * 0061 * For compatibility this will set the DBus service name and menu object path as properties 0062 * on the window so we keep working with clients that use the DBusMenu "properly". 0063 */ 0064 void slotWindowRegistered(WId id, const QString &serviceName, const QDBusObjectPath &menuObjectPath); 0065 /** 0066 * Show menu at QPoint(x,y) for DBus serviceName and menuObjectPath 0067 * if x or y == -1, show in application window 0068 */ 0069 void slotShowMenu(int x, int y, const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId); 0070 /** 0071 * Reconfigure module 0072 */ 0073 void reconfigure(); 0074 0075 void itemActivationRequested(int actionId, uint timeStamp); 0076 0077 private: 0078 void hideMenu(); 0079 0080 void fakeUnityAboutToShow(const QString &service, const QDBusObjectPath &menuObjectPath); 0081 0082 KDBusMenuImporter *getImporter(const QString &service, const QString &path); 0083 void initMenuWayland(); 0084 0085 MenuImporter *m_menuImporter = nullptr; 0086 AppmenuDBus *m_appmenuDBus; 0087 QDBusServiceWatcher *m_menuViewWatcher; 0088 QPointer<VerticalMenu> m_menu; 0089 0090 #ifdef HAVE_X11 0091 xcb_connection_t *m_xcbConn = nullptr; 0092 #endif 0093 KWayland::Client::PlasmaShell *m_plasmashell = nullptr; 0094 };