From 5ed7c49ff3323c2000f4f39135cc3ce6a434a13a Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 16 Feb 2023 17:09:11 -0800 Subject: [PATCH] Fix 104816: Ensure Win32 visible title bar When creating Win32 windows, ensure that the caption bar is visible. --- intern/ghost/intern/GHOST_WindowWin32.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index b8e1b16ef4e..ccd2980d77e 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -310,6 +310,9 @@ void GHOST_WindowWin32::adjustWindowRectForDesktop(LPRECT win_rect, DWORD dwStyl monitor.cbSize = sizeof(MONITORINFOEX); monitor.dwFlags = 0; + /* We'll need this value before it is altered for checking later. */ + LONG requested_top = win_rect->top; + /* Note that with MonitorFromPoint using MONITOR_DEFAULTTONEAREST, it will return * the exact monitor if there is one at the location or the nearest monitor if not. */ @@ -355,6 +358,9 @@ void GHOST_WindowWin32::adjustWindowRectForDesktop(LPRECT win_rect, DWORD dwStyl /* Adjust to allow for caption, borders, shadows, scaling, etc. Resulting values can be * correctly outside of monitor bounds. NOTE: You cannot specify #WS_OVERLAPPED when calling. */ if (fpAdjustWindowRectExForDpi) { + /* Use the DPI of the monitor that is at the middle of the rect. */ + hmonitor = MonitorFromRect(win_rect, MONITOR_DEFAULTTONEAREST); + GetMonitorInfo(hmonitor, &monitor); UINT dpiX, dpiY; GetDpiForMonitor(hmonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY); fpAdjustWindowRectExForDpi(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle, dpiX); @@ -362,6 +368,14 @@ void GHOST_WindowWin32::adjustWindowRectForDesktop(LPRECT win_rect, DWORD dwStyl else { AdjustWindowRectEx(win_rect, dwStyle & ~WS_OVERLAPPED, FALSE, dwExStyle); } + + /* Don't hide the title bar. Check the working area of the monitor at the top-left corner, using + * the original top since the justWindowRects might have altered it to different monitor. */ + pt.x = win_rect->left; + pt.y = requested_top; + hmonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + GetMonitorInfo(hmonitor, &monitor); + win_rect->top = max(monitor.rcWork.top, win_rect->top); } bool GHOST_WindowWin32::getValid() const -- 2.30.2