diff --git a/src/client/plasmashell.h b/src/client/plasmashell.h index 9555d01..33d0e3a 100644 --- a/src/client/plasmashell.h +++ b/src/client/plasmashell.h @@ -1,368 +1,369 @@ /******************************************************************** Copyright 2015 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #ifndef WAYLAND_PLASMASHELL_H #define WAYLAND_PLASMASHELL_H #include #include #include struct wl_surface; struct org_kde_plasma_shell; struct org_kde_plasma_surface; namespace KWayland { namespace Client { class EventQueue; class Surface; class PlasmaShellSurface; /** * @short Wrapper for the org_kde_plasma_shell interface. * * This class provides a convenient wrapper for the org_kde_plasma_shell interface. * It's main purpose is to create a PlasmaShellSurface. * * To use this class one needs to interact with the Registry. There are two * possible ways to create the Shell interface: * @code * PlasmaShell *s = registry->createPlasmaShell(name, version); * @endcode * * This creates the PlasmaShell and sets it up directly. As an alternative this * can also be done in a more low level way: * @code * PlasmaShell *s = new PlasmaShell; * s->setup(registry->bindPlasmaShell(name, version)); * @endcode * * The PlasmaShell can be used as a drop-in replacement for any org_kde_plasma_shell * pointer as it provides matching cast operators. * * @see Registry * @see PlasmaShellSurface **/ class KWAYLANDCLIENT_EXPORT PlasmaShell : public QObject { Q_OBJECT public: explicit PlasmaShell(QObject *parent = nullptr); virtual ~PlasmaShell(); /** * @returns @c true if managing a org_kde_plasma_shell. **/ bool isValid() const; /** * Releases the org_kde_plasma_shell interface. * After the interface has been released the PlasmaShell instance is no * longer valid and can be setup with another org_kde_plasma_shell interface. * * Right before the interface is released the signal interfaceAboutToBeReleased is emitted. * @see interfaceAboutToBeReleased **/ void release(); /** * Destroys the data held by this PlasmaShell. * This method is supposed to be used when the connection to the Wayland * server goes away. Once the connection becomes invalid, it's not * possible to call release anymore as that calls into the Wayland * connection and the call would fail. This method cleans up the data, so * that the instance can be deleted or set up to a new org_kde_plasma_shell interface * once there is a new connection available. * * This method is automatically invoked when the Registry which created this * PlasmaShell gets destroyed. * * Right before the data is destroyed, the signal interfaceAboutToBeDestroyed is emitted. * * @see release * @see interfaceAboutToBeDestroyed **/ void destroy(); /** * Setup this Shell to manage the @p shell. * When using Registry::createShell there is no need to call this * method. **/ void setup(org_kde_plasma_shell *shell); /** * Sets the @p queue to use for creating a Surface. **/ void setEventQueue(EventQueue *queue); /** * @returns The event queue to use for creating a Surface. **/ EventQueue *eventQueue(); /** * Creates a PlasmaShellSurface for the given @p surface and sets it up. * * If a PlasmaShellSurface for the given @p surface has already been created * a pointer to the existing one is returned instead of creating a new surface. * * @param surface The native surface to create the PlasmaShellSurface for * @param parent The parent to use for the PlasmaShellSurface * @returns created PlasmaShellSurface **/ PlasmaShellSurface *createSurface(wl_surface *surface, QObject *parent = nullptr); /** * Creates a PlasmaShellSurface for the given @p surface and sets it up. * * If a PlasmaShellSurface for the given @p surface has already been created * a pointer to the existing one is returned instead of creating a new surface. * * @param surface The Surface to create the PlasmaShellSurface for * @param parent The parent to use for the PlasmaShellSurface * @returns created PlasmaShellSurface **/ PlasmaShellSurface *createSurface(Surface *surface, QObject *parent = nullptr); operator org_kde_plasma_shell*(); operator org_kde_plasma_shell*() const; Q_SIGNALS: /** * This signal is emitted right before the interface is released. **/ void interfaceAboutToBeReleased(); /** * This signal is emitted right before the data is destroyed. **/ void interfaceAboutToBeDestroyed(); /** * The corresponding global for this interface on the Registry got removed. * * This signal gets only emitted if the Compositor got created by * Registry::createPlasmaShell * * @since 5.5 **/ void removed(); private: class Private; QScopedPointer d; }; /** * @short Wrapper for the org_kde_plasma_surface interface. * * This class is a convenient wrapper for the org_kde_plasma_surface interface. * * To create an instance use PlasmaShell::createSurface. * * A PlasmaShellSurface is a privileged Surface which can add further hints to the * Wayland server about it's position and the usage role. The Wayland server is allowed * to ignore all requests. * * Even if a PlasmaShellSurface is created for a Surface a normal ShellSurface (or similar) * needs to be created to have the Surface mapped as a window by the Wayland server. * * @see PlasmaShell * @see Surface **/ class KWAYLANDCLIENT_EXPORT PlasmaShellSurface : public QObject { Q_OBJECT public: explicit PlasmaShellSurface(QObject *parent); virtual ~PlasmaShellSurface(); /** * Releases the org_kde_plasma_surface interface. * After the interface has been released the PlasmaShellSurface instance is no * longer valid and can be setup with another org_kde_plasma_surface interface. * * This method is automatically invoked when the PlasmaShell which created this * PlasmaShellSurface gets released. **/ void release(); /** * Destroys the data held by this PlasmaShellSurface. * This method is supposed to be used when the connection to the Wayland * server goes away. If the connection is not valid anymore, it's not * possible to call release anymore as that calls into the Wayland * connection and the call would fail. This method cleans up the data, so * that the instance can be deleted or set up to a new org_kde_plasma_surface interface * once there is a new connection available. * * This method is automatically invoked when the PlasmaShell which created this * PlasmaShellSurface gets destroyed. * * @see release **/ void destroy(); /** * Setup this PlasmaShellSurface to manage the @p surface. * There is normally no need to call this method as it's invoked by * PlasmaShell::createSurface. **/ void setup(org_kde_plasma_surface *surface); /** * @returns the PlasmaShellSurface * associated with surface, * if any, nullptr if not found. * @since 5.6 */ static PlasmaShellSurface *get(Surface *surf); /** * @returns @c true if managing a org_kde_plasma_surface. **/ bool isValid() const; operator org_kde_plasma_surface*(); operator org_kde_plasma_surface*() const; /** * Describes possible roles this PlasmaShellSurface can have. * The role can be used by the Wayland server to e.g. change the stacking order accordingly. **/ enum class Role { Normal, ///< A normal Surface Desktop, ///< The Surface represents a desktop, normally stacked below all other surfaces Panel, ///< The Surface represents a panel (dock), normally stacked above normal surfaces OnScreenDisplay, ///< The Surface represents an on screen display, like a volume changed notification Notification, ///< The Surface represents a notification @since 5.24 ToolTip, ///< The Surface represents a tooltip @since 5.24 CriticalNotification, ///< The Surface represents a critical notification, like battery is running out @since 5.58 }; /** * Changes the requested Role to @p role. * @see role **/ void setRole(Role role); /** * @returns The requested Role, default value is @c Role::Normal. * @see setRole **/ Role role() const; /** * Requests to position this PlasmaShellSurface at @p point in global coordinates. **/ void setPosition(const QPoint &point); /** * Describes how a PlasmaShellSurface with role @c Role::Panel should behave. * @see Role **/ enum class PanelBehavior { AlwaysVisible, AutoHide, WindowsCanCover, WindowsGoBelow }; /** * Sets the PanelBehavior for a PlasmaShellSurface with Role @c Role::Panel * @see setRole **/ void setPanelBehavior(PanelBehavior behavior); /** * Setting this bit to the window, will make it say it prefers * to not be listed in the taskbar. Taskbar implementations * may or may not follow this hint. * @since 5.5 */ void setSkipTaskbar(bool skip); /** * Setting this bit on a window will indicate it does not prefer * to be included in a window switcher. * @since 5.47 */ void setSkipSwitcher(bool skip); /** * Requests to hide a surface with Role Panel and PanelBahvior AutoHide. * * Once the compositor has hidden the panel the signal {@link autoHidePanelHidden} gets * emitted. Once it is shown again the signal {@link autoHidePanelShown} gets emitted. * * To show the surface again from client side use {@link requestShowAutoHidingPanel}. * * @see autoHidePanelHidden * @see autoHidePanelShown * @see requestShowAutoHidingPanel * @since 5.28 **/ void requestHideAutoHidingPanel(); /** * Requests to show a surface with Role Panel and PanelBahvior AutoHide. * * This request allows the client to show a surface which it previously * requested to be hidden with {@link requestHideAutoHidingPanel}. * * @see autoHidePanelHidden * @see autoHidePanelShown * @see requestHideAutoHidingPanel * @since 5.28 **/ void requestShowAutoHidingPanel(); /** - * Set whether a PlasmaShellSurface with Role Panel should get focus or not. + * Set whether a PlasmaShellSurface should get focus or not. * - * By default a Panel does not take focus. With this request the compositor - * can be instructed to also pass focus to a panel + * By default some roles do not take focus. With this request the compositor + * can be instructed to also pass focus. * - * @param takesFocus Set to @c true if the Panel should gain focus. + * @param takesFocus Set to @c true if the surface should gain focus. * @since 5.28 **/ + //KF6 TODO rename to make it generic void setPanelTakesFocus(bool takesFocus); Q_SIGNALS: /** * Emitted when the compositor hided an auto hiding panel. * @see requestHideAutoHidingPanel * @see autoHidePanelShown * @see requestShowAutoHidingPanel * @since 5.28 **/ void autoHidePanelHidden(); /** * Emitted when the compositor showed an auto hiding panel. * @see requestHideAutoHidingPanel * @see autoHidePanelHidden * @see requestShowAutoHidingPanel * @since 5.28 **/ void autoHidePanelShown(); private: friend class PlasmaShell; class Private; QScopedPointer d; }; } } Q_DECLARE_METATYPE(KWayland::Client::PlasmaShellSurface::Role) Q_DECLARE_METATYPE(KWayland::Client::PlasmaShellSurface::PanelBehavior) #endif diff --git a/src/client/protocols/plasma-shell.xml b/src/client/protocols/plasma-shell.xml index cd3c22c..e6e0612 100644 --- a/src/client/protocols/plasma-shell.xml +++ b/src/client/protocols/plasma-shell.xml @@ -1,398 +1,396 @@ . ]]> This interface is used by KF5 powered Wayland shells to communicate with the compositor and can only be bound one time. Create a shell surface for an existing surface. Only one shell surface can be associated with a given surface. An interface that may be implemented by a wl_surface, for implementations that provide the shell user interface. It provides requests to set surface roles, assign an output or set the position in output coordinates. On the server side the object is automatically destroyed when the related wl_surface is destroyed. On client side, org_kde_plasma_surface.destroy() must be called before destroying the wl_surface object. The org_kde_plasma_surface interface is removed from the wl_surface object that was turned into a shell surface with the org_kde_plasma_shell.get_surface request. The shell surface role is lost and wl_surface is unmapped. Assign an output to this shell surface. The compositor will use this information to set the position when org_kde_plasma_surface.set_position request is called. Move the surface to new coordinates. Coordinates are global, for example 50,50 for a 1920,0+1920x1080 output is 1970,50 in global coordinates space. Use org_kde_plasma_surface.set_output to assign an output to this surface. Assign a role to a shell surface. The compositor handles surfaces depending on their role. See the explanation below. This request fails if the surface already has a role, this means the surface role may be assigned only once. == Surfaces with splash role == Splash surfaces are placed above every other surface during the shell startup phase. The surfaces are placed according to the output coordinates. No size is imposed to those surfaces, the shell has to resize them according to output size. These surfaces are meant to hide the desktop during the startup phase so that the user will always see a ready to work desktop. A shell might not create splash surfaces if the compositor reveals the desktop in an alternative fashion, for example with a fade in effect. That depends on how much time the desktop usually need to prepare the workspace or specific design decisions. This specification doesn't impose any particular design. When the startup phase is finished, the shell will send the org_kde_plasma.desktop_ready request to the compositor. == Surfaces with desktop role == Desktop surfaces are placed below all other surfaces and are used to show the actual desktop view with icons, search results or controls the user will interact with. What to show depends on the shell implementation. The surfaces are placed according to the output coordinates. No size is imposed to those surfaces, the shell has to resize them according to output size. Only one surface per output can have the desktop role. == Surfaces with dashboard role == Dashboard surfaces are placed above desktop surfaces and are used to show additional widgets and controls. The surfaces are placed according to the output coordinates. No size is imposed to those surfaces, the shell has to resize them according to output size. Only one surface per output can have the dashboard role. == Surfaces with config role == A configuration surface is shown when the user wants to configure panel or desktop views. Only one surface per output can have the config role. TODO: This should grab the input like popup menus, right? == Surfaces with overlay role == Overlays are special surfaces that shows for a limited amount of time. Such surfaces are useful to display things like volume, brightness and status changes. Compositors may decide to show those surfaces in a layer above all surfaces, even full screen ones if so is desired. == Surfaces with notification role == Notification surfaces display informative content for a limited amount of time. The compositor may decide to show them in a corner depending on the configuration. These surfaces are shown in a layer above all other surfaces except for full screen ones. == Surfaces with lock role == The lock surface is shown by the compositor when the session is locked, users interact with it to unlock the session. Compositors should move lock surfaces to 0,0 in output coordinates space and hide all other surfaces for security sake. For the same reason it is recommended that clients make the lock surface as big as the screen. Only one surface per output can have the lock role. The panel is on top of other surfaces, windows cannot cover (full screen windows excluded). The panel is hidden automatically and restored when the mouse is over. Windows can cover the panel. Maximized windows take the whole screen space but the panel is above the windows. Set flags bitmask as described by the flag enum. Pass 0 to unset any flag, the surface will adjust its behavior to the default. Setting this bit to the window, will make it say it prefers to not be listed in the taskbar. Taskbar implementations may or may not follow this hint. A panel surface with panel_behavior auto_hide can perform this request to hide the panel on a screen edge without unmapping it. The compositor informs the client about the panel being hidden with the event auto_hidden_panel_hidden. The compositor will restore the visibility state of the surface when the pointer touches the screen edge the panel borders. Once the compositor restores the visibility the event auto_hidden_panel_shown will be sent. This event will also be sent if the compositor is unable to hide the panel. The client can also request to show the panel again with the request panel_auto_hide_show. A panel surface with panel_behavior auto_hide can perform this request to show the panel again which got hidden with panel_auto_hide_hide. - By default a org_kde_plasma_surface with role panel does not take focus and cannot be + By default various org_kde_plasma_surface roles do not take focus and cannot be activated. With this request the compositor can be instructed to pass focus also to this org_kde_plasma_surface. - - For org_kde_plasma_surface with another role than panel the request does not have any effect. An auto-hiding panel got hidden by the compositor. An auto-hiding panel got shown by the compositor. Setting this bit will indicate that the window prefers not to be listed in a switcher. diff --git a/src/server/plasmashell_interface.h b/src/server/plasmashell_interface.h index 8daf086..ee82ecd 100644 --- a/src/server/plasmashell_interface.h +++ b/src/server/plasmashell_interface.h @@ -1,257 +1,258 @@ /******************************************************************** Copyright 2015 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #ifndef WAYLAND_SERVER_PLASMA_SHELL_INTERFACE_H #define WAYLAND_SERVER_PLASMA_SHELL_INTERFACE_H #include #include #include "global.h" #include "resource.h" class QSize; struct wl_resource; namespace KWayland { namespace Server { class Display; class SurfaceInterface; class PlasmaShellSurfaceInterface; /** * @brief Global for the org_kde_plasma_shell interface. * * The PlasmaShellInterface allows to add additional information to a SurfaceInterface. * It goes beyond what a ShellSurfaceInterface provides and is adjusted toward the needs * of the Plasma desktop. * * A server providing this interface should think about how to restrict access to it as * it allows to perform absolute window positioning. * * @since 5.4 **/ class KWAYLANDSERVER_EXPORT PlasmaShellInterface : public Global { Q_OBJECT public: virtual ~PlasmaShellInterface(); Q_SIGNALS: /** * Emitted whenever a PlasmaShellSurfaceInterface got created. **/ void surfaceCreated(KWayland::Server::PlasmaShellSurfaceInterface*); private: friend class Display; explicit PlasmaShellInterface(Display *display, QObject *parent); class Private; }; /** * @brief Resource for the org_kde_plasma_shell_surface interface. * * PlasmaShellSurfaceInterface gets created by PlasmaShellInterface. * * @since 5.4 **/ class KWAYLANDSERVER_EXPORT PlasmaShellSurfaceInterface : public Resource { Q_OBJECT public: virtual ~PlasmaShellSurfaceInterface(); /** * @returns the SurfaceInterface this PlasmaShellSurfaceInterface got created for **/ SurfaceInterface *surface() const; /** * @returns The PlasmaShellInterface which created this PlasmaShellSurfaceInterface. **/ PlasmaShellInterface *shell() const; /** * @returns the requested position in global coordinates. **/ QPoint position() const; /** * @returns Whether a global position has been requested. **/ bool isPositionSet() const; /** * Describes possible roles this PlasmaShellSurfaceInterface can have. * The role can be used by the server to e.g. change the stacking order accordingly. **/ enum class Role { Normal, ///< A normal surface Desktop, ///< The surface represents a desktop, normally stacked below all other surfaces Panel, ///< The surface represents a panel (dock), normally stacked above normal surfaces OnScreenDisplay, ///< The surface represents an on screen display, like a volume changed notification Notification, ///< The surface represents a notification @since 5.24 ToolTip, ///< The surface represents a tooltip @since 5.24 CriticalNotification, ///< The surface represents a critical notification, like battery is running out @since 5.58 }; /** * @returns The requested role, default value is @c Role::Normal. **/ Role role() const; /** * Describes how a PlasmaShellSurfaceInterface with role @c Role::Panel should behave. **/ enum class PanelBehavior { AlwaysVisible, ///< The panel should be always visible AutoHide, ///< The panel auto hides at a screen edge and returns on mouse press against edge WindowsCanCover, ///< Windows are allowed to go above the panel, it raises on mouse press against screen edge WindowsGoBelow ///< Window are allowed to go below the panel }; /** * @returns The PanelBehavior for a PlasmaShellSurfaceInterface with role @c Role::Panel * @see role **/ PanelBehavior panelBehavior() const; /** * @returns true if this window doesn't want to be listed * in the taskbar * @since 5.5 **/ bool skipTaskbar() const; /** * @returns true if this window doesn't want to be listed * in a window switcher * @since 5.47 **/ bool skipSwitcher() const; /** * Informs the PlasmaShellSurfaceInterface that the auto-hiding panel got hidden. * Once it is shown again the method {@link showAutoHidingPanel} should be used. * * @see showAutoHidingPanel * @see panelAutoHideHideRequested * @see panelAutoHideShowRequested * @since 5.28 **/ void hideAutoHidingPanel(); /** * Informs the PlasmaShellSurfaceInterface that the auto-hiding panel got shown again. * * @see hideAutoHidingPanel * @see panelAutoHideHideRequested * @see panelAutoHideShowRequested * @see 5.28 **/ void showAutoHidingPanel(); /** - * Whether a PlasmaShellSurfaceInterface with Role Panel wants to have focus. + * Whether a PlasmaShellSurfaceInterface wants to have focus. * - * By default a Panel does not get focus, but the PlasmaShellSurfaceInterface can + * By default some PlasmaShell roles do not get focus, but the PlasmaShellSurfaceInterface can * request that it wants to have focus. The compositor can use this information to - * pass focus to the panel. + * pass focus to the surface. * @since 5.28 **/ + //TODO KF6 rename to something generic bool panelTakesFocus() const; /** * @returns The PlasmaShellSurfaceInterface for the @p native resource. * @since 5.5 **/ static PlasmaShellSurfaceInterface *get(wl_resource *native); Q_SIGNALS: /** * A change of global position has been requested. **/ void positionChanged(); /** * A change of the role has been requested. **/ void roleChanged(); /** * A change of the panel behavior has been requested. **/ void panelBehaviorChanged(); /** * A change in the skip taskbar property has been requested */ void skipTaskbarChanged(); /** * A change in the skip switcher property has been requested **/ void skipSwitcherChanged(); /** * A surface with Role Panel and PanelBehavior AutoHide requested to be hidden. * * The compositor should inform the PlasmaShellSurfaceInterface about the actual change. * Once the surface is hidden it should invoke {@link hideAutoHidingPanel}. If the compositor * cannot hide the surface (e.g. because it doesn't border a screen edge) it should inform * the surface through invoking {@link showAutoHidingPanel}. This method should also be invoked * whenever the surface gets shown again due to triggering the screen edge. * * @see hideAutoHidingPanel * @see showAutoHidingPanel * @see panelAutoHideShowRequested * @since 5.28 **/ void panelAutoHideHideRequested(); /** * A surface with Role Panel and PanelBehavior AutoHide requested to be shown. * * The compositor should inform the PlasmaShellSurfaceInterface about the actual change. * Once the surface is shown it should invoke {@link showAutoHidingPanel}. * * @see hideAutoHidingPanel * @see showAutoHidingPanel * @see panelAutoHideHideRequested * @since 5.28 **/ void panelAutoHideShowRequested(); /* * Emitted when panelTakesFocus changes * @see panelTakesFocus * @since 5.66 */ void panelTakesFocusChanged(); private: friend class PlasmaShellInterface; explicit PlasmaShellSurfaceInterface(PlasmaShellInterface *shell, SurfaceInterface *parent, wl_resource *parentResource); class Private; Private *d_func() const; }; } } Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::Role) Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::PanelBehavior) #endif