mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +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;
|
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)
|
// For windows that FancyZones shouldn't process (start menu, tray, popup menus)
|
||||||
// VirtualDesktopManager is unable to retrieve virtual desktop id and returns an error.
|
// VirtualDesktopManager is unable to retrieve virtual desktop id and returns an error.
|
||||||
auto desktopId = VirtualDesktop::instance().GetDesktopId(window);
|
auto desktopId = VirtualDesktop::instance().GetDesktopId(window);
|
||||||
auto currentDesktopId = VirtualDesktop::instance().GetCurrentVirtualDesktopId();
|
|
||||||
if (!desktopId.has_value())
|
if (!desktopId.has_value())
|
||||||
{
|
{
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,8 +190,13 @@ bool VirtualDesktop::IsVirtualDesktopIdSavedInRegistry(GUID id) const
|
|||||||
|
|
||||||
bool VirtualDesktop::IsWindowOnCurrentDesktop(HWND window) const
|
bool VirtualDesktop::IsWindowOnCurrentDesktop(HWND window) const
|
||||||
{
|
{
|
||||||
std::optional<GUID> id = GetDesktopId(window);
|
BOOL isWindowOnCurrentDesktop = false;
|
||||||
return id.has_value();
|
if (m_vdManager)
|
||||||
|
{
|
||||||
|
m_vdManager->IsWindowOnCurrentVirtualDesktop(window, &isWindowOnCurrentDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isWindowOnCurrentDesktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<GUID> VirtualDesktop::GetDesktopId(HWND window) const
|
std::optional<GUID> VirtualDesktop::GetDesktopId(HWND window) const
|
||||||
|
|||||||
Reference in New Issue
Block a user