From 30d44548e3dd43f88d40cda477ecaa5e277bfd00 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 11 Jul 2023 21:13:50 +0200 Subject: [PATCH] Fix #109886: Win32 AutoFocus Between Main Windows Allow auto-focusing between multiple parent (main) windows when they are immediately adjacent. Pull Request: https://projects.blender.org/blender/blender/pulls/109946 --- intern/ghost/intern/GHOST_SystemWin32.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 7ea8d55ad67..a14fdc0a8c2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -1890,8 +1890,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, else if (!new_parent && !old_parent) { /* Between main windows that don't overlap. */ RECT new_rect, old_rect, dest_rect; - ::GetWindowRect(hwnd, &new_rect); - ::GetWindowRect(old_hwnd, &old_rect); + + /* The rects without the outside shadows and slightly inset. */ + DwmGetWindowAttribute(hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &new_rect, sizeof(RECT)); + ::InflateRect(&new_rect, -1, -1); + DwmGetWindowAttribute( + old_hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &old_rect, sizeof(RECT)); + ::InflateRect(&old_rect, -1, -1); + if (!IntersectRect(&dest_rect, &new_rect, &old_rect)) { ::SetFocus(hwnd); }