From 819b474a79114a63dda906ceb257b02026ad167c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 11 Jan 2013 10:06:14 +0100 Subject: [PATCH] Introduce property "visible" on EffectWindow This property can be used to check whether a window is currently visible to the user, that is: * not minimized * on the current desktop * on current activity This is a common need for various effects. REVIEW: 108341 --- effects/fallapart/fallapart.cpp | 6 +----- libkwineffects/kwineffects.cpp | 7 +++++++ libkwineffects/kwineffects.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/effects/fallapart/fallapart.cpp b/effects/fallapart/fallapart.cpp index 3eb913d15a..5d460172cf 100644 --- a/effects/fallapart/fallapart.cpp +++ b/effects/fallapart/fallapart.cpp @@ -148,11 +148,7 @@ void FallApartEffect::slotWindowClosed(EffectWindow* c) { if (!isRealWindow(c)) return; - if (c->isMinimized()) - return; - if (!c->isOnCurrentDesktop()) - return; - if (!c->isOnCurrentActivity()) + if (!c->isVisible()) return; const void* e = c->data(WindowClosedGrabRole).value(); if (e && e != this) diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index fa1015a496..7d522d11e1 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -818,6 +818,13 @@ bool EffectWindow::hasDecoration() const return contentsRect() != QRect(0, 0, width(), height()); } +bool EffectWindow::isVisible() const +{ + return !isMinimized() + && isOnCurrentDesktop() + && isOnCurrentActivity(); +} + //**************************************** // EffectWindowGroup diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index f1e2add39d..2b8ede9e46 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1360,6 +1360,16 @@ class KWIN_EXPORT EffectWindow : public QObject * @since 4.10 **/ Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) + /** + * Whether the window is currently visible to the user, that is: + * + * @since 4.11 + **/ + Q_PROPERTY(bool visible READ isVisible) public: /** Flags explaining why painting should be disabled */ enum { @@ -1577,6 +1587,11 @@ public: bool isCurrentTab() const; + /** + * @since 4.11 + **/ + bool isVisible() const; + /** * Can be used to by effects to store arbitrary data in the EffectWindow. */