From a12e0856782b362bc9a1ca780f08451ce5f22724 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 30 Oct 2023 12:59:38 +0900 Subject: [PATCH 1/3] Reload workspace clones when monitors change --- src/Widgets/MultitaskingView.vala | 49 +++++++++++++++++++++---------- src/Widgets/WorkspaceClone.vala | 2 ++ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index 7604ef1c2..ceb5fb8d7 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -68,7 +68,6 @@ namespace Gala { workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected); workspaces = new Clutter.Actor (); - workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); icon_groups = new IconGroupContainer (wm, display.get_monitor_scale (display.get_primary_monitor ())); @@ -83,11 +82,7 @@ namespace Gala { add_child (primary_monitor_container); add_child (dock_clones); - unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); - for (int i = 0; i < manager.get_n_workspaces (); i++) { - add_workspace (i); - } - + unowned var manager = display.get_workspace_manager (); manager.workspace_added.connect (add_workspace); manager.workspace_removed.connect (remove_workspace); manager.workspaces_reordered.connect (() => update_positions (false)); @@ -141,15 +136,19 @@ namespace Gala { * MonitorClones at the right positions */ private void update_monitors () { - foreach (var monitor_clone in window_containers_monitors) + update_workspaces (); + + foreach (var monitor_clone in window_containers_monitors) { monitor_clone.destroy (); + } var primary = display.get_primary_monitor (); if (InternalUtils.workspaces_only_on_primary ()) { for (var monitor = 0; monitor < display.get_n_monitors (); monitor++) { - if (monitor == primary) + if (monitor == primary) { continue; + } var monitor_clone = new MonitorClone (wm, display, monitor, multitasking_gesture_tracker); monitor_clone.window_selected.connect (window_selected); @@ -167,13 +166,26 @@ namespace Gala { primary_monitor_container.set_position (primary_geometry.x, primary_geometry.y); primary_monitor_container.set_size (primary_geometry.width, primary_geometry.height); - foreach (var child in workspaces.get_children ()) { - unowned WorkspaceClone workspace_clone = (WorkspaceClone) child; + foreach (unowned var child in workspaces.get_children ()) { + unowned var workspace_clone = (WorkspaceClone) child; workspace_clone.scale_factor = scale; workspace_clone.update_size (primary_geometry); } } + private void update_workspaces () { + foreach (unowned var child in workspaces.get_children ()) { + unowned var workspace_clone = (WorkspaceClone) child; + icon_groups.remove_group (workspace_clone.icon_group); + workspace_clone.destroy (); + } + + unowned var manager = display.get_workspace_manager (); + for (int i = 0; i < manager.get_n_workspaces (); i++) { + add_workspace (i); + } + } + /** * Scroll through workspaces with the mouse wheel. Smooth scrolling is handled by * GestureTracker. @@ -353,6 +365,7 @@ namespace Gala { (uint) calculated_duration; workspaces.save_easing_state (); + workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); workspaces.set_easing_duration (duration); workspaces.x = (is_nudge_animation || cancel_action) ? initial_x : target_x; workspaces.restore_easing_state (); @@ -439,6 +452,7 @@ namespace Gala { } workspaces.save_easing_state (); + workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); workspaces.set_easing_duration ((animate && wm.enable_animations) ? AnimationDuration.WORKSPACE_SWITCH_MIN : 0); workspaces.x = -active_x; workspaces.restore_easing_state (); @@ -472,17 +486,19 @@ namespace Gala { private void add_workspace (int num) { unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); var scale = display.get_monitor_scale (display.get_primary_monitor ()); - var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), multitasking_gesture_tracker, scale); - workspace.window_selected.connect (window_selected); - workspace.selected.connect (activate_workspace); + var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), multitasking_gesture_tracker, scale); workspaces.insert_child_at_index (workspace, num); icon_groups.add_group (workspace.icon_group); + workspace.window_selected.connect (window_selected); + workspace.selected.connect (activate_workspace); + update_positions (false); - if (opened) + if (opened) { workspace.open (); + } } private void remove_workspace (int num) { @@ -703,8 +719,9 @@ namespace Gala { break; } } - if (active_workspace != null) + if (active_workspace != null) { workspaces.set_child_above_sibling (active_workspace, null); + } workspaces.remove_all_transitions (); foreach (var child in workspaces.get_children ()) { @@ -755,7 +772,7 @@ namespace Gala { toggle (false, true); } - return false; + return Source.REMOVE; }); }; diff --git a/src/Widgets/WorkspaceClone.vala b/src/Widgets/WorkspaceClone.vala index 25dceb500..638d5038e 100644 --- a/src/Widgets/WorkspaceClone.vala +++ b/src/Widgets/WorkspaceClone.vala @@ -245,6 +245,8 @@ namespace Gala { listener.window_no_longer_on_all_workspaces.disconnect (add_window); background.destroy (); + window_container.destroy (); + icon_group.destroy (); } private void reallocate () { From 85e621d7cc3bc32a24fd28e9c2aa4b84d5463b88 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 30 Oct 2023 14:20:47 +0900 Subject: [PATCH 2/3] Update metainfo --- data/gala.metainfo.xml.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/gala.metainfo.xml.in b/data/gala.metainfo.xml.in index 049600cdb..82fae02d2 100644 --- a/data/gala.metainfo.xml.in +++ b/data/gala.metainfo.xml.in @@ -39,6 +39,9 @@ Wrong workspaces behavior Use gestures for "move to workspace" Alt + Shift unnecessarily blocked when there is only one keyboard layout + Multitasking view breaks when switching displays & strange Wingpanel position + Disconnecting external monitor breaks the multi-tasking view + Workspace wallpaper's aspect ratio with different monitors Counter Strike 2 causes segfault in libmutter on exit Scheduled switch to dark style does not dim the wallpaper after cold reboot on elementary OS 7.1 Notifications appear in the middle of the screen From 147dac7775cee2188788596bd706f2cbfe473f41 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 30 Oct 2023 15:38:03 +0900 Subject: [PATCH 3/3] Remove code style changes --- src/Widgets/MultitaskingView.vala | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index ceb5fb8d7..f044bb9de 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -68,6 +68,7 @@ namespace Gala { workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected); workspaces = new Clutter.Actor (); + workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); icon_groups = new IconGroupContainer (wm, display.get_monitor_scale (display.get_primary_monitor ())); @@ -138,17 +139,15 @@ namespace Gala { private void update_monitors () { update_workspaces (); - foreach (var monitor_clone in window_containers_monitors) { + foreach (var monitor_clone in window_containers_monitors) monitor_clone.destroy (); - } var primary = display.get_primary_monitor (); if (InternalUtils.workspaces_only_on_primary ()) { for (var monitor = 0; monitor < display.get_n_monitors (); monitor++) { - if (monitor == primary) { + if (monitor == primary) continue; - } var monitor_clone = new MonitorClone (wm, display, monitor, multitasking_gesture_tracker); monitor_clone.window_selected.connect (window_selected); @@ -166,8 +165,8 @@ namespace Gala { primary_monitor_container.set_position (primary_geometry.x, primary_geometry.y); primary_monitor_container.set_size (primary_geometry.width, primary_geometry.height); - foreach (unowned var child in workspaces.get_children ()) { - unowned var workspace_clone = (WorkspaceClone) child; + foreach (var child in workspaces.get_children ()) { + unowned WorkspaceClone workspace_clone = (WorkspaceClone) child; workspace_clone.scale_factor = scale; workspace_clone.update_size (primary_geometry); } @@ -365,7 +364,6 @@ namespace Gala { (uint) calculated_duration; workspaces.save_easing_state (); - workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); workspaces.set_easing_duration (duration); workspaces.x = (is_nudge_animation || cancel_action) ? initial_x : target_x; workspaces.restore_easing_state (); @@ -452,7 +450,6 @@ namespace Gala { } workspaces.save_easing_state (); - workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); workspaces.set_easing_duration ((animate && wm.enable_animations) ? AnimationDuration.WORKSPACE_SWITCH_MIN : 0); workspaces.x = -active_x; workspaces.restore_easing_state (); @@ -486,19 +483,17 @@ namespace Gala { private void add_workspace (int num) { unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); var scale = display.get_monitor_scale (display.get_primary_monitor ()); - var workspace = new WorkspaceClone (wm, manager.get_workspace_by_index (num), multitasking_gesture_tracker, scale); - workspaces.insert_child_at_index (workspace, num); - icon_groups.add_group (workspace.icon_group); - workspace.window_selected.connect (window_selected); workspace.selected.connect (activate_workspace); + workspaces.insert_child_at_index (workspace, num); + icon_groups.add_group (workspace.icon_group); + update_positions (false); - if (opened) { + if (opened) workspace.open (); - } } private void remove_workspace (int num) { @@ -719,9 +714,8 @@ namespace Gala { break; } } - if (active_workspace != null) { + if (active_workspace != null) workspaces.set_child_above_sibling (active_workspace, null); - } workspaces.remove_all_transitions (); foreach (var child in workspaces.get_children ()) { @@ -772,7 +766,7 @@ namespace Gala { toggle (false, true); } - return Source.REMOVE; + return false; }); };