workspaceAnimation: Use window clones

Instead of reparenting windows, clone them. This will allow to properly
support multi-monitor setups in subsequent commits.

Block window mapping animation while the animation is running to prevent
new windows appearing during the animation from being visible at the same
time as their clones.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/929

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1326>
This commit is contained in:
Alexander Mikhaylenko 2019-07-04 23:15:15 +05:00 committed by Marge Bot
parent 0f99d46f87
commit 9cf300c972

View File

@ -37,12 +37,16 @@ class WorkspaceGroup extends Clutter.Actor {
} }
_syncStacking() { _syncStacking() {
const windowActors = global.get_window_actors(); const windowActors = global.get_window_actors().filter(w =>
let lastSibling = null; this._shouldShowWindow(w.meta_window));
let lastRecord;
for (const windowActor of windowActors) { for (const windowActor of windowActors) {
this.set_child_above_sibling(windowActor, lastSibling); const record = this._windowRecords.find(r => r.windowActor === windowActor);
lastSibling = windowActor;
this.set_child_above_sibling(record.clone, lastRecord ? lastRecord.clone : null);
lastRecord = record;
} }
} }
@ -51,16 +55,18 @@ class WorkspaceGroup extends Clutter.Actor {
this._shouldShowWindow(w.meta_window)); this._shouldShowWindow(w.meta_window));
for (const windowActor of windowActors) { for (const windowActor of windowActors) {
const record = { const clone = new Clutter.Clone({
windowActor, source: windowActor,
parent: windowActor.get_parent(), x: windowActor.x,
}; y: windowActor.y,
});
record.parent.remove_child(windowActor); this.add_child(clone);
this.add_child(windowActor);
windowActor.show(); const record = { windowActor, clone };
record.windowDestroyId = windowActor.connect('destroy', () => { record.windowDestroyId = windowActor.connect('destroy', () => {
clone.destroy();
this._windowRecords.splice(this._windowRecords.indexOf(record), 1); this._windowRecords.splice(this._windowRecords.indexOf(record), 1);
}); });
@ -71,11 +77,7 @@ class WorkspaceGroup extends Clutter.Actor {
_removeWindows() { _removeWindows() {
for (const record of this._windowRecords) { for (const record of this._windowRecords) {
record.windowActor.disconnect(record.windowDestroyId); record.windowActor.disconnect(record.windowDestroyId);
this.remove_child(record.windowActor); record.clone.destroy();
record.parent.add_child(record.windowActor);
if (!this._workspace.active)
record.windowActor.hide();
} }
this._windowRecords = []; this._windowRecords = [];