[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20721] branches/blender2.5/blender/intern /ghost/intern/GHOST_WindowWin32.cpp: Win GUI fix: Blender won' t hide behind the taskbar anymore on startup (in non maximized mode).

Daniel Genrich daniel.genrich at gmx.net
Mon Jun 8 01:36:34 CEST 2009


Revision: 20721
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20721
Author:   genscher
Date:     2009-06-08 01:36:34 +0200 (Mon, 08 Jun 2009)

Log Message:
-----------
Win GUI fix: Blender won't hide behind the taskbar anymore on startup (in non maximized mode). Until now, the bottom of Blender always got hidden behind the taskbar - verified to fix at least Win7 + XP

- Windows devs (elubie, jesterKing): please check this fix.

Modified Paths:
--------------
    branches/blender2.5/blender/intern/ghost/intern/GHOST_WindowWin32.cpp

Modified: branches/blender2.5/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- branches/blender2.5/blender/intern/ghost/intern/GHOST_WindowWin32.cpp	2009-06-07 21:02:54 UTC (rev 20720)
+++ branches/blender2.5/blender/intern/ghost/intern/GHOST_WindowWin32.cpp	2009-06-07 23:36:34 UTC (rev 20721)
@@ -117,16 +117,18 @@
 	m_maxPressure(0)
 {
 	if (state != GHOST_kWindowStateFullScreen) {
-			/* Convert client size into window size */
-		width += GetSystemMetrics(SM_CXSIZEFRAME)*2;
-		height += GetSystemMetrics(SM_CYSIZEFRAME)*2 + GetSystemMetrics(SM_CYCAPTION);
+		// take taskbar into account
+		RECT rect;
+		SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);
+		height = rect.bottom - rect.top;
+		width = rect.right - rect.left;
 
 		m_hWnd = ::CreateWindow(
 			s_windowClassName,			// pointer to registered class name
 			title,						// pointer to window name
 			WS_OVERLAPPEDWINDOW,		// window style
-			left,						// horizontal position of window
- 			top,						// vertical position of window
+			rect.left,						// horizontal position of window
+ 			rect.top,						// vertical position of window
 			width,						// window width
 			height,						// window height
 			0,							// handle to parent or owner window
@@ -239,7 +241,7 @@
 	if (m_wintab) {
 		GHOST_WIN32_WTClose fpWTClose = ( GHOST_WIN32_WTClose ) ::GetProcAddress( m_wintab, "WTClose" );
 		if (fpWTClose) {
-			if (m_tablet) 
+			if (m_tablet)
 				fpWTClose(m_tablet);
 			if (m_tabletData)
 				delete m_tabletData;
@@ -297,15 +299,17 @@
 void GHOST_WindowWin32::getClientBounds(GHOST_Rect& bounds) const
 {
 	RECT rect;
-	::GetWindowRect(m_hWnd, &rect);
 
 	LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE);
 	if((result & (WS_POPUP | WS_MAXIMIZE)) != (WS_POPUP | WS_MAXIMIZE)) {
+		SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);
+
 		bounds.m_b = rect.bottom-GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYSIZEFRAME)*2;
 		bounds.m_l = rect.left;
 		bounds.m_r = rect.right-GetSystemMetrics(SM_CYSIZEFRAME)*2;
 		bounds.m_t = rect.top;
 	} else {
+		::GetWindowRect(m_hWnd, &rect);
 		bounds.m_b = rect.bottom;
 		bounds.m_l = rect.left;
 		bounds.m_r = rect.right;
@@ -415,12 +419,12 @@
 	wp.length = sizeof(WINDOWPLACEMENT);
 	::GetWindowPlacement(m_hWnd, &wp);
 	switch (state) {
-	case GHOST_kWindowStateMinimized: 
-		wp.showCmd = SW_SHOWMINIMIZED; 
+	case GHOST_kWindowStateMinimized:
+		wp.showCmd = SW_SHOWMINIMIZED;
 		break;
-	case GHOST_kWindowStateMaximized: 
+	case GHOST_kWindowStateMaximized:
 		ShowWindow(m_hWnd, SW_HIDE);
-		wp.showCmd = SW_SHOWMAXIMIZED; 
+		wp.showCmd = SW_SHOWMAXIMIZED;
 		SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
 		break;
 	case GHOST_kWindowStateFullScreen:
@@ -429,10 +433,10 @@
 		wp.ptMaxPosition.y = 0;
 		SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_POPUP | WS_MAXIMIZE);
 		break;
-	case GHOST_kWindowStateNormal: 
-	default: 
+	case GHOST_kWindowStateNormal:
+	default:
 		ShowWindow(m_hWnd, SW_HIDE);
-		wp.showCmd = SW_SHOWNORMAL; 
+		wp.showCmd = SW_SHOWNORMAL;
 		SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
 		break;
 	}
@@ -490,7 +494,7 @@
 	switch (type) {
 	case GHOST_kDrawingContextTypeOpenGL:
 		{
-		if(m_stereoVisual) 
+		if(m_stereoVisual)
 			sPreferredFormat.dwFlags |= PFD_STEREO;
 
 		// Attempt to match device context pixel format to the preferred format
@@ -627,7 +631,7 @@
 			default:
 			success = false;
 		}
-		
+
 		if (success) {
 			::SetCursor(::LoadCursor(0, id));
 		}
@@ -660,7 +664,7 @@
 {
 	if (m_wintab) {
 		GHOST_WIN32_WTInfo fpWTInfo = ( GHOST_WIN32_WTInfo ) ::GetProcAddress( m_wintab, "WTInfoA" );
-		
+
 		// let's see if we can initialize tablet here
 		/* check if WinTab available. */
 		if (fpWTInfo) {
@@ -671,7 +675,7 @@
 				m_maxPressure = Pressure.axMax;
 			else
 				m_maxPressure = 0;
-			
+
 			BOOL tiltSupport = fpWTInfo (WTI_DEVICES, DVC_ORIENTATION, &Orientation);
 			if (tiltSupport) {
 				/* does the tablet support azimuth ([0]) and altitude ([1]) */
@@ -737,7 +741,7 @@
 						WACOM uses negative altitude values to show that the pen is inverted;
 						therefore we cast .orAltitude as an (int) and then use the absolute value.
 						*/
-						
+
 						/* convert raw fixed point data to radians */
 						altRad = (float)((fabs((float)ort.orAltitude)/(float)m_maxAltitude) * M_PI/2.0);
 						azmRad = (float)(((float)ort.orAzimuth/(float)m_maxAzimuth) * M_PI*2.0);
@@ -777,25 +781,25 @@
 	shrt= ((shrt>>8)&0x00FF) | ((shrt<<8)&0xFF00);
 	return shrt;
 }
-GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], 
+GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
 					GHOST_TUns8 mask[16][2], int hotX, int hotY)
 {
-	return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask, 
+	return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask,
 									16, 16, hotX, hotY, 0, 1);
 }
 
-GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, 
-					GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY, 
+GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
+					GHOST_TUns8 *mask, int sizeX, int sizeY, int hotX, int hotY,
 					int fg_color, int bg_color)
 {
 	GHOST_TUns32 andData[32];
 	GHOST_TUns32 xorData[32];
 	GHOST_TUns32 fullBitRow, fullMaskRow;
 	int x, y, cols;
-	
+
 	cols=sizeX/8; /* Num of whole bytes per row (width of bm/mask) */
 	if (sizeX%8) cols++;
-	
+
 	if (m_customCursor) {
 		DestroyCursor(m_customCursor);
 		m_customCursor = NULL;
@@ -835,9 +839,9 @@
 
 static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) {
 	int weight = 0;
-	
+
 	/* assume desktop color depth is 32 bits per pixel */
-	
+
 	/* cull unusable pixel formats */
 	/* if no formats can be found, can we determine why it was rejected? */
 	if( !(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
@@ -846,45 +850,45 @@
 		( pfd.cDepthBits <= 8 ) ||
 		!(pfd.iPixelType == PFD_TYPE_RGBA) )
 		return 0;
-	
+
 	weight = 1;  /* it's usable */
-	
+
 	/* the bigger the depth buffer the better */
 	/* give no weight to a 16-bit depth buffer, because those are crap */
 	weight += pfd.cDepthBits - 16;
-	
+
 	weight += pfd.cColorBits - 8;
-	
+
 	/* want swap copy capability -- it matters a lot */
 	if(pfd.dwFlags & PFD_SWAP_COPY)	weight += 16;
-	
+
 	/* but if it's a generic (not accelerated) view, it's really bad */
 	if(pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10;
-	
+
 	return weight;
 }
 
-/* A modification of Ron Fosner's replacement for ChoosePixelFormat */ 
+/* A modification of Ron Fosner's replacement for ChoosePixelFormat */
 /* returns 0 on error, else returns the pixel format number to be used */
 static int EnumPixelFormats(HDC hdc) {
 	int iPixelFormat;
 	int i, n, w, weight = 0;
 	PIXELFORMATDESCRIPTOR pfd;
-	
+
 	/* we need a device context to do anything */
 	if(!hdc) return 0;
 
 	iPixelFormat = 1; /* careful! PFD numbers are 1 based, not zero based */
-	
-	/* obtain detailed information about 
+
+	/* obtain detailed information about
 	the device context's first pixel format */
-	n = 1+::DescribePixelFormat(hdc, iPixelFormat, 
+	n = 1+::DescribePixelFormat(hdc, iPixelFormat,
 		sizeof(PIXELFORMATDESCRIPTOR), &pfd);
-	
+
 	/* choose a pixel format using the useless Windows function in case
 		we come up empty handed */
 	iPixelFormat = ::ChoosePixelFormat( hdc, &sPreferredFormat );
-	
+
 	if(!iPixelFormat) return 0; /* couldn't find one to use */
 
 	for(i=1; i<=n; i++) { /* not the idiom, but it's right */
@@ -899,7 +903,7 @@
 		}
 	}
 	if (weight == 0) {
-		// we could find the correct stereo setting, just find any suitable format 
+		// we could find the correct stereo setting, just find any suitable format
 		for(i=1; i<=n; i++) { /* not the idiom, but it's right */
 			::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
 			w = WeightPixelFormat(pfd);





More information about the Bf-blender-cvs mailing list