mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[FancyZones] Feature to create zone layouts spanning multiple monitors (#5289)
* Added the setting * Added a property to Editor Settings This will be used later * Fixed a bug in the previous commit * Simplified a method * Added snapping points to the editor * Simplified a method in ZoneSet * Updated ZoneSet testcases * Add a method to FancyZones / ZoneWindowHost * Almost works * The editor now launches, but FZ does not understand the results * Refactored some code * Snapping to a zone by dragging seems to work * Hotkeys seem to work * Refresh the work area handler after changing settings * Fixed zones not snapping to monitor edges when moved * Remove unused method in FancyZones.h * Fixed an issue with DPI awareness * Renamed setting to spanZonesAcrossMonitors * Renamed a function * Fixed a bug with the magnetic effect * Fix restoring window positions on layout changes
This commit is contained in:
@@ -19,12 +19,23 @@ winrt::com_ptr<IZoneWindow> MonitorWorkAreaHandler::GetWorkArea(const GUID& desk
|
||||
|
||||
winrt::com_ptr<IZoneWindow> MonitorWorkAreaHandler::GetWorkArea(HWND window)
|
||||
{
|
||||
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
|
||||
GUID desktopId{};
|
||||
if (monitor && VirtualDesktopUtils::GetWindowDesktopId(window, &desktopId))
|
||||
if (VirtualDesktopUtils::GetWindowDesktopId(window, &desktopId))
|
||||
{
|
||||
return GetWorkArea(desktopId, monitor);
|
||||
auto allMonitorsWorkArea = GetWorkArea(desktopId, NULL);
|
||||
if (allMonitorsWorkArea)
|
||||
{
|
||||
// First, check if there's a work area spanning all monitors (signalled by the NULL monitor handle)
|
||||
return allMonitorsWorkArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, look for the work area based on the window's position
|
||||
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
|
||||
return GetWorkArea(desktopId, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user