From b9817cd20767fa3ba61f80ef725fb42d6f3dd48f Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Sat, 25 May 2013 21:59:34 +0000 Subject: Live resize on Windows. Based on Ton's patch for mac. Removing old resize stuff. Windows has resize lag, which creates black gap with openGL. Still looking to fix it. --- intern/ghost/CMakeLists.txt | 2 - intern/ghost/SConscript | 2 +- intern/ghost/intern/GHOST_SizerWin32.cpp | 202 ------------------------------ intern/ghost/intern/GHOST_SizerWin32.h | 63 ---------- intern/ghost/intern/GHOST_SystemWin32.cpp | 66 +++++----- intern/ghost/intern/GHOST_WindowWin32.cpp | 6 +- intern/ghost/intern/GHOST_WindowWin32.h | 4 +- 7 files changed, 38 insertions(+), 307 deletions(-) delete mode 100644 intern/ghost/intern/GHOST_SizerWin32.cpp delete mode 100644 intern/ghost/intern/GHOST_SizerWin32.h (limited to 'intern') diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 5bad9922d15..12dd4c0d3eb 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -296,7 +296,6 @@ elseif(WIN32) intern/GHOST_SystemPathsWin32.cpp intern/GHOST_WindowWin32.cpp intern/GHOST_DropTargetWin32.cpp - intern/GHOST_SizerWin32.cpp intern/GHOST_DisplayManagerWin32.h intern/GHOST_DropTargetWin32.h @@ -304,7 +303,6 @@ elseif(WIN32) intern/GHOST_SystemPathsWin32.h intern/GHOST_WindowWin32.h intern/GHOST_TaskbarWin32.h - intern/GHOST_SizerWin32.h ) if(WITH_INPUT_NDOF) diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 30c58b06421..0d7df2847e0 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -37,7 +37,7 @@ if window_system == 'darwin': sources += env.Glob('intern/*.mm') -pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget', 'GHOST_NDOFManager', 'GHOST_Sizer'] +pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget', 'GHOST_NDOFManager'] defs=['_USE_MATH_DEFINES'] incs = [ diff --git a/intern/ghost/intern/GHOST_SizerWin32.cpp b/intern/ghost/intern/GHOST_SizerWin32.cpp deleted file mode 100644 index a66840f8bd5..00000000000 --- a/intern/ghost/intern/GHOST_SizerWin32.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2013 Blender Foundation. - * All rights reserved. - * - * Contributor(s): Alexandr Kuznetsov - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_SizerWin32.cpp - * \ingroup GHOST - */ - -#ifndef __GHOST_SIZERWIN32_CPP__ -#define __GHOST_SIZERWIN32_CPP__ - - -#include "GHOST_SizerWin32.h" -#include - -#define T_NONE (0) -#define T_SIZE (1) -#define T_MOVE (2) -#define T_MOVESIZE (3) - - -static void RectCopyH(RECT * t, RECT * f) -{ - t->left = f->left; - t->right = f->right; -} - -static void RectCopyV(RECT * t, RECT * f) -{ - t->top = f->top; - t->bottom = f->bottom; -} - -static void RectCopy(RECT * t, RECT * f) -{ - RectCopyH(t,f); - RectCopyV(t,f); -} - - -GHOST_SizerWin32::GHOST_SizerWin32(void) -{ - hortransf = vertransf = 0; - minsize[0] = minsize[1] = 0; - hwnd = 0; -} - -GHOST_SizerWin32::~GHOST_SizerWin32(void) -{ - if(isWinChanges()) - cancel(); -} - -void GHOST_SizerWin32::setMinSize(int minx, int miny) -{ - minsize[0] = minx; - minsize[1] = miny; - - -} - -bool GHOST_SizerWin32::isWinChanges(void) -{ - return hortransf||vertransf; -} - - -void GHOST_SizerWin32::startSizing(unsigned short type) -{ - //SetCapture(hwnd); - POINT coord; - - switch(type & 0xf) - { - - case WMSZ_LEFT: hortransf = T_MOVESIZE; - vertransf = T_NONE; break; - case WMSZ_RIGHT: hortransf = T_SIZE; - vertransf = T_NONE; break; - case WMSZ_TOP: hortransf = T_NONE; - vertransf = T_MOVESIZE; break; - case WMSZ_TOPLEFT: hortransf = T_MOVESIZE; - vertransf = T_MOVESIZE; break; - case WMSZ_TOPRIGHT: hortransf = T_SIZE; - vertransf = T_MOVESIZE; break; - case WMSZ_BOTTOM: hortransf = T_NONE; - vertransf = T_SIZE; break; - case WMSZ_BOTTOMLEFT: hortransf = T_MOVESIZE; - vertransf = T_SIZE; break; - case WMSZ_BOTTOMRIGHT: hortransf = T_SIZE; - vertransf = T_SIZE; break; - - } - - - - POINT mp; - GetCursorPos(&mp); - startpos[0]=mp.x; - startpos[1]=mp.y; - - GetWindowRect(hwnd, &initrect); - initrect.bottom-=initrect.top; - initrect.right-=initrect.left; - RectCopy(&goodrect,&initrect); - -} - -void GHOST_SizerWin32::setHWND(HWND hWnd) -{ - this->hwnd = hWnd; -} - - -void GHOST_SizerWin32::updateWindowSize(void) -{ - if(!isWinChanges()) - return; - if(hortransf||vertransf){ - POINT mp; - GetCursorPos(&mp); - int hordelta = mp.x-startpos[0]; - int verdelta = mp.y-startpos[1]; - - RECT newrect; - RectCopy(&newrect, &initrect); - - switch(hortransf) - { - case T_SIZE: - newrect.right+=hordelta; - break; - case T_MOVESIZE: - newrect.right-=hordelta; - case T_MOVE: - newrect.left+=hordelta; - break; - } - - switch(vertransf) - { - case T_SIZE: - newrect.bottom+=verdelta; - break; - case T_MOVESIZE: - newrect.bottom-=verdelta; - case T_MOVE: - newrect.top+=verdelta; - break; - } - - - if(newrect.right -class GHOST_SizerWin32 -{ - private: - HWND hwnd; - int startpos[2]; - int minsize[2]; - RECT initrect; - RECT goodrect; - unsigned char hortransf, vertransf; - - - public: - GHOST_SizerWin32(void); - ~GHOST_SizerWin32(void); - - bool isWinChanges(void); - void startSizing(unsigned short type); - void updateWindowSize(void); - - void setHWND(HWND hWnd); - void setMinSize(int minx, int miny); - - void cancel(void); - void accept(void); - - -}; - -#endif /*#ifndef __GHOST_SIZERWIN32_H__*/ diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 9ad89667e76..96842f0d2e9 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -984,14 +984,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, if (wParam == SC_KEYMENU) { eventHandled = true; - }// else - /* XXX Disable for now due to area resizing issue. bug# 34990 */ - /*if((wParam&0xfff0)==SC_SIZE) - { - window->registerMouseClickEvent(0); - window->m_wsh.startSizing(wParam); - eventHandled = true; - }*/ + } break; //////////////////////////////////////////////////////////////////////// // Tablet events, processed @@ -1029,10 +1022,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_LBUTTONUP: window->registerMouseClickEvent(1); - if(window->m_wsh.isWinChanges()) - window->m_wsh.accept(); - else - event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft); + event = processButtonEvent(GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft); break; case WM_MBUTTONUP: window->registerMouseClickEvent(1); @@ -1052,10 +1042,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, } break; case WM_MOUSEMOVE: - if(window->m_wsh.isWinChanges()) - window->m_wsh.updateWindowSize(); - else - event = processCursorEvent(GHOST_kEventCursorMove, window); + event = processCursorEvent(GHOST_kEventCursorMove, window); break; case WM_MOUSEWHEEL: /* The WM_MOUSEWHEEL message is sent to the focus window @@ -1129,6 +1116,19 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); break; } + case WM_ENTERSIZEMOVE: + /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving + * or sizing modal loop. The window enters the moving or sizing modal loop when the user + * clicks the window's title bar or sizing border, or when the window passes the + * WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the + * message specifies the SC_MOVE or SC_SIZE value. The operation is complete when + * DefWindowProc returns. + */ + window->m_inLiveResize = 1; + break; + case WM_EXITSIZEMOVE: + window->m_inLiveResize = 0; + break; case WM_PAINT: /* An application sends the WM_PAINT message when the system or another application * makes a request to paint a portion of an application's window. The message is sent @@ -1136,8 +1136,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * function when the application obtains a WM_PAINT message by using the GetMessage or * PeekMessage function. */ + if(!window->m_inLiveResize) + { event = processWindowEvent(GHOST_kEventWindowUpdate, window); ::ValidateRect(hwnd, NULL); + } + else { + eventHandled = true; + } break; case WM_GETMINMAXINFO: /* The WM_GETMINMAXINFO message is sent to a window when the size or @@ -1148,6 +1154,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, processMinMaxInfo((MINMAXINFO *) lParam); /* Let DefWindowProc handle it. */ break; + case WM_SIZING: case WM_SIZE: /* The WM_SIZE message is sent to a window after its size has changed. * The WM_SIZE and WM_MOVE messages are not sent if an application handles the @@ -1155,23 +1162,27 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * to perform any move or size change processing during the WM_WINDOWPOSCHANGED * message without calling DefWindowProc. */ - event = processWindowEvent(GHOST_kEventWindowSize, window); + system->pushEvent(processWindowEvent(GHOST_kEventWindowSize, window)); + system->dispatchEvents(); + eventHandled = true; break; case WM_CAPTURECHANGED: window->lostMouseCapture(); break; case WM_MOVING: - /* The WM_MOVING message is sent to a window that the user is moving. By processing - * this message, an application can monitor the size and position of the drag rectangle - * and, if needed, change its size or position. - */ + /* The WM_MOVING message is sent to a window that the user is moving. By processing + * this message, an application can monitor the size and position of the drag rectangle + * and, if needed, change its size or position. + */ case WM_MOVE: /* The WM_SIZE and WM_MOVE messages are not sent if an application handles the * WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient * to perform any move or size change processing during the WM_WINDOWPOSCHANGED * message without calling DefWindowProc. */ - event = processWindowEvent(GHOST_kEventWindowMove, window); + system->pushEvent(processWindowEvent(GHOST_kEventWindowMove, window)); + system->dispatchEvents(); + eventHandled = true; break; //////////////////////////////////////////////////////////////////////// // Window events, ignored @@ -1223,14 +1234,6 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, */ case WM_SETFOCUS: /* The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. */ - case WM_ENTERSIZEMOVE: - /* The WM_ENTERSIZEMOVE message is sent one time to a window after it enters the moving - * or sizing modal loop. The window enters the moving or sizing modal loop when the user - * clicks the window's title bar or sizing border, or when the window passes the - * WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the - * message specifies the SC_MOVE or SC_SIZE value. The operation is complete when - * DefWindowProc returns. - */ break; //////////////////////////////////////////////////////////////////////// // Other events @@ -1256,9 +1259,6 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, * In GHOST, we let DefWindowProc call the timer callback. */ break; - case WM_CANCELMODE: - if(window->m_wsh.isWinChanges()) - window->m_wsh.cancel(); } } diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 78a69eb6c4f..6d3b34b0785 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -146,7 +146,8 @@ GHOST_WindowWin32::GHOST_WindowWin32( m_normal_state(GHOST_kWindowStateNormal), m_stereo(stereoVisual), m_nextWindow(NULL), - m_parentWindowHwnd(parentwindowhwnd) + m_parentWindowHwnd(parentwindowhwnd), + m_inLiveResize(false) { OSVERSIONINFOEX versionInfo; bool hasMinVersionForTaskbar = false; @@ -264,9 +265,6 @@ GHOST_WindowWin32::GHOST_WindowWin32( // Store a pointer to this class in the window structure ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR) this); - m_wsh.setHWND(m_hWnd); - m_wsh.setMinSize(320, 240); - // Store the device context m_hDC = ::GetDC(m_hWnd); diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index d46f1b61493..2fd1f5b37f4 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -38,7 +38,6 @@ #endif // WIN32 #include "GHOST_Window.h" -#include "GHOST_SizerWin32.h" #include "GHOST_TaskbarWin32.h" #define _WIN32_WINNT 0x501 // require Windows XP or newer @@ -281,7 +280,8 @@ public: GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;} - GHOST_SizerWin32 m_wsh; + /** if the window currently resizing */ + bool m_inLiveResize; protected: GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd); -- cgit v1.2.3