From e717c131bf223b0353a126cf3278ea309642229e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Wed, 19 Jun 2013 16:26:55 +0200 Subject: [PATCH] Hook modalChanged signal for DialogParent script Eg. gtk+ alters the modality after mapping and before unmapping the window. Therfore the former implementation ahd a wrong idea about the modality until the window was activated and again had a wrong idea when the dialog closed, keeping the main client dimmed. Modality changes at runtime are uncommon but legal and can happen anytime. BUG: 321340 FIXED-IN: 4.11 REVIEW: 111154 --- effects.cpp | 6 ++++++ effects.h | 1 + .../package/contents/code/main.js | 20 +++++++++++++++++-- libkwineffects/kwineffects.h | 6 ++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/effects.cpp b/effects.cpp index 1ad2975abd..b07004ad3d 100644 --- a/effects.cpp +++ b/effects.cpp @@ -282,6 +282,7 @@ void EffectsHandlerImpl::setupClientConnections(Client* c) connect(c, SIGNAL(opacityChanged(KWin::Toplevel*,qreal)), this, SLOT(slotOpacityChanged(KWin::Toplevel*,qreal))); connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(slotClientMinimized(KWin::Client*,bool))); connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(slotClientUnminimized(KWin::Client*,bool))); + connect(c, SIGNAL(modalChanged()), this, SLOT(slotClientModalityChanged())); connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), this, SLOT(slotGeometryShapeChanged(KWin::Toplevel*,QRect))); connect(c, SIGNAL(paddingChanged(KWin::Toplevel*,QRect)), this, SLOT(slotPaddingChanged(KWin::Toplevel*,QRect))); connect(c, SIGNAL(damaged(KWin::Toplevel*,QRect)), this, SLOT(slotWindowDamaged(KWin::Toplevel*,QRect))); @@ -601,6 +602,11 @@ void EffectsHandlerImpl::slotClientUnminimized(Client* c, bool animate) } } +void EffectsHandlerImpl::slotClientModalityChanged() +{ + emit windowModalityChanged(static_cast(sender())->effectWindow()); +} + void EffectsHandlerImpl::slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to) { emit currentTabAboutToChange(from, to); diff --git a/effects.h b/effects.h index 1cb4bc230d..17dc4d9002 100644 --- a/effects.h +++ b/effects.h @@ -227,6 +227,7 @@ protected Q_SLOTS: void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity); void slotClientMinimized(KWin::Client *c, bool animate); void slotClientUnminimized(KWin::Client *c, bool animate); + void slotClientModalityChanged(); void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old); void slotPaddingChanged(KWin::Toplevel *t, const QRect &old); void slotWindowDamaged(KWin::Toplevel *t, const QRect& r); diff --git a/effects/dialogparent/package/contents/code/main.js b/effects/dialogparent/package/contents/code/main.js index e4c2f70a77..52ee202631 100644 --- a/effects/dialogparent/package/contents/code/main.js +++ b/effects/dialogparent/package/contents/code/main.js @@ -27,6 +27,10 @@ var dialogParentEffect = { if (window === null || window.modal === false) { return; } + dialogParentEffect.dialogGotModality(window) + }, + dialogGotModality: function (window) { + "use strict"; mainWindows = window.mainWindows(); for (i = 0; i < mainWindows.length; i += 1) { w = mainWindows[i]; @@ -60,6 +64,10 @@ var dialogParentEffect = { if (window.modal === false) { return; } + dialogParentEffect.dialogLostModality(window); + }, + dialogLostModality: function (window) { + "use strict"; mainWindows = window.mainWindows(); for (i = 0; i < mainWindows.length; i += 1) { w = mainWindows[i]; @@ -96,10 +104,17 @@ var dialogParentEffect = { windows = effects.stackingOrder; for (i = 0; i < windows.length; i += 1) { window = windows[i]; - dialogParentEffect.cancelAnimation(window); + dialogParentEffect.cancelAnimation(window); dialogParentEffect.restartAnimation(window); } }, + modalDialogChanged: function(dialog) { + "use strict"; + if (dialog.modal === false) + dialogParentEffect.dialogLostModality(dialog); + else if (dialog.modal === true) + dialogParentEffect.dialogGotModality(dialog); + }, restartAnimation: function (window) { "use strict"; if (window === null || window.findModal() === null) { @@ -110,10 +125,11 @@ var dialogParentEffect = { init: function () { "use strict"; var i, windows; - effects.windowActivated.connect(dialogParentEffect.windowAdded); + effects.windowAdded.connect(dialogParentEffect.windowAdded); effects.windowClosed.connect(dialogParentEffect.windowClosed); effects.windowMinimized.connect(dialogParentEffect.cancelAnimation); effects.windowUnminimized.connect(dialogParentEffect.restartAnimation); + effects.windowModalityChanged.connect(dialogParentEffect.modalDialogChanged) effects['desktopChanged(int,int)'].connect(dialogParentEffect.desktopChanged); // start animation diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 4e7519b3e6..b8c39e9b1d 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1079,6 +1079,12 @@ Q_SIGNALS: * @since 4.7 **/ void windowUnminimized(KWin::EffectWindow *w); + /** + * Signal emitted when a window either becomes modal (ie. blocking for its main client) or looses that state. + * @param w The window which was unminimized + * @since 4.11 + **/ + void windowModalityChanged(KWin::EffectWindow *w); /** * Signal emitted when an area of a window is scheduled for repainting. * Use this signal in an effect if another area needs to be synced as well.