1 /* 2 SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr> 3 SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com> 4 SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de> 5 6 SPDX-License-Identifier: MIT 7 */ 8 9 #pragma once 10 11 #include <config-X11.h> 12 #ifdef HAVE_X11 13 #include <xcb/xcb.h> 14 #endif 15 16 #include <kdedmodule.h> 17 18 #include "menuimporter.h" 19 #include <QPointer> 20 21 class QDBusServiceWatcher; 22 class KDBusMenuImporter; 23 class AppmenuDBus; 24 class VerticalMenu; 25 namespace KWayland 26 { 27 namespace Client 28 { 29 class PlasmaShell; 30 }; 31 }; 32 33 class AppMenuModule : public KDEDModule, protected QDBusContext 34 { 35 Q_OBJECT 36 public: 37 AppMenuModule(QObject *parent, const QList<QVariant> &list); 38 ~AppMenuModule() override; 39 bool eventFilter(QObject *object, QEvent *event) override; 40 41 Q_SIGNALS: 42 /** 43 * We do not know where is menu decoration button, so tell kwin to show menu 44 */ 45 void showRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId); 46 /** 47 * This signal is emitted whenever popup menu/menubar is shown 48 * Useful for decorations to know if menu button should look pressed 49 */ 50 void menuShown(const QString &service, const QDBusObjectPath &objectPath); 51 /** 52 * This signal is emitted whenever popup menu/menubar is hidden 53 * Useful for decorations to know if menu button should be release 54 */ 55 void menuHidden(const QString &service, const QDBusObjectPath &objectPath); 56 57 private Q_SLOTS: 58 /** 59 * A new window was registered to AppMenu 60 * 61 * For compatibility this will set the DBus service name and menu object path as properties 62 * on the window so we keep working with clients that use the DBusMenu "properly". 63 */ 64 void slotWindowRegistered(WId id, const QString &serviceName, const QDBusObjectPath &menuObjectPath); 65 /** 66 * Show menu at QPoint(x,y) for DBus serviceName and menuObjectPath 67 * if x or y == -1, show in application window 68 */ 69 void slotShowMenu(int x, int y, const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId); 70 /** 71 * Reconfigure module 72 */ 73 void reconfigure(); 74 75 void itemActivationRequested(int actionId, uint timeStamp); 76 77 private: 78 void hideMenu(); 79 80 void fakeUnityAboutToShow(const QString &service, const QDBusObjectPath &menuObjectPath); 81 82 KDBusMenuImporter *getImporter(const QString &service, const QString &path); 83 void initMenuWayland(); 84 85 MenuImporter *m_menuImporter = nullptr; 86 AppmenuDBus *m_appmenuDBus; 87 QDBusServiceWatcher *m_menuViewWatcher; 88 QPointer<VerticalMenu> m_menu; 89 90 #ifdef HAVE_X11 91 xcb_connection_t *m_xcbConn = nullptr; 92 #endif 93 KWayland::Client::PlasmaShell *m_plasmashell = nullptr; 94 }; 95