Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkspaceManager: Queue an idle to add a window #2271

Merged
merged 3 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ShellClients/NotificationsClient.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Gala.NotificationsClient : Object {
client.window_created.connect ((window) => {
window.set_data (NOTIFICATION_DATA_KEY, true);
window.make_above ();
window.stick ();
#if HAS_MUTTER46
client.wayland_client.make_dock (window);
#endif
Expand Down
18 changes: 13 additions & 5 deletions src/WorkspaceManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class Gala.WorkspaceManager : Object {
return;
}

workspace.window_added.connect (window_added);
workspace.window_added.connect (queue_window_added);
workspace.window_removed.connect (window_removed);
}

Expand Down Expand Up @@ -124,9 +124,15 @@ public class Gala.WorkspaceManager : Object {
}
}

private void window_added (Meta.Workspace? workspace, Meta.Window window) {
private void queue_window_added (Meta.Workspace? workspace, Meta.Window window) {
// We get this call very early so we have to queue an idle for ShellClients
// that might not have checked the window/got a protocol call yet
Idle.add (() => window_added (workspace, window));
}

private bool window_added (Meta.Workspace? workspace, Meta.Window window) {
if (workspace == null || !Meta.Prefs.get_dynamic_workspaces () || window.on_all_workspaces) {
return;
return Source.REMOVE;
}

unowned Meta.WorkspaceManager manager = workspace.get_display ().get_workspace_manager ();
Expand All @@ -139,6 +145,8 @@ public class Gala.WorkspaceManager : Object {
) {
append_workspace ();
}

return Source.REMOVE;
}

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

private void window_entered_monitor (Meta.Display display, int monitor, Meta.Window window) {
if (InternalUtils.workspaces_only_on_primary () && monitor == display.get_primary_monitor ()) {
window_added (window.get_workspace (), window);
queue_window_added (window.get_workspace (), window);
}
}

Expand Down Expand Up @@ -243,7 +251,7 @@ public class Gala.WorkspaceManager : Object {
return;
}

workspace.window_added.disconnect (window_added);
workspace.window_added.disconnect (queue_window_added);
workspace.window_removed.disconnect (window_removed);

workspaces_marked_removed.add (workspace);
Expand Down