activate zones for windows with custom titlebar

fixes https://github.com/microsoft/PowerToys/issues/209
This commit is contained in:
Enrico Giordani
2019-09-11 21:12:39 +02:00
committed by GitHub
parent 1430332b98
commit 8221f5e641

View File

@@ -594,19 +594,17 @@ void FancyZones::OnSnapHotkey(DWORD vkCode) noexcept
void FancyZones::MoveSizeStartInternal(HWND window, HMONITOR monitor, POINT const& ptScreen, require_write_lock writeLock) noexcept void FancyZones::MoveSizeStartInternal(HWND window, HMONITOR monitor, POINT const& ptScreen, require_write_lock writeLock) noexcept
{ {
// Only enter move/size if the cursor is in the titlebar. // Only enter move/size if the cursor is inside the window rect by a certain padding.
// This prevents resize from triggering zones. // This prevents resize from triggering zones.
RECT windowRect{}; RECT windowRect{};
::GetWindowRect(window, &windowRect); ::GetWindowRect(window, &windowRect);
TITLEBARINFO titlebarInfo{ sizeof(titlebarInfo) }; windowRect.top += 6;
::GetTitleBarInfo(window, &titlebarInfo); windowRect.left += 8;
windowRect.right -= 8;
windowRect.bottom -= 6;
// Titlebar height is weird and apps can do custom drag areas. if (PtInRect(&windowRect, ptScreen))
// Give it half of the height of the window to make sure.
titlebarInfo.rcTitleBar.bottom += ((windowRect.bottom - windowRect.top) / 2);
if (PtInRect(&titlebarInfo.rcTitleBar, ptScreen))
{ {
m_inMoveSize = true; m_inMoveSize = true;