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.
This commit is contained in:
Alexander Kuznetsov 2013-05-25 21:59:34 +00:00
parent b7c36b9511
commit b9817cd207
8 changed files with 40 additions and 309 deletions

@ -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)

@ -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 = [

@ -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 <windowsx.h>
#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<minsize[0])
RectCopyH(&newrect,&goodrect);
if(newrect.bottom<minsize[1])
RectCopyV(&newrect,&goodrect);
SetWindowPos(hwnd,0,newrect.left, newrect.top,
newrect.right, newrect.bottom,
0);
RectCopy(&goodrect, &newrect);
}
}
void GHOST_SizerWin32::cancel(void)
{
accept();
SetWindowPos(hwnd,0,initrect.left, initrect.top,
initrect.right, initrect.bottom, 0);
}
void GHOST_SizerWin32::accept(void)
{
hortransf=vertransf=0;
}
#endif /* __GHOST_SIZERWIN32_CPP__*/

@ -1,63 +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.h
* \ingroup GHOST
*/
#ifndef __GHOST_SIZERWIN32_H__
#define __GHOST_SIZERWIN32_H__
#define _WIN32_WINNT 0x501 // require Windows XP or newer
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
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__*/

@ -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,9 +1022,6 @@ 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);
break;
case WM_MBUTTONUP:
@ -1052,9 +1042,6 @@ 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);
break;
case WM_MOUSEWHEEL:
@ -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,7 +1162,9 @@ 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();
@ -1171,7 +1180,9 @@ 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_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();
}
}

@ -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);

@ -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);

@ -901,8 +901,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
#if defined(__APPLE__)
/* OSX doesn't return to the mainloop while resize */
#if defined(__APPLE__) || defined(WIN32)
/* OSX and Win32 don't return to the mainloop while resize */
wm_event_do_handlers(C);
wm_event_do_notifiers(C);
wm_draw_update(C);