From 196d2498a257d8af48221b1999639bcce8b80eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Sat, 4 May 2024 23:01:00 +0200 Subject: [PATCH] WorkspaceManager: Make cleanup private Also make sure to only call it if there is no freeze ongoing. --- src/InternalUtils.vala | 1 - src/WorkspaceManager.vala | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index 722299cc..ff32204e 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -105,7 +105,6 @@ namespace Gala { } workspace_manager.thaw_remove (); - workspace_manager.cleanup (); } // Code ported from KWin present windows effect diff --git a/src/WorkspaceManager.vala b/src/WorkspaceManager.vala index c78ea0c5..9aa797a3 100644 --- a/src/WorkspaceManager.vala +++ b/src/WorkspaceManager.vala @@ -239,14 +239,16 @@ namespace Gala { * Temporarily disables removing workspaces when they are empty */ public void freeze_remove () { - remove_freeze_count++; + GLib.AtomicInt.inc (ref remove_freeze_count); } /** * Undo the effect of freeze_remove() */ public void thaw_remove () { - remove_freeze_count--; + if (GLib.AtomicInt.dec_and_test (ref remove_freeze_count)) { + cleanup (); + } assert (remove_freeze_count >= 0); } @@ -256,7 +258,7 @@ namespace Gala { * be removed. Particularly useful in conjunction with freeze/thaw_remove to * cleanup after an operation that required stable workspace/window indices */ - public void cleanup () { + private void cleanup () { if (!Meta.Prefs.get_dynamic_workspaces ()) { return; }