11/*
22 * Copyright 2012 Tom Beckmann
33 * Copyright 2012 Rico Tzschichholz
4- * Copyright 2023 elementary, Inc. <https://elementary.io>
4+ * Copyright 2023-2025 elementary, Inc. <https://elementary.io>
55 * SPDX-License-Identifier: GPL-3.0-or-later
66 */
77
@@ -14,10 +14,8 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
1414
1515 private GestureController gesture_controller; // Currently not used for actual touchpad gestures but only as controller
1616
17+ private Clutter . Actor monitors;
1718 private ModalProxy modal_proxy;
18- // the workspaces which we expose right now
19- private List<Meta . Workspace > workspaces;
20- private WindowCloneContainer window_clone_container;
2119
2220 public WindowOverview (WindowManager wm ) {
2321 Object (wm : wm);
@@ -30,15 +28,20 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
3028 enabled = false
3129 };
3230 add_gesture_controller (gesture_controller);
33- }
3431
32+ monitors = new ActorTarget ();
33+ add_child (monitors);
34+
35+ wm. get_display (). window_left_monitor. connect (window_left_monitor);
36+ }
3537
3638 public override bool key_press_event (Clutter .Event event ) {
3739 if (! is_opened ()) {
3840 return Clutter . EVENT_PROPAGATE ;
3941 }
4042
41- return window_clone_container. key_press_event (event);
43+ // TODO: Navigating between monitors
44+ return get_child_at_index (wm. get_display (). get_primary_monitor ()). key_press_event (event);
4245 }
4346
4447 public override bool button_release_event (Clutter .Event event ) {
@@ -60,10 +63,8 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
6063 * {@inheritDoc }
6164 */
6265 public void open (HashTable<string,Variant > ? hints = null ) {
63- workspaces = new List<Meta . Workspace > ();
64- unowned var manager = wm. get_display (). get_workspace_manager ();
65- foreach (unowned var workspace in manager. get_workspaces ()) {
66- workspaces. append (workspace);
66+ if (visible) {
67+ return ;
6768 }
6869
6970 uint64 []? window_ids = null ;
@@ -72,44 +73,29 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
7273 }
7374
7475 var windows = new List<Meta . Window > ();
75- foreach (var workspace in workspaces) {
76- foreach (unowned var window in workspace. list_windows ()) {
77- if (window. window_type == Meta . WindowType . DOCK || NotificationStack . is_notification (window) ) {
78- continue ;
79- }
80-
81- if (window. window_type != Meta . WindowType . NORMAL &&
82- window. window_type != Meta . WindowType . DIALOG ||
83- window. is_attached_dialog () ||
84- (window_ids != null && ! (window. get_id () in window_ids))
85- ) {
86- unowned var actor = (Meta . WindowActor ) window. get_compositor_private ();
87- actor. hide ();
88-
89- continue ;
90- }
91-
92- // skip windows that are on all workspace except we're currently
93- // processing the workspace it actually belongs to
94- if (window. on_all_workspaces && window. get_workspace () != workspace) {
95- continue ;
96- }
97-
98- windows. append (window);
76+ foreach (unowned var window_actor in wm. get_display (). get_window_actors ()) {
77+ var window = window_actor. meta_window;
78+ if (ShellClientsManager . get_instance (). is_positioned_window (window)) {
79+ continue ;
80+ }
81+
82+ if (window. window_type != Meta . WindowType . NORMAL &&
83+ window. window_type != Meta . WindowType . DIALOG ||
84+ window. is_attached_dialog () ||
85+ window_ids != null && ! (window. get_id () in window_ids)
86+ ) {
87+ window_actor. hide ();
88+
89+ continue ;
9990 }
91+
92+ windows. append (window);
10093 }
10194
10295 if (windows. is_empty ()) {
10396 return ;
10497 }
10598
106- foreach (var workspace in workspaces) {
107- workspace. window_added. connect (add_window);
108- workspace. window_removed. connect (remove_window);
109- }
110-
111- wm. get_display (). window_left_monitor. connect (window_left_monitor);
112-
11399 grab_key_focus ();
114100
115101 modal_proxy = wm. push_modal (this );
@@ -122,7 +108,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
122108 var geometry = display. get_monitor_geometry (i);
123109 var scale = display. get_monitor_scale (i);
124110
125- window_clone_container = new WindowCloneContainer (wm, scale, true ) {
111+ var window_clone_container = new WindowCloneContainer (wm, scale, true ) {
126112 padding_top = TOP_GAP ,
127113 padding_left = BORDER ,
128114 padding_right = BORDER ,
@@ -136,7 +122,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
136122 window_clone_container. requested_close. connect (() = > close ());
137123 window_clone_container. last_window_closed. connect (() = > close ());
138124
139- add_child (window_clone_container);
125+ monitors . add_child (window_clone_container);
140126 }
141127
142128 visible = true ;
@@ -145,7 +131,7 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
145131 unowned var actor = (Meta . WindowActor ) window. get_compositor_private ();
146132 actor. hide ();
147133
148- unowned var container = (WindowCloneContainer ) get_child_at_index (window. get_monitor ());
134+ unowned var container = (WindowCloneContainer ) monitors . get_child_at_index (window. get_monitor ());
149135 if (container == null ) {
150136 continue ;
151137 }
@@ -177,60 +163,6 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
177163 return true ;
178164 }
179165
180- private void window_left_monitor (int num , Meta .Window window ) {
181- unowned var container = (WindowCloneContainer ) get_child_at_index (num);
182- if (container == null ) {
183- return ;
184- }
185-
186- // make sure the window belongs to one of our workspaces
187- foreach (var workspace in workspaces) {
188- if (window. located_on_workspace (workspace)) {
189- container. remove_window (window);
190- break ;
191- }
192- }
193- }
194-
195- private void add_window (Meta .Window window ) {
196- if (! visible) {
197- return ;
198- }
199- if (window. window_type == Meta . WindowType . DOCK || NotificationStack . is_notification (window)) {
200- return ;
201- }
202- if (window. window_type != Meta . WindowType . NORMAL &&
203- window. window_type != Meta . WindowType . DIALOG ||
204- window. is_attached_dialog ()) {
205- unowned var actor = (Meta . WindowActor ) window. get_compositor_private ();
206- actor. hide ();
207-
208- return ;
209- }
210-
211- unowned var container = (WindowCloneContainer ) get_child_at_index (window. get_monitor ());
212- if (container == null ) {
213- return ;
214- }
215-
216- // make sure the window belongs to one of our workspaces
217- foreach (var workspace in workspaces) {
218- if (window. located_on_workspace (workspace)) {
219- container. add_window (window);
220- break ;
221- }
222- }
223- }
224-
225- private void remove_window (Meta .Window window ) {
226- unowned var container = (WindowCloneContainer ) get_child_at_index (window. get_monitor ());
227- if (container == null ) {
228- return ;
229- }
230-
231- container. remove_window (window);
232- }
233-
234166 private void thumb_selected (Meta .Window window ) {
235167 if (window. get_workspace () == wm. get_display (). get_workspace_manager (). get_active_workspace ()) {
236168 window. activate (window. get_display (). get_current_time ());
@@ -246,6 +178,17 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
246178 }
247179 }
248180
181+ private void window_left_monitor (int monitor , Meta .Window window ) {
182+ if (! visible) {
183+ return ;
184+ }
185+
186+ var container = (WindowCloneContainer ) monitors. get_child_at_index (monitor);
187+ if (container != null ) {
188+ container. remove_window (window);
189+ }
190+ }
191+
249192 /**
250193 * {@inheritDoc }
251194 */
@@ -254,26 +197,14 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
254197 return ;
255198 }
256199
257- foreach (var workspace in workspaces) {
258- workspace. window_added. disconnect (add_window);
259- workspace. window_removed. disconnect (remove_window);
260- }
261- wm. get_display (). window_left_monitor. disconnect (window_left_monitor);
262-
263- #if HAS_MUTTER48
264- GLib . Timeout . add (MultitaskingView . ANIMATION_DURATION , () = > {
265- #else
266- Clutter . Threads . Timeout . add (MultitaskingView . ANIMATION_DURATION , () = > {
267- #endif
268- cleanup ();
269-
270- return Source . REMOVE ;
271- });
272-
273200 gesture_controller. goto (0 );
274201 }
275202
276- private void cleanup () {
203+ public override void end_progress (GestureAction action ) {
204+ if (action != MULTITASKING_VIEW || get_current_commit (MULTITASKING_VIEW ) > 0.5 ) {
205+ return ;
206+ }
207+
277208 visible = false ;
278209
279210 wm. pop_modal (modal_proxy);
@@ -284,6 +215,6 @@ public class Gala.WindowOverview : ActorTarget, RootTarget, ActivatableComponent
284215 }
285216 }
286217
287- destroy_all_children ();
218+ monitors . remove_all_children ();
288219 }
289220}
0 commit comments