Skip to content

Commit

Permalink
Merge branch 'main' into lenemter/dock-workspace-switcher-pof
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Feb 15, 2025
2 parents 0669c0a + ef6292a commit 34ca30c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
25 changes: 15 additions & 10 deletions src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ public class Gala.HideTracker : Object {
Object (display: display, panel: panel);
}

~HideTracker () {
if (hide_timeout_id != 0) {
Source.remove (hide_timeout_id);
}

if (update_timeout_id != 0) {
Source.remove (update_timeout_id);
}
}

construct {
panel.window.unmanaging.connect_after (() => {
// The timeouts hold refs on us so we stay connected to signal handlers that might
// access the panel which was already freed. To prevent that make sure we reset
// the timeouts so that we get freed immediately
reset_hide_timeout ();
reset_update_timeout ();
});

// Can't be local otherwise we get a memory leak :(
// See https://gitlab.gnome.org/GNOME/vala/-/issues/1548
current_focus_window = display.focus_window;
Expand Down Expand Up @@ -152,6 +150,13 @@ public class Gala.HideTracker : Object {
});
}

private void reset_update_timeout () {
if (update_timeout_id != 0) {
Source.remove (update_timeout_id);
update_timeout_id = 0;
}
}

public void update_overlap () {
overlap = false;
focus_overlap = false;
Expand Down
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

0 comments on commit 34ca30c

Please sign in to comment.