From 1236e3e83b90f07f9f09fc0addf8ba0ee8c54dc2 Mon Sep 17 00:00:00 2001 From: Ser Freeman Date: Mon, 4 Sep 2023 15:05:38 +0500 Subject: [PATCH] effects/maximize: Set oldGeometry only on windowMaximizedStateAboutToChange Since there is now exist the signal right before maximize, use it to set oldGeometry instead of storing previous values every time with windowFrameGeometryChanged. This fixes the effect under Wayland. --- .../package/contents/code/maximize.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/plugins/maximize/package/contents/code/maximize.js b/src/plugins/maximize/package/contents/code/maximize.js index 0539306cc9..6f9085eed5 100644 --- a/src/plugins/maximize/package/contents/code/maximize.js +++ b/src/plugins/maximize/package/contents/code/maximize.js @@ -30,6 +30,9 @@ class MaximizeEffect { if (!window.visible) { return; } + + window.oldGeometry = Object.assign({}, window.geometry); + if (window.maximizeAnimation1) { cancel(window.maximizeAnimation1); delete window.maximizeAnimation1; @@ -57,12 +60,8 @@ class MaximizeEffect { return; } window.setData(Effect.WindowForceBlurRole, true); - let oldGeometry = window.oldGeometry; + const oldGeometry = window.oldGeometry; const newGeometry = window.geometry; - if (oldGeometry.width == newGeometry.width && oldGeometry.height == newGeometry.height) - oldGeometry = window.olderGeometry; - window.olderGeometry = Object.assign({}, window.oldGeometry); - window.oldGeometry = Object.assign({}, newGeometry); window.maximizeAnimation1 = animate({ window: window, duration: this.duration, @@ -97,19 +96,23 @@ class MaximizeEffect { } onWindowFrameGeometryChanged(window, oldGeometry) { - if (window.maximizeAnimation1) { - if (window.geometry.width != window.oldGeometry.width || - window.geometry.height != window.oldGeometry.height) { - cancel(window.maximizeAnimation1); - delete window.maximizeAnimation1; - if (window.maximizeAnimation2) { - cancel(window.maximizeAnimation2); - delete window.maximizeAnimation2; - } - } + if (!window.maximizeAnimation1 || + // Check only dimension changes. + (window.geometry.width == oldGeometry.width && window.geometry.height == oldGeometry.height) || + // Check only if last dimension isn't equal to dimension from which effect was started (window.oldGeometry). + (window.oldGeometry.width == oldGeometry.width && window.oldGeometry.height == oldGeometry.height) + ) { + return; + } + + // Cancel animation if window got resized halfway through it. + cancel(window.maximizeAnimation1); + delete window.maximizeAnimation1; + + if (window.maximizeAnimation2) { + cancel(window.maximizeAnimation2); + delete window.maximizeAnimation2; } - window.oldGeometry = Object.assign({}, window.geometry); - window.olderGeometry = Object.assign({}, oldGeometry); } }