From 2a5861faefd9908c6a374edbab46e0f4297f7096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Tue, 3 Sep 2013 21:55:39 +0200 Subject: [PATCH] highlight effect: windowAdded false positive exits When a window is added while the effect is running it shall either be highlighted or hidden, but not exit the effect what happened, because the property notification is invoked to test whether the window has a highlight property (questionable since the effect is running, but valid - could be different X11 client) and that routine exits the effect if no property is found (assuming it was withdrawn) REVIEW: 112494 --- effects/highlightwindow/highlightwindow.cpp | 22 +++++++++++++-------- effects/highlightwindow/highlightwindow.h | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/effects/highlightwindow/highlightwindow.cpp b/effects/highlightwindow/highlightwindow.cpp index 2452b072c4..2de3aafcae 100644 --- a/effects/highlightwindow/highlightwindow.cpp +++ b/effects/highlightwindow/highlightwindow.cpp @@ -109,12 +109,15 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) { if (!m_highlightedWindows.isEmpty()) { // The effect is activated thus we need to add it to the opacity hash - if (w->isNormalWindow() || w->isDialog()) // Only fade out windows - m_windowOpacity[w] = isInitiallyHidden(w) ? 0.0 : 0.15; - else - m_windowOpacity[w] = 1.0; + foreach (const WId id, m_highlightedIds) { + if (w == effects->findWindow(id)) { + m_windowOpacity[w] = 1.0; // this window was demanded to be highlighted before it appeared + return; + } + } + m_windowOpacity[w] = 0.15; // this window is not currently highlighted } - slotPropertyNotify(w, m_atom); // Check initial value + slotPropertyNotify(w, m_atom, w); // Check initial value } void HighlightWindowEffect::slotWindowClosed(EffectWindow* w) @@ -128,7 +131,7 @@ void HighlightWindowEffect::slotWindowDeleted(EffectWindow* w) m_windowOpacity.remove(w); } -void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a) +void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWindow *addedWindow) { if (a != m_atom) return; // Not our atom @@ -138,7 +141,8 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a) effects->readRootProperty(m_atom, m_atom, 32); if (byteData.length() < 1) { // Property was removed, clearing highlight - finishHighlighting(); + if (!addedWindow || w != addedWindow) + finishHighlighting(); return; } long* data = reinterpret_cast(byteData.data()); @@ -154,11 +158,13 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a) //foreach ( EffectWindow* e, m_highlightedWindows ) // effects->setElevatedWindow( e, false ); m_highlightedWindows.clear(); + m_highlightedIds.clear(); for (int i = 0; i < length; i++) { + m_highlightedIds << data[i]; EffectWindow* foundWin = effects->findWindow(data[i]); if (!foundWin) { kDebug(1212) << "Invalid window targetted for highlight. Requested:" << data[i]; - continue; + continue; // might come in later. } m_highlightedWindows.append(foundWin); // TODO: We cannot just simply elevate the window as this will elevate it over diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index 2adefb2d02..4cfd2081e4 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -42,7 +42,7 @@ public Q_SLOTS: void slotWindowAdded(KWin::EffectWindow* w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); - void slotPropertyNotify(KWin::EffectWindow* w, long atom); + void slotPropertyNotify(KWin::EffectWindow* w, long atom, EffectWindow *addedWindow = NULL); private: void prepareHighlighting(); @@ -56,6 +56,7 @@ private: long m_atom; QList m_highlightedWindows; EffectWindow* m_monitorWindow; + QList m_highlightedIds; // Offscreen position cache /*QRect m_thumbArea; // Thumbnail area