diff options
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 89 |
1 files changed, 45 insertions, 44 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 78a2dbc4d7c..c0a42c1b7d4 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -80,6 +80,31 @@ stw_framebuffer_destroy_locked( } +static INLINE void +stw_framebuffer_get_size( struct stw_framebuffer *fb ) +{ + unsigned width, height; + RECT rect; + + assert(fb->hWnd); + + GetClientRect( fb->hWnd, &rect ); + width = rect.right - rect.left; + height = rect.bottom - rect.top; + + if(width < 1) + width = 1; + if(height < 1) + height = 1; + + if(width != fb->width || height != fb->height) { + fb->must_resize = TRUE; + fb->width = width; + fb->height = height; + } +} + + /** * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx @@ -92,6 +117,7 @@ stw_call_window_proc( { struct stw_tls_data *tls_data; PCWPSTRUCT pParams = (PCWPSTRUCT)lParam; + struct stw_framebuffer *fb; tls_data = stw_tls_get_data(); if(!tls_data) @@ -100,28 +126,28 @@ stw_call_window_proc( if (nCode < 0) return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam); - if (pParams->message == WM_SIZE && pParams->wParam != SIZE_MINIMIZED) { - struct stw_framebuffer *fb; - - pipe_mutex_lock( stw_dev->mutex ); - fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd ); - pipe_mutex_unlock( stw_dev->mutex ); - - if(fb) { - unsigned width = LOWORD( pParams->lParam ); - unsigned height = HIWORD( pParams->lParam ); + if (pParams->message == WM_WINDOWPOSCHANGED) { + /* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to + * http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx + * WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it + * can be masked out by the application. */ + LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam; + if((lpWindowPos->flags & SWP_SHOWWINDOW) || + !(lpWindowPos->flags & SWP_NOSIZE)) { + pipe_mutex_lock( stw_dev->mutex ); + fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd ); + pipe_mutex_unlock( stw_dev->mutex ); - pipe_mutex_lock( fb->mutex ); - fb->must_resize = TRUE; - fb->width = width; - fb->height = height; - pipe_mutex_unlock( fb->mutex ); + if(fb) { + pipe_mutex_lock( fb->mutex ); + /* Size in WINDOWPOS includes the window frame, so get the size + * of the client area via GetClientRect. */ + stw_framebuffer_get_size(fb); + pipe_mutex_unlock( fb->mutex ); + } } } - - if (pParams->message == WM_DESTROY) { - struct stw_framebuffer *fb; - + else if (pParams->message == WM_DESTROY) { pipe_mutex_lock( stw_dev->mutex ); fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd ); @@ -135,31 +161,6 @@ stw_call_window_proc( } -static void -stw_framebuffer_get_size( struct stw_framebuffer *fb ) -{ - unsigned width, height; - RECT rect; - - assert(fb->hWnd); - - GetClientRect( fb->hWnd, &rect ); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - - if(width < 1) - width = 1; - if(height < 1) - height = 1; - - if(width != fb->width || height != fb->height) { - fb->must_resize = TRUE; - fb->width = width; - fb->height = height; - } -} - - /** * Create a new framebuffer object which will correspond to the given HDC. */ |