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
This commit is contained in:
Thomas Lübking 2013-06-19 16:26:55 +02:00
parent cf6acf84b9
commit e717c131bf
4 changed files with 31 additions and 2 deletions

View file

@ -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<Client*>(sender())->effectWindow());
}
void EffectsHandlerImpl::slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to)
{
emit currentTabAboutToChange(from, to);

View file

@ -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);

View file

@ -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

View file

@ -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.