mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
[FancyZones] Process windows with "Show windows from this app on all desktops" option fix (#18675)
* changed current vd check * removed include
This commit is contained in:
@@ -19,18 +19,17 @@ namespace FancyZonesWindowProcessing
|
||||
return false;
|
||||
}
|
||||
|
||||
// Switch between virtual desktops results with posting same windows messages that also indicate
|
||||
// creation of new window. We need to check if window being processed is on currently active desktop.
|
||||
// For windows that FancyZones shouldn't process (start menu, tray, popup menus)
|
||||
// VirtualDesktopManager is unable to retrieve virtual desktop id and returns an error.
|
||||
auto desktopId = VirtualDesktop::instance().GetDesktopId(window);
|
||||
auto currentDesktopId = VirtualDesktop::instance().GetCurrentVirtualDesktopId();
|
||||
if (!desktopId.has_value())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentDesktopId != GUID_NULL && desktopId.value() != currentDesktopId)
|
||||
// Switch between virtual desktops results with posting same windows messages that also indicate
|
||||
// creation of new window. We need to check if window being processed is on currently active desktop.
|
||||
if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,13 @@ bool VirtualDesktop::IsVirtualDesktopIdSavedInRegistry(GUID id) const
|
||||
|
||||
bool VirtualDesktop::IsWindowOnCurrentDesktop(HWND window) const
|
||||
{
|
||||
std::optional<GUID> id = GetDesktopId(window);
|
||||
return id.has_value();
|
||||
BOOL isWindowOnCurrentDesktop = false;
|
||||
if (m_vdManager)
|
||||
{
|
||||
m_vdManager->IsWindowOnCurrentVirtualDesktop(window, &isWindowOnCurrentDesktop);
|
||||
}
|
||||
|
||||
return isWindowOnCurrentDesktop;
|
||||
}
|
||||
|
||||
std::optional<GUID> VirtualDesktop::GetDesktopId(HWND window) const
|
||||
|
||||
Reference in New Issue
Block a user