[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60067] trunk/blender/intern/ghost/intern/ GHOST_WindowWin32.cpp: Fix for [#36707] Blender Opens in fullscreen and stays like that

Nathan Letwory nathan at letworyinteractive.com
Thu Sep 12 12:44:04 CEST 2013


Revision: 60067
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60067
Author:   jesterking
Date:     2013-09-12 10:44:03 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp	2013-09-12 10:41:00 UTC (rev 60066)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp	2013-09-12 10:44:03 UTC (rev 60067)
@@ -176,33 +176,44 @@
 	}
 
 	if (state != GHOST_kWindowStateFullScreen) {
-		RECT rect;
+		RECT rect, desktop;
+		int wintype = WS_OVERLAPPEDWINDOW;
 
-		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;
-
-		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




More information about the Bf-blender-cvs mailing list