From 2e758ed6a763ef2e51ac0b6d8b433c514230fdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 24 Apr 2013 10:46:34 +0200 Subject: [PATCH] Add an elevate() method to Toplevel Shortcut to set an elevated window without the need to check whether effects pointer is valid and retrieving EffectWindow etc. REVIEW: 110147 --- effects.cpp | 5 +++++ effects.h | 2 ++ tabbox/tabbox.cpp | 12 +++++------- toplevel.cpp | 8 ++++++++ toplevel.h | 5 +++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/effects.cpp b/effects.cpp index aaf6e18749..9d4b3db2e1 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1797,6 +1797,11 @@ EffectWindow* effectWindow(Scene::Window* w) return ret; } +void EffectWindowImpl::elevate(bool elevate) +{ + effects->setElevatedWindow(this, elevate); +} + void EffectWindowImpl::registerThumbnail(AbstractThumbnailItem *item) { if (WindowThumbnailItem *thumb = qobject_cast(item)) { diff --git a/effects.h b/effects.h index 2da6a324ee..a4c33ddf98 100644 --- a/effects.h +++ b/effects.h @@ -302,6 +302,8 @@ public: const Scene::Window* sceneWindow() const; // internal Scene::Window* sceneWindow(); // internal + void elevate(bool elevate); + void setData(int role, const QVariant &data); QVariant data(int role) const; diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index be61185ae7..cc4556ba00 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -37,6 +37,7 @@ along with this program. If not, see . #include "focuschain.h" #include "screenedge.h" #include "screens.h" +#include "unmanaged.h" #include "virtualdesktops.h" #include "workspace.h" // Qt @@ -307,13 +308,10 @@ void TabBoxHandlerImpl::restack(TabBoxClient *c, TabBoxClient *under) void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, WId tabbox, bool b) const { - if (effects) { - const Client *cl = static_cast(c)->client(); - if (EffectWindow *w = static_cast(effects)->findWindow(cl->window())) - static_cast(effects)->setElevatedWindow(w, b); - if (EffectWindow *w = static_cast(effects)->findWindow(tabbox)) - static_cast(effects)->setElevatedWindow(w, b); - } + Client *cl = static_cast(c)->client(); + cl->elevate(b); + if (Unmanaged *w = Workspace::self()->findUnmanaged(WindowMatchPredicate(tabbox))) + w->elevate(b); } diff --git a/toplevel.cpp b/toplevel.cpp index e4f70e2580..611505b850 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -479,6 +479,14 @@ bool Toplevel::isOnCurrentActivity() const #endif } +void Toplevel::elevate(bool elevate) +{ + if (!effectWindow()) { + return; + } + effectWindow()->elevate(elevate); +} + } // namespace #include "toplevel.moc" diff --git a/toplevel.h b/toplevel.h index 48554b59df..5211e38195 100644 --- a/toplevel.h +++ b/toplevel.h @@ -259,6 +259,11 @@ public: void resetDamage(const QRect& r); EffectWindowImpl* effectWindow(); const EffectWindowImpl* effectWindow() const; + /** + * Window will be temporarily painted as if being at the top of the stack. + * Only available if Compositor is active, if not active, this method is a no-op. + **/ + void elevate(bool elevate); /** * @returns Whether the Toplevel has a Shadow or not