X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_main.c;h=5f9b0a5d21b3f61acb789f94d5aa45dcc6bdafa3;hb=e6b149a66a5d6f7539855ca7922791cd22348f43;hp=c3e67bdc28f703b3470094e630be204b7d58d18b;hpb=b8b35ac5a8b91f64b23ebed6c58a63e042f9870f;p=freeglut diff --git a/src/freeglut_main.c b/src/freeglut_main.c index c3e67bd..5f9b0a5 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -71,8 +71,8 @@ struct GXKeyList gxKeyList; #endif #ifdef WM_TOUCH - typedef BOOL (*pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int); - typedef BOOL (*pCloseTouchInputHandle)(HTOUCHINPUT); + typedef BOOL (WINAPI *pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int); + typedef BOOL (WINAPI *pCloseTouchInputHandle)(HTOUCHINPUT); static pGetTouchInputInfo fghGetTouchInputInfo = (pGetTouchInputInfo)0xDEADBEEF; static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF; #endif @@ -101,7 +101,6 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height ) freeglut_return_if_fail( window != NULL ); - #if TARGET_HOST_POSIX_X11 XResizeWindow( fgDisplay.Display, window->Window.Handle, @@ -110,8 +109,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height ) #elif TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) { - RECT winRect; - int x, y, w, h; + RECT windowRect; /* * For windowed mode, get the current position of the @@ -120,51 +118,43 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height ) */ /* "GetWindowRect" returns the pixel coordinates of the outside of the window */ - GetWindowRect( window->Window.Handle, &winRect ); - x = winRect.left; - y = winRect.top; - w = width; - h = height; + GetWindowRect( window->Window.Handle, &windowRect ); - if ( window->Parent == NULL ) - { - if ( ! window->IsMenu && (window != fgStructure.GameModeWindow) && - !( fgState.DisplayMode & GLUT_BORDERLESS )) - { - w += GetSystemMetrics( SM_CXSIZEFRAME ) * 2; - h += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + - GetSystemMetrics( SM_CYCAPTION ); - } - } + /* Create rect in FreeGLUT format, (X,Y) topleft outside window, WxH of client area */ + windowRect.right = windowRect.left+width; + windowRect.bottom = windowRect.top+height; + + if (window->Parent == NULL) + /* get the window rect from this to feed to SetWindowPos, correct for window decorations */ + fghComputeWindowRectFromClientArea_QueryWindow(window,&windowRect,TRUE); else { + /* correct rect for position client area of parent window + * (SetWindowPos input for child windows is in coordinates + * relative to the parent's client area). + * Child windows don't have decoration, so no need to correct + * for them. + */ RECT parentRect; - GetWindowRect( window->Parent->Window.Handle, &parentRect ); - x -= parentRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) * 2; - y -= parentRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + - GetSystemMetrics( SM_CYCAPTION ); + parentRect = fghGetClientArea( window->Parent, FALSE ); + windowRect.left -= parentRect.left; + windowRect.right -= parentRect.left; + windowRect.top -= parentRect.top; + windowRect.bottom -= parentRect.top; } - - /* - * SWP_NOACTIVATE Do not activate the window - * SWP_NOOWNERZORDER Do not change position in z-order - * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message - * SWP_NOZORDER Retains the current Z order (ignore 2nd param) - */ - + + /* Do the actual resizing */ SetWindowPos( window->Window.Handle, HWND_TOP, - x, y, w, h, + windowRect.left, windowRect.top, + windowRect.right - windowRect.left, + windowRect.bottom- windowRect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER ); } #endif - /* - * XXX Should update {window->State.OldWidth, window->State.OldHeight} - * XXX to keep in lockstep with POSIX_X11 code. - */ if( FETCH_WCB( *window, Reshape ) ) INVOKE_WCB( *window, Reshape, ( width, height ) ); else @@ -233,6 +223,7 @@ static void fghcbDisplayWindow( SFG_Window *window, #if TARGET_HOST_POSIX_X11 fghRedrawWindow ( window ) ; #elif TARGET_HOST_MS_WINDOWS + RedrawWindow( window->Window.Handle, NULL, NULL, RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW @@ -1743,7 +1734,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, switch( uMsg ) { case WM_CREATE: - /* The window structure is passed as the creation structure paramter... */ + /* The window structure is passed as the creation structure parameter... */ window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams); FREEGLUT_INTERNAL_ERROR_EXIT ( ( window != NULL ), "Cannot create window", "fgWindowProc" ); @@ -1797,6 +1788,10 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, } window->State.NeedToResize = GL_TRUE; + /* if we used CW_USEDEFAULT (thats a negative value) for the size + * of the window, query the window now for the size at which it + * was created. + */ if( ( window->State.Width < 0 ) || ( window->State.Height < 0 ) ) { SFG_Window *current_window = fgStructure.CurrentWindow;