diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2013-09-12 14:44:03 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2013-09-12 14:44:03 +0400 |
commit | 8309f1c0de6f8a70f85e3f980f83a5513d61d898 (patch) | |
tree | cea7cbb9708b43a25c904609a4aace1133b8f19a /intern/ghost | |
parent | c9dfe7bd74a03886d4284985418619ccf5077ac3 (diff) |
Fix for [#36707] Blender Opens in fullscreen and stays like that
Reported by holy enigma
The previous commit in this area removed bounding box checks, because
they were done against primary monitor. Now do bound checks against
the entire desktop, or rather, the virtual screen. This is the bounding
rectangle of all the monitors.
This should ensure windows are always created within the confines of this
area.
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 362a045e5c7..2b311f96647 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -176,33 +176,44 @@ GHOST_WindowWin32::GHOST_WindowWin32( } if (state != GHOST_kWindowStateFullScreen) { - RECT rect; - - int framex = GetSystemMetrics(SM_CXSIZEFRAME); - int framey = GetSystemMetrics(SM_CYSIZEFRAME); - int caption = GetSystemMetrics(SM_CYCAPTION); - width += framex * 2; - height += framey * 2 + caption; - - left -= framex; - top -= (caption+framey); - - rect.left = left; - rect.right = left + width + framex; - rect.top = top; - rect.bottom = top + height + caption - framey; - + RECT rect, desktop; int wintype = WS_OVERLAPPEDWINDOW; + if (m_parentWindowHwnd != 0) { wintype = WS_CHILD; + /* check against parent window if given */ GetWindowRect((HWND)m_parentWindowHwnd, &rect); - left = 0; - top = 0; - width = rect.right - rect.left; - height = rect.bottom - rect.top; + } else { + int framex = GetSystemMetrics(SM_CXSIZEFRAME); + int framey = GetSystemMetrics(SM_CYSIZEFRAME); + int caption = GetSystemMetrics(SM_CYCAPTION); + + /* set up total window rect, taking in account window decorations. */ + rect.left = left - framex; + rect.right = rect.left + width + framex*2; + rect.top = top - (caption + framey); + rect.bottom = rect.top + height + (caption + framey * 2); } - + + /* ask how large virtual screen is */ + desktop.left = GetSystemMetrics(SM_XVIRTUALSCREEN); + desktop.top = GetSystemMetrics(SM_YVIRTUALSCREEN); + desktop.right = GetSystemMetrics(SM_CXVIRTUALSCREEN); + desktop.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN); + + /* virtual screen (desktop) bound checks */ + if(rect.left < desktop.left) rect.left = desktop.left; + if(rect.top < desktop.top) rect.top = desktop.top; + if(rect.bottom > desktop.bottom) rect.bottom = desktop.bottom; + if(rect.right > desktop.right) rect.right = desktop.right; + + /* dimension vars to use in window creation */ + left = rect.left; + top = rect.top; + width = rect.right - rect.left; + height = rect.bottom - rect.top; + wchar_t *title_16 = alloc_utf16_from_8((char *)(const char *)title, 0); m_hWnd = ::CreateWindowW( s_windowClassName, // pointer to registered class name |