Skip to content

Commit 87e6a60

Browse files
committed
WindowOverview: Cleanup
1 parent 9e90a1c commit 87e6a60

File tree

1 file changed

+33
-111
lines changed

1 file changed

+33
-111
lines changed

src/Widgets/WindowOverview.vala

Lines changed: 33 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -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,18 @@ 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+
}
3434

3535
public override bool key_press_event (Clutter.Event event) {
3636
if (!is_opened ()) {
3737
return Clutter.EVENT_PROPAGATE;
3838
}
3939

40-
return window_clone_container.key_press_event (event);
40+
//TODO: Navigating between monitors
41+
return get_child_at_index (wm.get_display ().get_primary_monitor ()).key_press_event (event);
4142
}
4243

4344
public override bool button_release_event (Clutter.Event event) {
@@ -59,10 +60,8 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
5960
* {@inheritDoc}
6061
*/
6162
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);
63+
if (visible) {
64+
return;
6665
}
6766

6867
uint64[]? window_ids = null;
@@ -71,44 +70,29 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
7170
}
7271

7372
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);
73+
foreach (unowned var window_actor in wm.get_display ().get_window_actors ()) {
74+
var window = window_actor.meta_window;
75+
if (ShellClientsManager.get_instance ().is_positioned_window (window)) {
76+
continue;
9877
}
78+
79+
if (window.window_type != Meta.WindowType.NORMAL &&
80+
window.window_type != Meta.WindowType.DIALOG ||
81+
window.is_attached_dialog () ||
82+
window_ids != null && !(window.get_id () in window_ids)
83+
) {
84+
window_actor.hide ();
85+
86+
continue;
87+
}
88+
89+
windows.append (window);
9990
}
10091

10192
if (windows.is_empty ()) {
10293
return;
10394
}
10495

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-
11296
grab_key_focus ();
11397

11498
modal_proxy = wm.push_modal (this);
@@ -121,7 +105,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
121105
var geometry = display.get_monitor_geometry (i);
122106
var scale = display.get_monitor_scale (i);
123107

124-
window_clone_container = new WindowCloneContainer (wm, scale, true) {
108+
var window_clone_container = new WindowCloneContainer (wm, scale, true) {
125109
padding_top = TOP_GAP,
126110
padding_left = BORDER,
127111
padding_right = BORDER,
@@ -134,7 +118,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
134118
window_clone_container.window_selected.connect (thumb_selected);
135119
window_clone_container.requested_close.connect (() => close ());
136120

137-
add_child (window_clone_container);
121+
monitors.add_child (window_clone_container);
138122
}
139123

140124
visible = true;
@@ -143,7 +127,7 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
143127
unowned var actor = (Meta.WindowActor) window.get_compositor_private ();
144128
actor.hide ();
145129

146-
unowned var container = (WindowCloneContainer) get_child_at_index (window.get_monitor ());
130+
unowned var container = (WindowCloneContainer) monitors.get_child_at_index (window.get_monitor ());
147131
if (container == null) {
148132
continue;
149133
}
@@ -175,60 +159,6 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
175159
return true;
176160
}
177161

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-
232162
private void thumb_selected (Meta.Window window) {
233163
if (window.get_workspace () == wm.get_display ().get_workspace_manager ().get_active_workspace ()) {
234164
window.activate (window.get_display ().get_current_time ());
@@ -252,22 +182,14 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
252182
return;
253183
}
254184

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-
267185
gesture_controller.goto (0);
268186
}
269187

270-
private void cleanup () {
188+
public override void end_progress (GestureAction action) {
189+
if (action != MULTITASKING_VIEW || get_current_commit (MULTITASKING_VIEW) > 0.5) {
190+
return;
191+
}
192+
271193
visible = false;
272194

273195
wm.pop_modal (modal_proxy);
@@ -278,6 +200,6 @@ public class Gala.WindowOverview : ActorTarget, ActivatableComponent {
278200
}
279201
}
280202

281-
destroy_all_children ();
203+
monitors.remove_all_children ();
282204
}
283205
}

0 commit comments

Comments
 (0)