windowManager: Use Sets to track ongoing effects

We only care whether an effect is ongoing for an actor, not about
any particular order. Sets are more convenient than arrays in that
case, so use them instead.

https://gitlab.gnome.org/GNOME/mutter/issues/655
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/815
This commit is contained in:
Florian Müllner 2019-11-08 18:00:05 +01:00
parent f5996a9232
commit cb7374b1ec

View File

@ -699,16 +699,16 @@ var WindowManager = class {
constructor() {
this._shellwm = global.window_manager;
this._minimizing = [];
this._unminimizing = [];
this._mapping = [];
this._resizing = [];
this._destroying = [];
this._minimizing = new Set();
this._unminimizing = new Set();
this._mapping = new Set();
this._resizing = new Set();
this._destroying = new Set();
this._movingWindow = null;
this._dimmedWindows = [];
this._skippedActors = [];
this._skippedActors = new Set();
this._allowedKeybindings = {};
@ -1256,7 +1256,7 @@ var WindowManager = class {
}
skipNextEffect(actor) {
this._skippedActors.push(actor);
this._skippedActors.add(actor);
}
setCustomKeybindingHandler(name, modes, handler) {
@ -1285,7 +1285,7 @@ var WindowManager = class {
}
_shouldAnimateActor(actor, types) {
if (this._removeEffect(this._skippedActors, actor))
if (this._skippedActors.delete(actor))
return false;
if (!this._shouldAnimate())
@ -1298,15 +1298,6 @@ var WindowManager = class {
return types.includes(type);
}
_removeEffect(list, actor) {
let idx = list.indexOf(actor);
if (idx != -1) {
list.splice(idx, 1);
return true;
}
return false;
}
_minimizeWindow(shellwm, actor) {
let types = [Meta.WindowType.NORMAL,
Meta.WindowType.MODAL_DIALOG,
@ -1318,7 +1309,7 @@ var WindowManager = class {
actor.set_scale(1.0, 1.0);
this._minimizing.push(actor);
this._minimizing.add(actor);
if (actor.meta_window.is_monitor_sized()) {
actor.ease({
@ -1367,7 +1358,7 @@ var WindowManager = class {
}
_minimizeWindowDone(shellwm, actor) {
if (this._removeEffect(this._minimizing, actor)) {
if (this._minimizing.delete(actor)) {
actor.remove_all_transitions();
actor.set_scale(1.0, 1.0);
actor.set_opacity(255);
@ -1386,7 +1377,7 @@ var WindowManager = class {
return;
}
this._unminimizing.push(actor);
this._unminimizing.add(actor);
if (actor.meta_window.is_monitor_sized()) {
actor.opacity = 0;
@ -1433,7 +1424,7 @@ var WindowManager = class {
}
_unminimizeWindowDone(shellwm, actor) {
if (this._removeEffect(this._unminimizing, actor)) {
if (this._unminimizing.delete(actor)) {
actor.remove_all_transitions();
actor.set_scale(1.0, 1.0);
actor.set_opacity(255);
@ -1481,7 +1472,7 @@ var WindowManager = class {
_sizeChangedWindow(shellwm, actor) {
if (!actor.__animationInfo)
return;
if (this._resizing.includes(actor))
if (this._resizing.has(actor))
return;
let actorClone = actor.__animationInfo.clone;
@ -1491,7 +1482,7 @@ var WindowManager = class {
let scaleX = targetRect.width / sourceRect.width;
let scaleY = targetRect.height / sourceRect.height;
this._resizing.push(actor);
this._resizing.add(actor);
// Now scale and fade out the clone
actorClone.ease({
@ -1539,7 +1530,7 @@ var WindowManager = class {
}
_sizeChangeWindowDone(shellwm, actor) {
if (this._removeEffect(this._resizing, actor)) {
if (this._resizing.delete(actor)) {
actor.remove_all_transitions();
actor.scale_x = 1.0;
actor.scale_y = 1.0;
@ -1638,7 +1629,7 @@ var WindowManager = class {
actor.scale_y = 0.05;
actor.opacity = 0;
actor.show();
this._mapping.push(actor);
this._mapping.add(actor);
actor.ease({
opacity: 255,
@ -1655,7 +1646,7 @@ var WindowManager = class {
actor.scale_y = 0;
actor.opacity = 0;
actor.show();
this._mapping.push(actor);
this._mapping.add(actor);
actor.ease({
opacity: 255,
@ -1672,7 +1663,7 @@ var WindowManager = class {
}
_mapWindowDone(shellwm, actor) {
if (this._removeEffect(this._mapping, actor)) {
if (this._mapping.delete(actor)) {
actor.remove_all_transitions();
actor.opacity = 255;
actor.set_pivot_point(0, 0);
@ -1709,7 +1700,7 @@ var WindowManager = class {
switch (actor.meta_window.window_type) {
case Meta.WindowType.NORMAL:
actor.set_pivot_point(0.5, 0.5);
this._destroying.push(actor);
this._destroying.add(actor);
actor.ease({
opacity: 0,
@ -1723,7 +1714,7 @@ var WindowManager = class {
case Meta.WindowType.MODAL_DIALOG:
case Meta.WindowType.DIALOG:
actor.set_pivot_point(0.5, 0.5);
this._destroying.push(actor);
this._destroying.add(actor);
if (window.is_attached_dialog()) {
let parent = window.get_transient_for();
@ -1746,7 +1737,7 @@ var WindowManager = class {
}
_destroyWindowDone(shellwm, actor) {
if (this._removeEffect(this._destroying, actor)) {
if (this._destroying.delete(actor)) {
let parent = actor.get_meta_window().get_transient_for();
if (parent && actor._parentDestroyId) {
parent.disconnect(actor._parentDestroyId);