File indexing completed on 2025-04-20 04:59:51
0001 /* 0002 SPDX-FileCopyrightText: 2017 David Edmundson <kde@davidedmundson.co.uk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #pragma once 0007 0008 #include "kwin_export.h" 0009 0010 #include <QObject> 0011 #include <memory> 0012 0013 struct wl_resource; 0014 0015 namespace KWin 0016 { 0017 class Display; 0018 class SurfaceInterface; 0019 class AppMenuInterface; 0020 0021 class AppMenuManagerInterfacePrivate; 0022 class AppMenuInterfacePrivate; 0023 0024 /** 0025 * Provides the DBus service name and object path to a AppMenu DBus interface. 0026 * 0027 * This global can be used for clients to bind AppmenuInterface instances 0028 * and notifies when a new one is created 0029 */ 0030 class KWIN_EXPORT AppMenuManagerInterface : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit AppMenuManagerInterface(Display *display, QObject *parent = nullptr); 0036 ~AppMenuManagerInterface() override; 0037 /** 0038 * Returns any existing appMenu for a given surface 0039 * This returns a null pointer if no AppMenuInterface exists. 0040 */ 0041 AppMenuInterface *appMenuForSurface(SurfaceInterface *); 0042 0043 Q_SIGNALS: 0044 /** 0045 * Emitted whenever a new AppmenuInterface is created. 0046 */ 0047 void appMenuCreated(KWin::AppMenuInterface *); 0048 0049 private: 0050 std::unique_ptr<AppMenuManagerInterfacePrivate> d; 0051 }; 0052 0053 /** 0054 * Provides the DBus service name and object path to a AppMenu DBus interface. 0055 * This interface is attached to a wl_surface and provides access to where 0056 * the AppMenu DBus interface is registered. 0057 */ 0058 class KWIN_EXPORT AppMenuInterface : public QObject 0059 { 0060 Q_OBJECT 0061 public: 0062 /** 0063 * Structure containing DBus service name and path 0064 */ 0065 struct InterfaceAddress 0066 { 0067 /** Service name of host with the AppMenu object*/ 0068 QString serviceName; 0069 /** Object path of the AppMenu interface*/ 0070 QString objectPath; 0071 }; 0072 ~AppMenuInterface() override; 0073 0074 /** 0075 * @returns the service name and object path or empty strings if unset 0076 */ 0077 InterfaceAddress address() const; 0078 0079 /** 0080 * @returns The SurfaceInterface this AppmenuInterface references. 0081 */ 0082 SurfaceInterface *surface() const; 0083 0084 Q_SIGNALS: 0085 /** 0086 * Emitted when the address changes or is first received 0087 */ 0088 void addressChanged(KWin::AppMenuInterface::InterfaceAddress); 0089 0090 private: 0091 explicit AppMenuInterface(SurfaceInterface *s, wl_resource *resource); 0092 friend class AppMenuManagerInterfacePrivate; 0093 0094 std::unique_ptr<AppMenuInterfacePrivate> d; 0095 }; 0096 0097 }