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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,12 @@ namespace Gala {
* on all workspaces
*
* @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