mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[FancyZones] Snap out of maximized window into zones with win + left/right arrow (#3097)
* Snap out of maximized window into zones with win + left/right arrow. * Determine if there is anything to process before swallowing keypress.
This commit is contained in:
parent
c923e96f3e
commit
7870a66790
@ -226,6 +226,7 @@ private:
|
|||||||
bool IsNewWorkArea(GUID virtualDesktopId, HMONITOR monitor) noexcept;
|
bool IsNewWorkArea(GUID virtualDesktopId, HMONITOR monitor) noexcept;
|
||||||
|
|
||||||
void OnEditorExitEvent() noexcept;
|
void OnEditorExitEvent() noexcept;
|
||||||
|
bool ProcessSnapHotkey() noexcept;
|
||||||
|
|
||||||
std::vector<std::pair<HMONITOR, RECT>> GetRawMonitorData() noexcept;
|
std::vector<std::pair<HMONITOR, RECT>> GetRawMonitorData() noexcept;
|
||||||
std::vector<HMONITOR> GetMonitorsSorted() noexcept;
|
std::vector<HMONITOR> GetMonitorsSorted() noexcept;
|
||||||
@ -397,7 +398,7 @@ FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
|
|||||||
}
|
}
|
||||||
else if ((info->vkCode == VK_RIGHT) || (info->vkCode == VK_LEFT))
|
else if ((info->vkCode == VK_RIGHT) || (info->vkCode == VK_LEFT))
|
||||||
{
|
{
|
||||||
if (m_settings->GetSettings()->overrideSnapHotkeys)
|
if (ProcessSnapHotkey())
|
||||||
{
|
{
|
||||||
Trace::FancyZones::OnKeyDown(info->vkCode, win, ctrl, false /*inMoveSize*/);
|
Trace::FancyZones::OnKeyDown(info->vkCode, win, ctrl, false /*inMoveSize*/);
|
||||||
// Win+Left, Win+Right will cycle through Zones in the active ZoneSet when WM_PRIV_LOWLEVELKB's handled
|
// Win+Left, Win+Right will cycle through Zones in the active ZoneSet when WM_PRIV_LOWLEVELKB's handled
|
||||||
@ -948,6 +949,24 @@ void FancyZones::OnEditorExitEvent() noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FancyZones::ProcessSnapHotkey() noexcept
|
||||||
|
{
|
||||||
|
if (m_settings->GetSettings()->overrideSnapHotkeys)
|
||||||
|
{
|
||||||
|
const HMONITOR monitor = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONULL);
|
||||||
|
if (monitor)
|
||||||
|
{
|
||||||
|
auto zoneWindow = m_zoneWindowMap.find(monitor);
|
||||||
|
if (zoneWindow != m_zoneWindowMap.end() &&
|
||||||
|
zoneWindow->second->ActiveZoneSet())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HMONITOR> FancyZones::GetMonitorsSorted() noexcept
|
std::vector<HMONITOR> FancyZones::GetMonitorsSorted() noexcept
|
||||||
{
|
{
|
||||||
std::shared_lock readLock(m_lock);
|
std::shared_lock readLock(m_lock);
|
||||||
|
@ -128,6 +128,13 @@ void SizeWindowToRect(HWND window, RECT rect) noexcept
|
|||||||
placement.showCmd = SW_RESTORE | SW_SHOWNA;
|
placement.showCmd = SW_RESTORE | SW_SHOWNA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove maximized show command to make sure window is moved to the correct zone.
|
||||||
|
if (placement.showCmd & SW_SHOWMAXIMIZED)
|
||||||
|
{
|
||||||
|
placement.showCmd = SW_RESTORE;
|
||||||
|
placement.flags &= ~WPF_RESTORETOMAXIMIZED;
|
||||||
|
}
|
||||||
|
|
||||||
placement.rcNormalPosition = rect;
|
placement.rcNormalPosition = rect;
|
||||||
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user