File indexing completed on 2025-04-20 04:59:56
0001 /* 0002 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QObject> 0012 #include <memory> 0013 0014 class QSize; 0015 struct wl_resource; 0016 0017 namespace KWin 0018 { 0019 class Display; 0020 class SurfaceInterface; 0021 class PlasmaShellSurfaceInterface; 0022 0023 class PlasmaShellInterfacePrivate; 0024 class PlasmaShellSurfaceInterfacePrivate; 0025 0026 /** 0027 * @brief Global for the org_kde_plasma_shell interface. 0028 * 0029 * The PlasmaShellInterface allows to add additional information to a SurfaceInterface. 0030 * It goes beyond what a ShellSurfaceInterface provides and is adjusted toward the needs 0031 * of the Plasma desktop. 0032 * 0033 * A server providing this interface should think about how to restrict access to it as 0034 * it allows to perform absolute window positioning. 0035 */ 0036 class KWIN_EXPORT PlasmaShellInterface : public QObject 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 explicit PlasmaShellInterface(Display *display, QObject *parent); 0042 virtual ~PlasmaShellInterface(); 0043 0044 Q_SIGNALS: 0045 /** 0046 * Emitted whenever a PlasmaShellSurfaceInterface got created. 0047 */ 0048 void surfaceCreated(KWin::PlasmaShellSurfaceInterface *); 0049 0050 private: 0051 std::unique_ptr<PlasmaShellInterfacePrivate> d; 0052 }; 0053 0054 /** 0055 * @brief Resource for the org_kde_plasma_shell_surface interface. 0056 * 0057 * PlasmaShellSurfaceInterface gets created by PlasmaShellInterface. 0058 */ 0059 class KWIN_EXPORT PlasmaShellSurfaceInterface : public QObject 0060 { 0061 Q_OBJECT 0062 public: 0063 virtual ~PlasmaShellSurfaceInterface(); 0064 0065 /** 0066 * @returns the SurfaceInterface this PlasmaShellSurfaceInterface got created for 0067 */ 0068 SurfaceInterface *surface() const; 0069 /** 0070 * @returns the requested position in global coordinates. 0071 */ 0072 QPoint position() const; 0073 /** 0074 * @returns Whether a global position has been requested. 0075 */ 0076 bool isPositionSet() const; 0077 0078 /** 0079 * @returns Whether the surface has requested to be opened under the cursor. 0080 */ 0081 bool wantsOpenUnderCursor() const; 0082 0083 /** 0084 * Describes possible roles this PlasmaShellSurfaceInterface can have. 0085 * The role can be used by the server to e.g. change the stacking order accordingly. 0086 */ 0087 enum class Role { 0088 Normal, ///< A normal surface 0089 Desktop, ///< The surface represents a desktop, normally stacked below all other surfaces 0090 Panel, ///< The surface represents a panel (dock), normally stacked above normal surfaces 0091 OnScreenDisplay, ///< The surface represents an on screen display, like a volume changed notification 0092 Notification, ///< The surface represents a notification 0093 ToolTip, ///< The surface represents a tooltip 0094 CriticalNotification, ///< The surface represents a critical notification, like battery is running out 0095 AppletPopup, ///< The surface represents an applet popup window 0096 }; 0097 /** 0098 * @returns The requested role, default value is @c Role::Normal. 0099 */ 0100 Role role() const; 0101 /** 0102 * Describes how a PlasmaShellSurfaceInterface with role @c Role::Panel should behave. 0103 * 0104 * Deprecated 0105 */ 0106 enum class PanelBehavior { 0107 AlwaysVisible, ///< The panel should be always visible 0108 AutoHide, ///< The panel auto hides at a screen edge and returns on mouse press against edge 0109 WindowsCanCover, ///< Windows are allowed to go above the panel, it raises on mouse press against screen edge 0110 WindowsGoBelow, ///< Window are allowed to go below the panel 0111 }; 0112 /** 0113 * @returns The PanelBehavior for a PlasmaShellSurfaceInterface with role @c Role::Panel 0114 * @see role 0115 * 0116 * Deprecated. This is now ignored 0117 */ 0118 PanelBehavior panelBehavior() const; 0119 0120 /** 0121 * @returns true if this window doesn't want to be listed 0122 * in the taskbar 0123 */ 0124 bool skipTaskbar() const; 0125 0126 /** 0127 * @returns true if this window doesn't want to be listed 0128 * in a window switcher 0129 */ 0130 bool skipSwitcher() const; 0131 0132 /** 0133 * Informs the PlasmaShellSurfaceInterface that the auto-hiding panel got hidden. 0134 * Once it is shown again the method {@link showAutoHidingPanel} should be used. 0135 * 0136 * @see showAutoHidingPanel 0137 * @see panelAutoHideHideRequested 0138 * @see panelAutoHideShowRequested 0139 */ 0140 void hideAutoHidingPanel(); 0141 0142 /** 0143 * Informs the PlasmaShellSurfaceInterface that the auto-hiding panel got shown again. 0144 * 0145 * @see hideAutoHidingPanel 0146 * @see panelAutoHideHideRequested 0147 * @see panelAutoHideShowRequested 0148 * @see 5.28 0149 */ 0150 void showAutoHidingPanel(); 0151 0152 /** 0153 * Whether a PlasmaShellSurfaceInterface wants to have focus. 0154 * 0155 * By default some PlasmaShell roles do not get focus, but the PlasmaShellSurfaceInterface can 0156 * request that it wants to have focus. The compositor can use this information to 0157 * pass focus to the surface. 0158 */ 0159 // TODO KF6 rename to something generic 0160 bool panelTakesFocus() const; 0161 0162 /** 0163 * @returns The PlasmaShellSurfaceInterface for the @p native resource. 0164 */ 0165 static PlasmaShellSurfaceInterface *get(wl_resource *native); 0166 static PlasmaShellSurfaceInterface *get(SurfaceInterface *surface); 0167 0168 Q_SIGNALS: 0169 /** 0170 * A change of global position has been requested. 0171 */ 0172 void positionChanged(); 0173 0174 /** 0175 * The surface has requested to be initially shown under the cursor. Can only occur 0176 * before any buffer has been attached. 0177 */ 0178 void openUnderCursorRequested(); 0179 /** 0180 * A change of the role has been requested. 0181 */ 0182 void roleChanged(); 0183 /** 0184 * A change of the panel behavior has been requested. 0185 */ 0186 void panelBehaviorChanged(); 0187 /** 0188 * A change in the skip taskbar property has been requested 0189 */ 0190 void skipTaskbarChanged(); 0191 /** 0192 * A change in the skip switcher property has been requested 0193 */ 0194 void skipSwitcherChanged(); 0195 0196 /** 0197 * A surface with Role Panel and PanelBehavior AutoHide requested to be hidden. 0198 * 0199 * The compositor should inform the PlasmaShellSurfaceInterface about the actual change. 0200 * Once the surface is hidden it should invoke {@link hideAutoHidingPanel}. If the compositor 0201 * cannot hide the surface (e.g. because it doesn't border a screen edge) it should inform 0202 * the surface through invoking {@link showAutoHidingPanel}. This method should also be invoked 0203 * whenever the surface gets shown again due to triggering the screen edge. 0204 * 0205 * @see hideAutoHidingPanel 0206 * @see showAutoHidingPanel 0207 * @see panelAutoHideShowRequested 0208 */ 0209 void panelAutoHideHideRequested(); 0210 0211 /** 0212 * A surface with Role Panel and PanelBehavior AutoHide requested to be shown. 0213 * 0214 * The compositor should inform the PlasmaShellSurfaceInterface about the actual change. 0215 * Once the surface is shown it should invoke {@link showAutoHidingPanel}. 0216 * 0217 * @see hideAutoHidingPanel 0218 * @see showAutoHidingPanel 0219 * @see panelAutoHideHideRequested 0220 */ 0221 void panelAutoHideShowRequested(); 0222 0223 /* 0224 * Emitted when panelTakesFocus changes 0225 * @see panelTakesFocus 0226 */ 0227 void panelTakesFocusChanged(); 0228 0229 private: 0230 friend class PlasmaShellInterfacePrivate; 0231 explicit PlasmaShellSurfaceInterface(SurfaceInterface *surface, wl_resource *resource); 0232 std::unique_ptr<PlasmaShellSurfaceInterfacePrivate> d; 0233 }; 0234 0235 } 0236 0237 Q_DECLARE_METATYPE(KWin::PlasmaShellSurfaceInterface::Role) 0238 Q_DECLARE_METATYPE(KWin::PlasmaShellSurfaceInterface::PanelBehavior)