environment: Disable fullscreen unredirect during all transitions

When there is a transition, it's likely that we are animating some part
of the desktop, and in such situations we don't want to unredirect
fullscreen windows.

This fixes unwanted unredirection when e.g. hiding a modal dialog by
re-enabling the unredirection after the animation has finished, instead
of when it starts.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/721
This commit is contained in:
Jonas Ådahl 2019-09-13 11:51:41 +02:00 committed by Florian Müllner
parent 413c677fcf
commit 57ed68541a

View File

@ -10,7 +10,7 @@ imports.gi.versions.Gtk = '3.0';
imports.gi.versions.TelepathyGLib = '0.12'; imports.gi.versions.TelepathyGLib = '0.12';
imports.gi.versions.TelepathyLogger = '0.2'; imports.gi.versions.TelepathyLogger = '0.2';
const { Clutter, GLib, Shell, St } = imports.gi; const { Clutter, GLib, Meta, Shell, St } = imports.gi;
const Gettext = imports.gettext; const Gettext = imports.gettext;
// We can't import shell JS modules yet, because they may have // We can't import shell JS modules yet, because they may have
@ -58,17 +58,16 @@ function _patchLayoutClass(layoutClass, styleProps) {
}; };
} }
function _makeEaseCallback(params) { function _makeEaseCallback(params, cleanup) {
let onComplete = params.onComplete; let onComplete = params.onComplete;
delete params.onComplete; delete params.onComplete;
let onStopped = params.onStopped; let onStopped = params.onStopped;
delete params.onStopped; delete params.onStopped;
if (!onComplete && !onStopped)
return null;
return isFinished => { return isFinished => {
cleanup();
if (onStopped) if (onStopped)
onStopped(isFinished); onStopped(isFinished);
if (onComplete && isFinished) if (onComplete && isFinished)
@ -110,7 +109,10 @@ function _easeActor(actor, params) {
actor.set_easing_mode(params.mode); actor.set_easing_mode(params.mode);
delete params.mode; delete params.mode;
let callback = _makeEaseCallback(params); Meta.disable_unredirect_for_display(global.display);
let cleanup = () => Meta.enable_unredirect_for_display(global.display);
let callback = _makeEaseCallback(params, cleanup);
// cancel overwritten transitions // cancel overwritten transitions
let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g')); let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g'));
@ -119,14 +121,11 @@ function _easeActor(actor, params) {
actor.set(params); actor.set(params);
actor.restore_easing_state(); actor.restore_easing_state();
if (callback) { let transition = actor.get_transition(animatedProps[0]);
let transition = actor.get_transition(animatedProps[0]); if (transition)
transition.connect('stopped', (t, finished) => callback(finished));
if (transition) else
transition.connect('stopped', (t, finished) => callback(finished)); callback(true);
else
callback(true);
}
} }
function _easeActorProperty(actor, propName, target, params) { function _easeActorProperty(actor, propName, target, params) {
@ -144,7 +143,10 @@ function _easeActorProperty(actor, propName, target, params) {
if (actor instanceof Clutter.Actor && !actor.mapped) if (actor instanceof Clutter.Actor && !actor.mapped)
duration = 0; duration = 0;
let callback = _makeEaseCallback(params); Meta.disable_unredirect_for_display(global.display);
let cleanup = () => Meta.enable_unredirect_for_display(global.display);
let callback = _makeEaseCallback(params, cleanup);
// cancel overwritten transition // cancel overwritten transition
actor.remove_transition(propName); actor.remove_transition(propName);
@ -153,8 +155,7 @@ function _easeActorProperty(actor, propName, target, params) {
let [obj, prop] = _getPropertyTarget(actor, propName); let [obj, prop] = _getPropertyTarget(actor, propName);
obj[prop] = target; obj[prop] = target;
if (callback) callback(true);
callback(true);
return; return;
} }
@ -169,8 +170,7 @@ function _easeActorProperty(actor, propName, target, params) {
transition.set_to(target); transition.set_to(target);
if (callback) transition.connect('stopped', (t, finished) => callback(finished));
transition.connect('stopped', (t, finished) => callback(finished));
} }
function _loggingFunc(...args) { function _loggingFunc(...args) {