Skip to content

Commit ef6292a

Browse files
authored
WorkspaceManager: Queue an idle to add a window (#2271)
1 parent 7ace625 commit ef6292a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/ShellClients/NotificationsClient.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Gala.NotificationsClient : Object {
2020
client.window_created.connect ((window) => {
2121
window.set_data (NOTIFICATION_DATA_KEY, true);
2222
window.make_above ();
23+
window.stick ();
2324
#if HAS_MUTTER46
2425
client.wayland_client.make_dock (window);
2526
#endif

src/WorkspaceManager.vala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class Gala.WorkspaceManager : Object {
8585
return;
8686
}
8787

88-
workspace.window_added.connect (window_added);
88+
workspace.window_added.connect (queue_window_added);
8989
workspace.window_removed.connect (window_removed);
9090
}
9191

@@ -124,9 +124,15 @@ public class Gala.WorkspaceManager : Object {
124124
}
125125
}
126126

127-
private void window_added (Meta.Workspace? workspace, Meta.Window window) {
127+
private void queue_window_added (Meta.Workspace? workspace, Meta.Window window) {
128+
// We get this call very early so we have to queue an idle for ShellClients
129+
// that might not have checked the window/got a protocol call yet
130+
Idle.add (() => window_added (workspace, window));
131+
}
132+
133+
private bool window_added (Meta.Workspace? workspace, Meta.Window window) {
128134
if (workspace == null || !Meta.Prefs.get_dynamic_workspaces () || window.on_all_workspaces) {
129-
return;
135+
return Source.REMOVE;
130136
}
131137

132138
unowned Meta.WorkspaceManager manager = workspace.get_display ().get_workspace_manager ();
@@ -139,6 +145,8 @@ public class Gala.WorkspaceManager : Object {
139145
) {
140146
append_workspace ();
141147
}
148+
149+
return Source.REMOVE;
142150
}
143151

144152
private void window_removed (Meta.Workspace? workspace, Meta.Window window) {
@@ -185,7 +193,7 @@ public class Gala.WorkspaceManager : Object {
185193

186194
private void window_entered_monitor (Meta.Display display, int monitor, Meta.Window window) {
187195
if (InternalUtils.workspaces_only_on_primary () && monitor == display.get_primary_monitor ()) {
188-
window_added (window.get_workspace (), window);
196+
queue_window_added (window.get_workspace (), window);
189197
}
190198
}
191199

@@ -243,7 +251,7 @@ public class Gala.WorkspaceManager : Object {
243251
return;
244252
}
245253

246-
workspace.window_added.disconnect (window_added);
254+
workspace.window_added.disconnect (queue_window_added);
247255
workspace.window_removed.disconnect (window_removed);
248256

249257
workspaces_marked_removed.add (workspace);

0 commit comments

Comments
 (0)