Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratik Borhade <PratikPB2123>2021-05-24 21:42:30 +0300
committerHarley Acheson <harley.acheson@gmail.com>2021-05-24 21:46:35 +0300
commit0606a37e1a8c1e9c1abe94c19848382278ed966e (patch)
tree16247d49a4978461687c5e3b70b1c96c7d61d315 /intern/ghost/intern/GHOST_WindowWin32.cpp
parent9c53690b301618452ccc61eb524e343af554c9c0 (diff)
Fix T88500: Constrain window top position (Win32)
Do not allow a window to be created that has a top position that can obscure all or part of title bar. Right and Left edges can still be specified slightly outside of monitor bounds, but top edge must be clamped to monitor top. see D11371 for more details. https://developer.blender.org/D11371 Reviewed by Ray Molenkamp
Diffstat (limited to 'intern/ghost/intern/GHOST_WindowWin32.cpp')
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index bf142239606..3af92153e8b 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -121,19 +121,21 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
monitor.dwFlags = 0;
GetMonitorInfo(MonitorFromRect(&win_rect, MONITOR_DEFAULTTONEAREST), &monitor);
- /* Constrain size to fit within this monitor. */
+ /* Constrain requested size and position to fit within this monitor. */
width = min(monitor.rcWork.right - monitor.rcWork.left, win_rect.right - win_rect.left);
height = min(monitor.rcWork.bottom - monitor.rcWork.top, win_rect.bottom - win_rect.top);
-
win_rect.left = min(max(monitor.rcWork.left, win_rect.left), monitor.rcWork.right - width);
win_rect.right = win_rect.left + width;
win_rect.top = min(max(monitor.rcWork.top, win_rect.top), monitor.rcWork.bottom - height);
win_rect.bottom = win_rect.top + height;
- /* Adjust our requested values to allow for caption, borders, shadows, etc.
- Windows API Note: You cannot specify WS_OVERLAPPED when calling. */
+ /* 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. */
AdjustWindowRectEx(&win_rect, style & ~WS_OVERLAPPED, FALSE, extended_style);
+ /* But never allow a top position that can hide part of the title bar. */
+ win_rect.top = max(monitor.rcWork.top, win_rect.top);
+
m_hWnd = ::CreateWindowExW(extended_style, // window extended style
s_windowClassName, // pointer to registered class name
title_16, // pointer to window name