From 75c7598f7feb1cbbc8afab682fa38c9d96c5f5db Mon Sep 17 00:00:00 2001 From: lenemter Date: Sat, 28 Oct 2023 14:45:26 +0900 Subject: [PATCH 1/4] MultitaskingView: cleanup and bugfixes --- src/Widgets/MultitaskingView.vala | 73 ++++++++++++++++--------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 7604ef1c2..e7736cdd7 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -44,6 +44,13 @@ namespace Gala { private GLib.Settings gala_behavior_settings; + private bool switching_workspace_with_gesture = false; + private bool switching_workspace_in_progress { + get { + return switching_workspace_with_gesture || workspaces.get_transition ("x") != null; + } + } + public MultitaskingView (WindowManager wm) { Object (wm: wm); } @@ -131,7 +138,7 @@ namespace Gala { update_monitors (); update_positions (false); - return false; + return Source.REMOVE; }); }); } @@ -281,16 +288,21 @@ namespace Gala { } private void switch_workspace_with_gesture (Meta.MotionDirection direction) { - var relative_dir = (direction == Meta.MotionDirection.LEFT) ? -1 : 1; + if (switching_workspace_in_progress) { + return; + } - unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); + unowned var manager = display.get_workspace_manager (); var num_workspaces = manager.get_n_workspaces (); - var active_workspace_index = manager.get_active_workspace ().index (); - var target_workspace_index = active_workspace_index + relative_dir; + + unowned var active_workspace = manager.get_active_workspace (); + + var relative_dir = (direction == Meta.MotionDirection.LEFT) ? -1 : 1; + unowned var target_workspace = manager.get_workspace_by_index (active_workspace.index () + relative_dir); float initial_x = workspaces.x; float target_x = 0; - bool is_nudge_animation = (target_workspace_index < 0 || target_workspace_index >= num_workspaces); + bool is_nudge_animation = (target_workspace.index () < 0 || target_workspace.index () >= num_workspaces); var scale = display.get_monitor_scale (display.get_primary_monitor ()); var nudge_gap = InternalUtils.scale_to_int (WindowManagerGala.NUDGE_GAP, scale); @@ -303,12 +315,12 @@ namespace Gala { } else { foreach (unowned var child in workspaces.get_children ()) { unowned var workspace_clone = (WorkspaceClone) child; - var index = workspace_clone.workspace.index (); + var workspace = workspace_clone.workspace; - if (index == target_workspace_index) { + if (workspace == target_workspace) { target_icon_group = workspace_clone.icon_group; target_x = -workspace_clone.multitasking_view_x (); - } else if (index == active_workspace_index) { + } else if (workspace == active_workspace) { active_icon_group = workspace_clone.icon_group; } } @@ -322,13 +334,16 @@ namespace Gala { } debug ("Starting MultitaskingView switch workspace animation:"); - debug ("Active workspace index: %d", active_workspace_index); - debug ("Target workspace index: %d", target_workspace_index); + debug ("Active workspace index: %d", active_workspace.index ()); + debug ("Target workspace index: %d", target_workspace.index ()); debug ("Total number of workspaces: %d", num_workspaces); debug ("Is nudge animation: %s", is_nudge_animation ? "Yes" : "No"); debug ("Initial X: %f", initial_x); debug ("Target X: %f", target_x); + switching_workspace_with_gesture = true; + target_workspace.activate (display.get_current_time ()); + GestureTracker.OnUpdate on_animation_update = (percentage) => { var x = GestureTracker.animation_value (initial_x, target_x, percentage, true); var icon_group_opacity = GestureTracker.animation_value (0.0f, 1.0f, percentage, false); @@ -346,7 +361,7 @@ namespace Gala { }; GestureTracker.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => { - workspace_gesture_tracker.enabled = false; + switching_workspace_with_gesture = false; var duration = is_nudge_animation ? (uint) (AnimationDuration.NUDGE / 2) : @@ -380,24 +395,8 @@ namespace Gala { } } - - var transition = workspaces.get_transition ("x"); - if (transition != null) { - transition.completed.connect (() => { - workspace_gesture_tracker.enabled = true; - - if (!is_nudge_animation && !cancel_action) { - manager.get_workspace_by_index (target_workspace_index).activate (display.get_current_time ()); - update_positions (false); - } - }); - } else { - workspace_gesture_tracker.enabled = true; - - if (!is_nudge_animation && !cancel_action) { - manager.get_workspace_by_index (target_workspace_index).activate (display.get_current_time ()); - update_positions (false); - } + if (is_nudge_animation || cancel_action) { + active_workspace.activate (display.get_current_time ()); } }; @@ -416,16 +415,20 @@ namespace Gala { * positions immediately. */ private void update_positions (bool animate) { - unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); - var active_index = manager.get_active_workspace ().index (); + if (switching_workspace_with_gesture) { + return; + } + + unowned var manager = display.get_workspace_manager (); + var active_workspace = manager.get_active_workspace (); var active_x = 0.0f; foreach (unowned var child in workspaces.get_children ()) { unowned var workspace_clone = (WorkspaceClone) child; - var index = workspace_clone.workspace.index (); + var workspace = workspace_clone.workspace; var dest_x = workspace_clone.multitasking_view_x (); - if (index == active_index) { + if (workspace == active_workspace) { active_x = dest_x; workspace_clone.icon_group.backdrop_opacity = 1.0f; } else { @@ -755,7 +758,7 @@ namespace Gala { toggle (false, true); } - return false; + return Source.REMOVE; }); }; From ce1db2ed3d134c3112b5ea25db166227f44986bb Mon Sep 17 00:00:00 2001 From: lenemter Date: Sat, 28 Oct 2023 14:52:41 +0900 Subject: [PATCH 2/4] Fix segfault --- src/Widgets/MultitaskingView.vala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index e7736cdd7..b74777406 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -294,15 +294,17 @@ namespace Gala { unowned var manager = display.get_workspace_manager (); var num_workspaces = manager.get_n_workspaces (); + var relative_dir = (direction == Meta.MotionDirection.LEFT) ? -1 : 1; unowned var active_workspace = manager.get_active_workspace (); - var relative_dir = (direction == Meta.MotionDirection.LEFT) ? -1 : 1; - unowned var target_workspace = manager.get_workspace_by_index (active_workspace.index () + relative_dir); + var target_workspace_index = active_workspace.index () + relative_dir; + var target_workspace_exists = target_workspace_index >= 0 && target_workspace_index < num_workspaces; + unowned var target_workspace = manager.get_workspace_by_index (target_workspace_index); float initial_x = workspaces.x; float target_x = 0; - bool is_nudge_animation = (target_workspace.index () < 0 || target_workspace.index () >= num_workspaces); + bool is_nudge_animation = !target_workspace_exists; var scale = display.get_monitor_scale (display.get_primary_monitor ()); var nudge_gap = InternalUtils.scale_to_int (WindowManagerGala.NUDGE_GAP, scale); @@ -335,14 +337,16 @@ namespace Gala { debug ("Starting MultitaskingView switch workspace animation:"); debug ("Active workspace index: %d", active_workspace.index ()); - debug ("Target workspace index: %d", target_workspace.index ()); + debug ("Target workspace index: %d", target_workspace_index); debug ("Total number of workspaces: %d", num_workspaces); debug ("Is nudge animation: %s", is_nudge_animation ? "Yes" : "No"); debug ("Initial X: %f", initial_x); debug ("Target X: %f", target_x); switching_workspace_with_gesture = true; - target_workspace.activate (display.get_current_time ()); + if (target_workspace != null) { + target_workspace.activate (display.get_current_time ()); + } GestureTracker.OnUpdate on_animation_update = (percentage) => { var x = GestureTracker.animation_value (initial_x, target_x, percentage, true); From dbdcb917ab0a0dcc6dd22809b786ebc6b8337e96 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 30 Oct 2023 14:17:04 +0900 Subject: [PATCH 3/4] Update metainfo --- data/gala.metainfo.xml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/gala.metainfo.xml.in b/data/gala.metainfo.xml.in index 049600cdb..d5a3c0917 100644 --- a/data/gala.metainfo.xml.in +++ b/data/gala.metainfo.xml.in @@ -31,6 +31,7 @@
  • Changing the wallpaper or going to sleep respects the "Reduce Motion" option
  • Use appropriate drag-and-drop pointers when moving windows
  • +
  • Fix the issue when gestures in the multitasking view might stop working
  • Updated translations
From 1c071b4410564c871183ac00a820e0380cae0644 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 30 Oct 2023 15:39:16 +0900 Subject: [PATCH 4/4] Reduce diff --- src/Widgets/MultitaskingView.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index b74777406..124c62139 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -138,7 +138,7 @@ namespace Gala { update_monitors (); update_positions (false); - return Source.REMOVE; + return false; }); }); } @@ -762,7 +762,7 @@ namespace Gala { toggle (false, true); } - return Source.REMOVE; + return false; }); };