Skip to content

Commit 88a715a

Browse files
committed
WindowOverview: Cleanup
1 parent a986881 commit 88a715a

File tree

1 file changed

+47
-112
lines changed

1 file changed

+47
-112
lines changed

src/Widgets/WindowOverview.vala

Lines changed: 47 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright 2012 Tom Beckmann
33
* Copyright 2012 Rico Tzschichholz
4-
* Copyright 2023 elementary, Inc. <https://elementary.io>
4+
* Copyright 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, 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);
@@ -29,15 +27,20 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
2927
gesture_controller = new GestureController (MULTITASKING_VIEW, this, wm) {
3028
enabled = false
3129
};
32-
}
3330

31+
monitors = new ActorTarget ();
32+
add_child (monitors);
33+
34+
wm.get_display ().window_left_monitor.connect (window_left_monitor);
35+
}
3436

3537
public override bool key_press_event (Clutter.Event event) {
3638
if (!is_opened ()) {
3739
return Clutter.EVENT_PROPAGATE;
3840
}
3941

40-
return window_clone_container.key_press_event (event);
42+
//TODO: Navigating between monitors
43+
return get_child_at_index (wm.get_display ().get_primary_monitor ()).key_press_event (event);
4144
}
4245

4346
public override bool button_release_event (Clutter.Event event) {
@@ -59,10 +62,8 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
5962
* {@inheritDoc}
6063
*/
6164
public void open (HashTable<string,Variant>? hints = null) {
62-
workspaces = new List<Meta.Workspace> ();
63-
unowned var manager = wm.get_display ().get_workspace_manager ();
64-
foreach (unowned var workspace in manager.get_workspaces ()) {
65-
workspaces.append (workspace);
65+
if (visible) {
66+
return;
6667
}
6768

6869
uint64[]? window_ids = null;
@@ -71,44 +72,29 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
7172
}
7273

7374
var windows = new List<Meta.Window> ();
74-
foreach (var workspace in workspaces) {
75-
foreach (unowned var window in workspace.list_windows ()) {
76-
if (window.window_type == Meta.WindowType.DOCK || NotificationStack.is_notification (window) ) {
77-
continue;
78-
}
79-
80-
if (window.window_type != Meta.WindowType.NORMAL &&
81-
window.window_type != Meta.WindowType.DIALOG ||
82-
window.is_attached_dialog () ||
83-
(window_ids != null && !(window.get_id () in window_ids))
84-
) {
85-
unowned var actor = (Meta.WindowActor) window.get_compositor_private ();
86-
actor.hide ();
87-
88-
continue;
89-
}
90-
91-
// skip windows that are on all workspace except we're currently
92-
// processing the workspace it actually belongs to
93-
if (window.on_all_workspaces && window.get_workspace () != workspace) {
94-
continue;
95-
}
96-
97-
windows.append (window);
75+
foreach (unowned var window_actor in wm.get_display ().get_window_actors ()) {
76+
var window = window_actor.meta_window;
77+
if (ShellClientsManager.get_instance ().is_positioned_window (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+
window_actor.hide ();
87+
88+
continue;
9889
}
90+
91+
windows.append (window);
9992
}
10093

10194
if (windows.is_empty ()) {
10295
return;
10396
}
10497

105-
foreach (var workspace in workspaces) {
106-
workspace.window_added.connect (add_window);
107-
workspace.window_removed.connect (remove_window);
108-
}
109-
110-
wm.get_display ().window_left_monitor.connect (window_left_monitor);
111-
11298
grab_key_focus ();
11399

114100
modal_proxy = wm.push_modal (this);
@@ -121,7 +107,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
121107
var geometry = display.get_monitor_geometry (i);
122108
var scale = display.get_monitor_scale (i);
123109

124-
window_clone_container = new WindowCloneContainer (wm, scale, true) {
110+
var window_clone_container = new WindowCloneContainer (wm, scale, true) {
125111
padding_top = TOP_GAP,
126112
padding_left = BORDER,
127113
padding_right = BORDER,
@@ -134,7 +120,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
134120
window_clone_container.window_selected.connect (thumb_selected);
135121
window_clone_container.requested_close.connect (() => close ());
136122

137-
add_child (window_clone_container);
123+
monitors.add_child (window_clone_container);
138124
}
139125

140126
visible = true;
@@ -143,7 +129,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
143129
unowned var actor = (Meta.WindowActor) window.get_compositor_private ();
144130
actor.hide ();
145131

146-
unowned var container = (WindowCloneContainer) get_child_at_index (window.get_monitor ());
132+
unowned var container = (WindowCloneContainer) monitors.get_child_at_index (window.get_monitor ());
147133
if (container == null) {
148134
continue;
149135
}
@@ -175,60 +161,6 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
175161
return true;
176162
}
177163

178-
private void window_left_monitor (int num, Meta.Window window) {
179-
unowned var container = (WindowCloneContainer) get_child_at_index (num);
180-
if (container == null) {
181-
return;
182-
}
183-
184-
// make sure the window belongs to one of our workspaces
185-
foreach (var workspace in workspaces) {
186-
if (window.located_on_workspace (workspace)) {
187-
container.remove_window (window);
188-
break;
189-
}
190-
}
191-
}
192-
193-
private void add_window (Meta.Window window) {
194-
if (!visible) {
195-
return;
196-
}
197-
if (window.window_type == Meta.WindowType.DOCK || NotificationStack.is_notification (window)) {
198-
return;
199-
}
200-
if (window.window_type != Meta.WindowType.NORMAL &&
201-
window.window_type != Meta.WindowType.DIALOG ||
202-
window.is_attached_dialog ()) {
203-
unowned var actor = (Meta.WindowActor) window.get_compositor_private ();
204-
actor.hide ();
205-
206-
return;
207-
}
208-
209-
unowned var container = (WindowCloneContainer) get_child_at_index (window.get_monitor ());
210-
if (container == null) {
211-
return;
212-
}
213-
214-
// make sure the window belongs to one of our workspaces
215-
foreach (var workspace in workspaces) {
216-
if (window.located_on_workspace (workspace)) {
217-
container.add_window (window);
218-
break;
219-
}
220-
}
221-
}
222-
223-
private void remove_window (Meta.Window window) {
224-
unowned var container = (WindowCloneContainer) get_child_at_index (window.get_monitor ());
225-
if (container == null) {
226-
return;
227-
}
228-
229-
container.remove_window (window);
230-
}
231-
232164
private void thumb_selected (Meta.Window window) {
233165
if (window.get_workspace () == wm.get_display ().get_workspace_manager ().get_active_workspace ()) {
234166
window.activate (window.get_display ().get_current_time ());
@@ -244,6 +176,17 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
244176
}
245177
}
246178

179+
private void window_left_monitor (int monitor, Meta.Window window) {
180+
if (!visible) {
181+
return;
182+
}
183+
184+
var container = (WindowCloneContainer) monitors.get_child_at_index (monitor);
185+
if (container != null) {
186+
container.remove_window (window);
187+
}
188+
}
189+
247190
/**
248191
* {@inheritDoc}
249192
*/
@@ -252,22 +195,14 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
252195
return;
253196
}
254197

255-
foreach (var workspace in workspaces) {
256-
workspace.window_added.disconnect (add_window);
257-
workspace.window_removed.disconnect (remove_window);
258-
}
259-
wm.get_display ().window_left_monitor.disconnect (window_left_monitor);
260-
261-
Clutter.Threads.Timeout.add (MultitaskingView.ANIMATION_DURATION, () => {
262-
cleanup ();
263-
264-
return Source.REMOVE;
265-
});
266-
267198
gesture_controller.goto (0);
268199
}
269200

270-
private void cleanup () {
201+
public override void end_progress (GestureAction action) {
202+
if (action != MULTITASKING_VIEW || get_current_commit (MULTITASKING_VIEW) > 0.5) {
203+
return;
204+
}
205+
271206
visible = false;
272207

273208
wm.pop_modal (modal_proxy);
@@ -278,6 +213,6 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
278213
}
279214
}
280215

281-
destroy_all_children ();
216+
monitors.remove_all_children ();
282217
}
283218
}

0 commit comments

Comments
 (0)