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
This commit is contained in:
Martin Gräßlin 2013-01-11 10:06:14 +01:00
parent 2781f240b6
commit 819b474a79
3 changed files with 23 additions and 5 deletions

View file

@ -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<void*>();
if (e && e != this)

View file

@ -818,6 +818,13 @@ bool EffectWindow::hasDecoration() const
return contentsRect() != QRect(0, 0, width(), height());
}
bool EffectWindow::isVisible() const
{
return !isMinimized()
&& isOnCurrentDesktop()
&& isOnCurrentActivity();
}
//****************************************
// EffectWindowGroup

View file

@ -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:
* <ul>
* <li>Not minimized</li>
* <li>On current desktop</li>
* <li>On current activity</li>
* </ul>
* @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.
*/