Skip to content

feat: add support for multiple desktops#151

Merged
sigoden merged 5 commits intosigoden:mainfrom
ian-h-chamberlain:feature/all-desktops
Nov 21, 2024
Merged

feat: add support for multiple desktops#151
sigoden merged 5 commits intosigoden:mainfrom
ian-h-chamberlain:feature/all-desktops

Conversation

@ian-h-chamberlain
Copy link
Copy Markdown
Contributor

Closes #99

Include windows cloaked by the shell, but exclude "invisible" windows. This seems to result in pretty much the expected list of windows across all desktops instead of just the current one.

We read the Windows registry to decide whether to filter windows on other desktops or not, based on the corresponding multitasking setting.

NOTE: I will probably file a separate issue for this and try to implement it as well, but I realized it might make sense to have a corresponding setting for Alt+`; the behavior now is to follow the same setting, but macOS always limits it to the current desktop, so being able to toggle it independently would be nice. AFAIK there would be no corresponding Windows setting for this one.

Include windows cloaked by the shell, but exclude "invisible" windows.
This seems to result in pretty much the expected list of windows across
all desktops instead of just the current one.
Windows already has a setting for the Alt-tab switcher to include
virtual desktops, so we can just use that instead of a config.
@sigoden
Copy link
Copy Markdown
Owner

sigoden commented Nov 17, 2024

@ian-h-chamberlain

Add two configuration items.

[switch-windows]

#  Only switch windows in the current desktop
only_current_desktop = yes

[switch-apps]

# Only switch apps in the current desktop, yes/no/auto
# If auto, follow the system setting (Settings > System > Multitasking -> Virtual Desktops)
only_current_desktop = auto
pub struct Config {
    ...
    pub switch_windows_only_current_desktop: bool,
    ...
    pub switch_apps_only_current_desktop: Option<bool<,
}

Why add is_invisible_window?

We already have is_visible_window fn, Can you give an example of situations where is_visible_window fn is not enough, and is_invisible_window fn must also be used?

@ian-h-chamberlain
Copy link
Copy Markdown
Contributor Author

We already have is_visible_window fn, Can you give an example of situations where is_visible_window fn is not enough, and is_invisible_window fn must also be used?

There are a handful of programs that appear as "invisible", which Windows does not appear to include in its own task switcher:

$ cargo r --package inspect-windows |& grep 'visible:✓invisible:✓cloak:'
visible:✓invisible:✓cloak:0iconic: topmost:✓    1512x48      65726: 0:
visible:✓invisible:✓cloak:0iconic: topmost:         0x0     197330: 131464:
visible:✓invisible:✓cloak:0iconic: topmost:         0x0     131464: 0:
visible:✓invisible:✓cloak:2iconic: topmost:         0x0     197164:Windows Shell Experience Host 0:
visible:✓invisible:✓cloak:1iconic: topmost:         0x0      65906: 0:
visible:✓invisible:✓cloak:1iconic: topmost:      1497x2      65898: 0:
visible:✓invisible:✓cloak:1iconic: topmost:         0x0      65870: 0:
visible:✓invisible:✓cloak:1iconic: topmost:         0x0      65868: 0:
visible:✓invisible:✓cloak:1iconic: topmost:         0x0      65866: 0:
visible:✓invisible:✓cloak:1iconic: topmost:         0x0      65864: 0:
visible:✓invisible:✓cloak:0iconic: topmost:    1512x827      65808:Program Manager 0:

In particular, Windows Shell Experience here (I have also seen Calculator sometimes?) was showing up in the task switcher app list, but it really shouldn't be. This also has a side effect of filtering out Program Manager automatically, I think. I got the details about this from reading https://stackoverflow.com/a/7292674 which may have some additional useful info in general for this app.

I will work on adding the new configs and push my changes once I have it working.

@sigoden
Copy link
Copy Markdown
Owner

sigoden commented Nov 18, 2024

It seems that is_invisible_window makes sence.

Why not merge it into the is_visible_window function? It's strange to have two functions is_visible_window and is_invisible_window.

Since we have is_invisible_window, we can safely remove the following code:

let title = get_window_title(hwnd);
if !title.is_empty() && title != "Program Manager" {

@ian-h-chamberlain ian-h-chamberlain marked this pull request as ready for review November 18, 2024 04:22
@sigoden sigoden changed the title Add support for multiple desktops based on Windows settings feat: add support for multiple desktops Nov 21, 2024
@sigoden
Copy link
Copy Markdown
Owner

sigoden commented Nov 21, 2024

Good job, thanks!

@sigoden sigoden merged commit 55f0046 into sigoden:main Nov 21, 2024
@ian-h-chamberlain ian-h-chamberlain deleted the feature/all-desktops branch December 5, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Option in [switch-apps] to get apps from all desktops

2 participants