From 2f02ee45cff91e0fde1473c8249ea0d07a5a2d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Jun 2015 23:25:54 +0200 Subject: [PATCH] Add support for panel behavior in PlasmaShellSurface Allows to set a PlasmaShellSurface with role panel to be either: * AlwaysVisible * AutoHide * WindowsCanCover * WindowsGoBelow --- src/wayland/plasmashell_interface.cpp | 44 ++++++++++++++++++++++++++- src/wayland/plasmashell_interface.h | 8 +++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/wayland/plasmashell_interface.cpp b/src/wayland/plasmashell_interface.cpp index 4bf4f785e2..b21def138a 100644 --- a/src/wayland/plasmashell_interface.cpp +++ b/src/wayland/plasmashell_interface.cpp @@ -72,6 +72,7 @@ public: QPoint m_globalPos; Role m_role; bool m_positionSet = false; + PanelBehavior m_panelBehavior = PanelBehavior::AlwaysVisible; private: // interface callbacks @@ -79,9 +80,11 @@ private: static void setOutputCallback(wl_client *client, wl_resource *resource, wl_resource *output); static void setPositionCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y); static void setRoleCallback(wl_client *client, wl_resource *resource, uint32_t role); + static void setPanelBehaviorCallback(wl_client *client, wl_resource *resource, uint32_t flag); void setPosition(const QPoint &globalPos); void setRole(uint32_t role); + void setPanelBehavior(org_kde_plasma_surface_panel_behavior behavior); PlasmaShellSurfaceInterface *q_func() { return reinterpret_cast(q); @@ -149,7 +152,8 @@ const struct org_kde_plasma_surface_interface PlasmaShellSurfaceInterface::Priva destroyCallback, setOutputCallback, setPositionCallback, - setRoleCallback + setRoleCallback, + setPanelBehaviorCallback }; PlasmaShellSurfaceInterface::PlasmaShellSurfaceInterface(PlasmaShellInterface *shell, SurfaceInterface *parent, wl_resource *parentResource) @@ -236,6 +240,38 @@ void PlasmaShellSurfaceInterface::Private::setRole(uint32_t role) emit q->roleChanged(); } +void PlasmaShellSurfaceInterface::Private::setPanelBehaviorCallback(wl_client *client, wl_resource *resource, uint32_t flag) +{ + auto s = cast(resource); + Q_ASSERT(client == *s->client); + s->setPanelBehavior(org_kde_plasma_surface_panel_behavior(flag)); +} + +void PlasmaShellSurfaceInterface::Private::setPanelBehavior(org_kde_plasma_surface_panel_behavior behavior) +{ + PanelBehavior newBehavior = PanelBehavior::AlwaysVisible; + switch (behavior) { + case ORG_KDE_PLASMA_SURFACE_PANEL_BEHAVIOR_AUTO_HIDE: + newBehavior = PanelBehavior::AutoHide; + break; + case ORG_KDE_PLASMA_SURFACE_PANEL_BEHAVIOR_WINDOWS_CAN_COVER: + newBehavior = PanelBehavior::WindowsCanCover; + break; + case ORG_KDE_PLASMA_SURFACE_PANEL_BEHAVIOR_WINDOWS_GO_BELOW: + newBehavior = PanelBehavior::WindowsGoBelow; + break; + case ORG_KDE_PLASMA_SURFACE_PANEL_BEHAVIOR_ALWAYS_VISIBLE: + default: + break; + } + if (m_panelBehavior == newBehavior) { + return; + } + m_panelBehavior = newBehavior; + Q_Q(PlasmaShellSurfaceInterface); + emit q->panelBehaviorChanged(); +} + QPoint PlasmaShellSurfaceInterface::position() const { Q_D(); @@ -254,5 +290,11 @@ bool PlasmaShellSurfaceInterface::isPositionSet() const return d->m_positionSet; } +PlasmaShellSurfaceInterface::PanelBehavior PlasmaShellSurfaceInterface::panelBehavior() const +{ + Q_D(); + return d->m_panelBehavior; +} + } } diff --git a/src/wayland/plasmashell_interface.h b/src/wayland/plasmashell_interface.h index 2e07a52594..9ed0c4a300 100644 --- a/src/wayland/plasmashell_interface.h +++ b/src/wayland/plasmashell_interface.h @@ -72,10 +72,18 @@ public: Panel }; Role role() const; + enum class PanelBehavior { + AlwaysVisible, + AutoHide, + WindowsCanCover, + WindowsGoBelow + }; + PanelBehavior panelBehavior() const; Q_SIGNALS: void positionChanged(); void roleChanged(); + void panelBehaviorChanged(); private: friend class PlasmaShellInterface;