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.TelepathyLogger = '0.2';
const { Clutter, GLib, Shell, St } = imports.gi;
const { Clutter, GLib, Meta, Shell, St } = imports.gi;
const Gettext = imports.gettext;
// 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;
delete params.onComplete;
let onStopped = params.onStopped;
delete params.onStopped;
if (!onComplete && !onStopped)
return null;
return isFinished => {
cleanup();
if (onStopped)
onStopped(isFinished);
if (onComplete && isFinished)
@ -110,7 +109,10 @@ function _easeActor(actor, params) {
actor.set_easing_mode(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
let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g'));
@ -119,14 +121,11 @@ function _easeActor(actor, params) {
actor.set(params);
actor.restore_easing_state();
if (callback) {
let transition = actor.get_transition(animatedProps[0]);
if (transition)
transition.connect('stopped', (t, finished) => callback(finished));
else
callback(true);
}
}
function _easeActorProperty(actor, propName, target, params) {
@ -144,7 +143,10 @@ function _easeActorProperty(actor, propName, target, params) {
if (actor instanceof Clutter.Actor && !actor.mapped)
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
actor.remove_transition(propName);
@ -153,7 +155,6 @@ function _easeActorProperty(actor, propName, target, params) {
let [obj, prop] = _getPropertyTarget(actor, propName);
obj[prop] = target;
if (callback)
callback(true);
return;
@ -169,7 +170,6 @@ function _easeActorProperty(actor, propName, target, params) {
transition.set_to(target);
if (callback)
transition.connect('stopped', (t, finished) => callback(finished));
}