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: Exclude a window that's about to be removed from count #2160

Merged
merged 4 commits into from
Dec 18, 2024
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
12 changes: 9 additions & 3 deletions lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,20 @@ namespace Gala {

/**
* Get the number of toplevel windows on a workspace excluding those that are
* on all workspaces
* on all workspaces.
*
* We need `exclude` here because on Meta.Workspace.window_removed
* the windows gets removed from workspace's internal window list but not display's window list
* which Meta.Workspace uses for Meta.Workspace.list_windows ().
*
* @param workspace The workspace on which to count the windows
* @param exclude a window to not count
*
*/
public static uint get_n_windows (Meta.Workspace workspace, bool on_primary = false) {
public static uint get_n_windows (Meta.Workspace workspace, bool on_primary = false, Meta.Window? exclude = null) {
var n = 0;
foreach (unowned var window in workspace.list_windows ()) {
if (window.on_all_workspaces) {
if (window.on_all_workspaces || window == exclude) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/WorkspaceManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ namespace Gala {
// or we are in modal-mode
if ((!is_active_workspace || wm.is_modal ())
&& remove_freeze_count < 1
&& Utils.get_n_windows (workspace, true) == 0
&& Utils.get_n_windows (workspace, true, window) == 0
&& workspace != last_workspace) {
remove_workspace (workspace);
}

// if window is the second last and empty, make it the last workspace
if (is_active_workspace
&& remove_freeze_count < 1
&& Utils.get_n_windows (workspace, true) == 0
&& Utils.get_n_windows (workspace, true, window) == 0
&& workspace.index () == last_workspace_index - 1) {
remove_workspace (last_workspace);
}
Expand Down
Loading