Skip to content

[FancyZones] Improve handling of current virtual desktop identifier #2160

Description

In order to get current virtual desktop id we are parsing data from registry Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SessionInfo\\<session-id>\\VirtualDesktops. When system is first started and only one (virtual) desktop exists there is no virtual desktop id in mentioned registry key (value is empty), so we use GUID 00000000-0000-0000-0000-000000000000.

After creating new virtual desktop, both of them get assigned with valid GUID, and 00000000-0000-0000-0000-000000000000 is never used latter on. Having GUID of primary desktop changing from empty (all zeros) was cause of several issues in the past, and handling it is tricky.
Using https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ivirtualdesktopmanager and method GetWindowDesktopId could help us to bypass this problem and have valid GUID for all desktops at any point.

Modify ZoneWindow class to use this API for it's virtual desktop id, and check all other places handling virtual desktop id if it can be simplified. This might be good opportunity to replace unique identifier (Format: <device-id>_<resolution>_<virtual-desktop-id>) and instead of string use object.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions