aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <mgraesslin@kde.org>2012-09-04 19:02:41 (GMT)
committerMartin Gräßlin <mgraesslin@kde.org>2012-09-07 05:39:32 (GMT)
commita88457250ef4e13b4934b6dca1632d67c41d8b05 (patch)
treefa67c9921194921e09d0ac74fcf2df29402e1ac5
parent8452e6c3f01a65953705087e0d7ada87e2cc6997 (diff)
Translucency Effect supports isActive hook
The effect gets a set of boolean values to check whether it is active for one of the categories (e.g. move resize, decorations). This allows to easily check whether the effect is active at all, that is if all values are at 1.0 the effect will never affect a window. In all other cases it can be combined with looking at the available windows to e.g. enable the effect for move resize only when there is a window which is either moved or resized. This check is performed whenever an action happens which could cause a window to become inactive. BUG: 306262 FIXED-IN: 4.9.2
-rw-r--r--kwin/effects/translucency/translucency.cpp96
-rw-r--r--kwin/effects/translucency/translucency.h12
2 files changed, 107 insertions, 1 deletions
diff --git a/kwin/effects/translucency/translucency.cpp b/kwin/effects/translucency/translucency.cpp
index f176ff3..cbd3858 100644
--- a/kwin/effects/translucency/translucency.cpp
+++ b/kwin/effects/translucency/translucency.cpp
@@ -31,10 +31,19 @@ TranslucencyEffect::TranslucencyEffect()
: fadeout(NULL)
, current(NULL)
, previous(NULL)
+ , m_activeDecorations(false)
+ , m_activeMoveResize(false)
+ , m_activeDialogs(false)
+ , m_activeInactive(false)
+ , m_activeCombobox(false)
+ , m_activeMenus(false)
+ , m_active(false)
{
reconfigure(ReconfigureAll);
active = effects->activeWindow();
connect(effects, SIGNAL(windowActivated(KWin::EffectWindow*)), this, SLOT(slotWindowActivated(KWin::EffectWindow*)));
+ connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(checkIsActive()));
+ connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(checkIsActive()));
connect(effects, SIGNAL(windowStartUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowStartStopUserMovedResized(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowFinishUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowStartStopUserMovedResized(KWin::EffectWindow*)));
}
@@ -63,10 +72,88 @@ void TranslucencyEffect::reconfigure(ReconfigureFlags)
activeinactive_timeline.setCurveShape(QTimeLine::EaseInOutCurve);
activeinactive_timeline.setDuration(animationTime(conf, "Duration", 800));
+ m_activeDecorations = !qFuzzyCompare(decoration, 1.0);
+ m_activeMoveResize = !qFuzzyCompare(moveresize, 1.0);
+ m_activeDialogs = !qFuzzyCompare(dialogs, 1.0);
+ m_activeInactive = !qFuzzyCompare(inactive, 1.0);
+ m_activeCombobox = !qFuzzyCompare(comboboxpopups, 1.0);
+ m_activeMenus = !qFuzzyCompare(menus, 1.0);
+ if (!m_activeMenus && individualmenuconfig) {
+ m_activeMenus = !qFuzzyCompare(dropdownmenus, 1.0) ||
+ !qFuzzyCompare(popupmenus, 1.0) ||
+ !qFuzzyCompare(tornoffmenus, 1.0);
+ }
+ checkIsActive();
+
// Repaint the screen just in case the user changed the inactive opacity
effects->addRepaintFull();
}
+void TranslucencyEffect::checkIsActive()
+{
+ m_active = m_activeDecorations ||
+ m_activeMoveResize ||
+ m_activeDialogs ||
+ m_activeInactive ||
+ m_activeCombobox ||
+ m_activeMenus;
+ if (!m_active) {
+ // all individual options are disabled, no window state can activate it
+ return;
+ }
+ if (m_activeDecorations) {
+ // we can assume that there is at least one decorated window, so the effect is active
+ return;
+ }
+ if (m_activeInactive) {
+ // we can assume that there is at least one inactive window, so the effect is active
+ // TODO: maybe only if inactive window is not obscured?
+ return;
+ }
+ // for all other options we go through the list of window and search for a Window being affected
+ bool activeDropdown, activePopup, activeTornoff;
+ activeDropdown = activePopup = activeTornoff = false;
+ if (individualmenuconfig) {
+ activeDropdown = !qFuzzyCompare(dropdownmenus, 1.0);
+ activePopup = !qFuzzyCompare(popupmenus, 1.0);
+ activeTornoff = !qFuzzyCompare(activeTornoff, 1.0);
+ }
+ foreach (EffectWindow *w, effects->stackingOrder()) {
+ if (w->isDeleted()) {
+ // ignore deleted windows
+ continue;
+ }
+ if (m_activeMoveResize && (w->isUserMove() || w->isUserResize())) {
+ return;
+ }
+ if (m_activeDialogs && w->isDialog()) {
+ return;
+ }
+ if (m_activeCombobox && w->isComboBox()) {
+ return;
+ }
+ if (m_activeMenus) {
+ if (individualmenuconfig) {
+ if (activeDropdown && w->isDropdownMenu()) {
+ return;
+ }
+ if (activePopup && w->isPopupMenu()) {
+ return;
+ }
+ if (activeTornoff && w->isMenu()) {
+ return;
+ }
+ } else {
+ if (w->isMenu() || w->isDropdownMenu() || w->isPopupMenu()) {
+ return;
+ }
+ }
+ }
+ }
+ // no matching window, disable effect
+ m_active = false;
+}
+
void TranslucencyEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
// We keep track of the windows that was last active so we know
@@ -183,7 +270,8 @@ bool TranslucencyEffect::isInactive(const EffectWindow* w) const
void TranslucencyEffect::slotWindowStartStopUserMovedResized(EffectWindow* w)
{
- if (moveresize != 1.0) {
+ if (m_activeMoveResize) {
+ checkIsActive();
moveresize_timeline.setCurrentTime(0);
w->addRepaintFull();
}
@@ -213,6 +301,12 @@ void TranslucencyEffect::slotWindowActivated(EffectWindow* w)
}
}
active = w;
+ checkIsActive();
+}
+
+bool TranslucencyEffect::isActive() const
+{
+ return m_active;
}
} // namespace
diff --git a/kwin/effects/translucency/translucency.h b/kwin/effects/translucency/translucency.h
index 35f5448..24e528d 100644
--- a/kwin/effects/translucency/translucency.h
+++ b/kwin/effects/translucency/translucency.h
@@ -48,6 +48,7 @@ public:
virtual void reconfigure(ReconfigureFlags);
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
+ virtual bool isActive() const;
// for properties
qreal configuredDecoration() const {
@@ -90,6 +91,9 @@ public Q_SLOTS:
void slotWindowActivated(KWin::EffectWindow* w);
void slotWindowStartStopUserMovedResized(KWin::EffectWindow *w);
+private Q_SLOTS:
+ void checkIsActive();
+
private:
bool isInactive(const EffectWindow *w) const;
bool individualmenuconfig;
@@ -111,6 +115,14 @@ private:
QTimeLine moveresize_timeline;
QTimeLine activeinactive_timeline;
+
+ bool m_activeDecorations;
+ bool m_activeMoveResize;
+ bool m_activeDialogs;
+ bool m_activeInactive;
+ bool m_activeCombobox;
+ bool m_activeMenus;
+ bool m_active;
};
} // namespace