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
This commit is contained in:
Martin Gräßlin 2013-04-24 10:46:34 +02:00
parent cd025c7526
commit 2e758ed6a7
5 changed files with 25 additions and 7 deletions

View file

@ -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<WindowThumbnailItem*>(item)) {

View file

@ -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;

View file

@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<TabBoxClientImpl*>(c)->client();
if (EffectWindow *w = static_cast<EffectsHandlerImpl*>(effects)->findWindow(cl->window()))
static_cast<EffectsHandlerImpl*>(effects)->setElevatedWindow(w, b);
if (EffectWindow *w = static_cast<EffectsHandlerImpl*>(effects)->findWindow(tabbox))
static_cast<EffectsHandlerImpl*>(effects)->setElevatedWindow(w, b);
}
Client *cl = static_cast<TabBoxClientImpl*>(c)->client();
cl->elevate(b);
if (Unmanaged *w = Workspace::self()->findUnmanaged(WindowMatchPredicate(tabbox)))
w->elevate(b);
}

View file

@ -479,6 +479,14 @@ bool Toplevel::isOnCurrentActivity() const
#endif
}
void Toplevel::elevate(bool elevate)
{
if (!effectWindow()) {
return;
}
effectWindow()->elevate(elevate);
}
} // namespace
#include "toplevel.moc"

View file

@ -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