WindowManager: clean up effects code

Use consistently shouldAnimateActor(), and try to have a uniform code flow
between the modal dialog and the normal case.

https://bugzilla.gnome.org/show_bug.cgi?id=690241
This commit is contained in:
Giovanni Campagna 2012-12-15 03:23:36 +01:00
parent 9860b1c677
commit 3b8a125732

View File

@ -219,7 +219,9 @@ const WindowManager = new Lang.Class({
_shouldAnimateActor: function(actor) { _shouldAnimateActor: function(actor) {
if (!this._shouldAnimate()) if (!this._shouldAnimate())
return false; return false;
return actor.meta_window.get_window_type() == Meta.WindowType.NORMAL; let windowType = actor.meta_window.get_window_type();
return windowType == Meta.WindowType.NORMAL ||
windowType == Meta.WindowType.MODAL_DIALOG;
}, },
_removeEffect : function(list, actor) { _removeEffect : function(list, actor) {
@ -369,9 +371,15 @@ const WindowManager = new Lang.Class({
actor._windowType = type; actor._windowType = type;
})); }));
if (!this._shouldAnimateActor(actor)) {
shellwm.completed_map(actor);
return;
}
if (actor.meta_window.is_attached_dialog()) { if (actor.meta_window.is_attached_dialog()) {
/* Scale the window from the center of the parent */
this._checkDimming(actor.get_meta_window().get_transient_for()); this._checkDimming(actor.get_meta_window().get_transient_for());
if (this._shouldAnimate()) {
actor.set_scale(1.0, 0.0); actor.set_scale(1.0, 0.0);
actor.scale_gravity = Clutter.Gravity.CENTER; actor.scale_gravity = Clutter.Gravity.CENTER;
actor.show(); actor.show();
@ -388,21 +396,12 @@ const WindowManager = new Lang.Class({
onOverwriteScope: this, onOverwriteScope: this,
onOverwriteParams: [shellwm, actor] onOverwriteParams: [shellwm, actor]
}); });
return; } else {
} /* Fade window in */
shellwm.completed_map(actor);
return;
}
if (!this._shouldAnimateActor(actor)) {
shellwm.completed_map(actor);
return;
}
actor.opacity = 0; actor.opacity = 0;
actor.show(); actor.show();
/* Fade window in */
this._mapping.push(actor); this._mapping.push(actor);
Tweener.addTween(actor, Tweener.addTween(actor,
{ opacity: 255, { opacity: 255,
time: WINDOW_ANIMATION_TIME, time: WINDOW_ANIMATION_TIME,
@ -414,6 +413,7 @@ const WindowManager = new Lang.Class({
onOverwriteScope: this, onOverwriteScope: this,
onOverwriteParams: [shellwm, actor] onOverwriteParams: [shellwm, actor]
}); });
}
}, },
_mapWindowDone : function(shellwm, actor) { _mapWindowDone : function(shellwm, actor) {
@ -441,18 +441,21 @@ const WindowManager = new Lang.Class({
return win != window; return win != window;
}); });
} }
if (window.is_attached_dialog()) {
let parent = window.get_transient_for(); if (!this._shouldAnimateActor(actor)) {
this._checkDimming(parent, window);
if (!this._shouldAnimate()) {
shellwm.completed_destroy(actor); shellwm.completed_destroy(actor);
return; return;
} }
this._destroying.push(actor);
if (window.is_attached_dialog()) {
let parent = window.get_transient_for();
this._checkDimming(parent, window);
actor.set_scale(1.0, 1.0); actor.set_scale(1.0, 1.0);
actor.scale_gravity = Clutter.Gravity.CENTER; actor.scale_gravity = Clutter.Gravity.CENTER;
actor.show(); actor.show();
this._destroying.push(actor);
actor._parentDestroyId = parent.connect('unmanaged', Lang.bind(this, function () { actor._parentDestroyId = parent.connect('unmanaged', Lang.bind(this, function () {
Tweener.removeTweens(actor); Tweener.removeTweens(actor);