[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:
Seraphima Zykova
2022-06-09 14:34:22 +02:00
committed by GitHub
parent a11f9ab4c9
commit 5c8742e557
2 changed files with 10 additions and 6 deletions

View File

@@ -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;
}

View File

@@ -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