From 3abeae8f4af46f1d8ddc158f6bc9892504a38982 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 9 May 2001 17:21:04 +0000 Subject: [PATCH] Moved window move/resize syscommand handling to the graphics driver. --- dlls/ttydrv/ttydrv.h | 2 - dlls/ttydrv/wnd.c | 18 -- dlls/user/user_main.c | 1 + dlls/x11drv/winpos.c | 408 ++++++++++++++++++++++++++++ dlls/x11drv/x11drv.spec | 1 + include/nonclient.h | 1 + include/user.h | 1 + include/win.h | 2 - include/x11drv.h | 2 - windows/nonclient.c | 579 +++++----------------------------------- windows/x11drv/wnd.c | 23 -- 11 files changed, 475 insertions(+), 563 deletions(-) diff --git a/dlls/ttydrv/ttydrv.h b/dlls/ttydrv/ttydrv.h index 3f12f29522..b79506ae0a 100644 --- a/dlls/ttydrv/ttydrv.h +++ b/dlls/ttydrv/ttydrv.h @@ -134,8 +134,6 @@ extern struct tagWND_DRIVER TTYDRV_WND_Driver; extern HANDLE TTYDRV_LoadOEMResource(WORD resid, WORD type); extern void TTYDRV_WND_ForceWindowRaise(struct tagWND *pWnd); -extern void TTYDRV_WND_PreSizeMove(struct tagWND *wndPtr); -extern void TTYDRV_WND_PostSizeMove(struct tagWND *wndPtr); extern void TTYDRV_WND_ScrollWindow(struct tagWND *wndPtr, HDC hdc, INT dx, INT dy, const RECT *clipRect, BOOL bUpdate); extern BOOL TTYDRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value); diff --git a/dlls/ttydrv/wnd.c b/dlls/ttydrv/wnd.c index 743f1a9fbe..1a31cc8699 100644 --- a/dlls/ttydrv/wnd.c +++ b/dlls/ttydrv/wnd.c @@ -18,8 +18,6 @@ DEFAULT_DEBUG_CHANNEL(ttydrv); WND_DRIVER TTYDRV_WND_Driver = { TTYDRV_WND_ForceWindowRaise, - TTYDRV_WND_PreSizeMove, - TTYDRV_WND_PostSizeMove, TTYDRV_WND_ScrollWindow, TTYDRV_WND_SetHostAttr }; @@ -100,22 +98,6 @@ void TTYDRV_WND_ForceWindowRaise(WND *wndPtr) FIXME("(%p): stub\n", wndPtr); } -/***************************************************************** - * TTYDRV_WND_PreSizeMove - */ -void TTYDRV_WND_PreSizeMove(WND *wndPtr) -{ - FIXME("(%p): stub\n", wndPtr); -} - -/***************************************************************** - * TTYDRV_WND_PostSizeMove - */ -void TTYDRV_WND_PostSizeMove(WND *wndPtr) -{ - FIXME("(%p): stub\n", wndPtr); -} - /***************************************************************** * TTYDRV_WND_ScrollWindow */ diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index aa8be710a2..cb4f9e8bec 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -94,6 +94,7 @@ static BOOL load_driver(void) GET_USER_FUNC(SetWindowRgn); GET_USER_FUNC(SetWindowIcon); GET_USER_FUNC(SetWindowText); + GET_USER_FUNC(SysCommandSizeMove); return TRUE; } diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c index c209ca9701..1f110a5b2c 100644 --- a/dlls/x11drv/winpos.c +++ b/dlls/x11drv/winpos.c @@ -15,10 +15,14 @@ #include "winuser.h" #include "x11drv.h" +#include "hook.h" #include "win.h" #include "winpos.h" #include "region.h" #include "dce.h" +#include "cursoricon.h" +#include "nonclient.h" +#include "message.h" #include "debugtools.h" @@ -36,6 +40,18 @@ DEFAULT_DEBUG_CHANNEL(win); #define SWP_EX_PAINTSELF 0x0002 #define SWP_EX_NONCLIENT 0x0004 +#define HAS_THICKFRAME(style,exStyle) \ + (((style) & WS_THICKFRAME) && \ + !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME)) + +#define ON_LEFT_BORDER(hit) \ + (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT)) +#define ON_RIGHT_BORDER(hit) \ + (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT)) +#define ON_TOP_BORDER(hit) \ + (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT)) +#define ON_BOTTOM_BORDER(hit) \ + (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT)) /*********************************************************************** * DCE_OffsetVisRgn @@ -1322,3 +1338,395 @@ BOOL X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw ) WIN_ReleaseWndPtr(wndPtr); return ret; } + + +/*********************************************************************** + * draw_moving_frame + * + * Draw the frame used when moving or resizing window. + * + * FIXME: This causes problems in Win95 mode. (why?) + */ +static void draw_moving_frame( HDC hdc, RECT *rect, BOOL thickframe ) +{ + if (thickframe) + { + const int width = GetSystemMetrics(SM_CXFRAME); + const int height = GetSystemMetrics(SM_CYFRAME); + + HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) ); + PatBlt( hdc, rect->left, rect->top, + rect->right - rect->left - width, height, PATINVERT ); + PatBlt( hdc, rect->left, rect->top + height, width, + rect->bottom - rect->top - height, PATINVERT ); + PatBlt( hdc, rect->left + width, rect->bottom - 1, + rect->right - rect->left - width, -height, PATINVERT ); + PatBlt( hdc, rect->right - 1, rect->top, -width, + rect->bottom - rect->top - height, PATINVERT ); + SelectObject( hdc, hbrush ); + } + else DrawFocusRect( hdc, rect ); +} + + +/*********************************************************************** + * start_size_move + * + * Initialisation of a move or resize, when initiatied from a menu choice. + * Return hit test code for caption or sizing border. + */ +static LONG start_size_move( WND* wndPtr, WPARAM wParam, POINT *capturePoint ) +{ + LONG hittest = 0; + POINT pt; + MSG msg; + RECT rectWindow; + + GetWindowRect(wndPtr->hwndSelf,&rectWindow); + + if ((wParam & 0xfff0) == SC_MOVE) + { + /* Move pointer at the center of the caption */ + RECT rect; + NC_GetInsideRect( wndPtr->hwndSelf, &rect ); + if (wndPtr->dwStyle & WS_SYSMENU) + rect.left += GetSystemMetrics(SM_CXSIZE) + 1; + if (wndPtr->dwStyle & WS_MINIMIZEBOX) + rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + if (wndPtr->dwStyle & WS_MAXIMIZEBOX) + rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + pt.x = rectWindow.left + (rect.right - rect.left) / 2; + pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2; + hittest = HTCAPTION; + *capturePoint = pt; + } + else /* SC_SIZE */ + { + while(!hittest) + { + MSG_InternalGetMessage( &msg, 0, 0, WM_KEYFIRST, WM_MOUSELAST, + MSGF_SIZE, PM_REMOVE, FALSE, NULL ); + switch(msg.message) + { + case WM_MOUSEMOVE: + hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt ); + if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) + hittest = 0; + break; + + case WM_LBUTTONUP: + return 0; + + case WM_KEYDOWN: + switch(msg.wParam) + { + case VK_UP: + hittest = HTTOP; + pt.x =(rectWindow.left+rectWindow.right)/2; + pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2; + break; + case VK_DOWN: + hittest = HTBOTTOM; + pt.x =(rectWindow.left+rectWindow.right)/2; + pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2; + break; + case VK_LEFT: + hittest = HTLEFT; + pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2; + pt.y =(rectWindow.top+rectWindow.bottom)/2; + break; + case VK_RIGHT: + hittest = HTRIGHT; + pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2; + pt.y =(rectWindow.top+rectWindow.bottom)/2; + break; + case VK_RETURN: + case VK_ESCAPE: return 0; + } + } + } + *capturePoint = pt; + } + SetCursorPos( pt.x, pt.y ); + NC_HandleSetCursor( wndPtr->hwndSelf, + wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE )); + return hittest; +} + + +/*********************************************************************** + * X11DRV_SysCommandSizeMove (X11DRV.@) + * + * Perform SC_MOVE and SC_SIZE commands. + */ +void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) +{ + MSG msg; + RECT sizingRect, mouseRect, origRect; + HDC hdc; + LONG hittest = (LONG)(wParam & 0x0f); + HCURSOR16 hDragCursor = 0, hOldCursor = 0; + POINT minTrack, maxTrack; + POINT capturePoint, pt; + WND * wndPtr = WIN_FindWndPtr( hwnd ); + BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ); + BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE; + BOOL moved = FALSE; + DWORD dwPoint = GetMessagePos (); + BOOL DragFullWindows = FALSE; + int iWndsLocks; + + SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); + + pt.x = SLOWORD(dwPoint); + pt.y = SHIWORD(dwPoint); + capturePoint = pt; + + if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || + (wndPtr->dwExStyle & WS_EX_MANAGED)) goto END; + + if ((wParam & 0xfff0) == SC_MOVE) + { + if (!hittest) hittest = start_size_move( wndPtr, wParam, &capturePoint ); + if (!hittest) goto END; + } + else /* SC_SIZE */ + { + if (!thickframe) goto END; + if ( hittest && hittest != HTSYSMENU ) hittest += 2; + else + { + SetCapture(hwnd); + hittest = start_size_move( wndPtr, wParam, &capturePoint ); + if (!hittest) + { + ReleaseCapture(); + goto END; + } + } + } + + /* Get min/max info */ + + WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack ); + sizingRect = wndPtr->rectWindow; + origRect = sizingRect; + if (wndPtr->dwStyle & WS_CHILD) + GetClientRect( wndPtr->parent->hwndSelf, &mouseRect ); + else + SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + if (ON_LEFT_BORDER(hittest)) + { + mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); + mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x ); + } + else if (ON_RIGHT_BORDER(hittest)) + { + mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x ); + mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x ); + } + if (ON_TOP_BORDER(hittest)) + { + mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y ); + mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y); + } + else if (ON_BOTTOM_BORDER(hittest)) + { + mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); + mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); + } + if (wndPtr->dwStyle & WS_CHILD) + { + MapWindowPoints( wndPtr->parent->hwndSelf, 0, (LPPOINT)&mouseRect, 2 ); + } + SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); + + if (GetCapture() != hwnd) SetCapture( hwnd ); + + if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow())) + { + /* Retrieve a default cache DC (without using the window style) */ + hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE ); + } + else + hdc = GetDC( 0 ); + + if( iconic ) /* create a cursor for dragging */ + { + HICON hIcon = GetClassLongA( hwnd, GCL_HICON); + if(!hIcon) hIcon = (HICON)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L); + if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE ); + if( !hDragCursor ) iconic = FALSE; + } + + /* repaint the window before moving it around */ + RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN ); + + /* grab the server only when moving top-level windows without desktop */ + if ((root_window == DefaultRootWindow(display)) && + (wndPtr->parent->hwndSelf == GetDesktopWindow())) + TSXGrabServer( display ); + + while(1) + { + int dx = 0, dy = 0; + + MSG_InternalGetMessage( &msg, 0, 0, WM_KEYFIRST, WM_MOUSELAST, + MSGF_SIZE, PM_REMOVE, FALSE, NULL ); + + /* Exit on button-up, Return, or Esc */ + if ((msg.message == WM_LBUTTONUP) || + ((msg.message == WM_KEYDOWN) && + ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break; + + if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) + continue; /* We are not interested in other messages */ + + pt = msg.pt; + + if (msg.message == WM_KEYDOWN) switch(msg.wParam) + { + case VK_UP: pt.y -= 8; break; + case VK_DOWN: pt.y += 8; break; + case VK_LEFT: pt.x -= 8; break; + case VK_RIGHT: pt.x += 8; break; + } + + pt.x = max( pt.x, mouseRect.left ); + pt.x = min( pt.x, mouseRect.right ); + pt.y = max( pt.y, mouseRect.top ); + pt.y = min( pt.y, mouseRect.bottom ); + + dx = pt.x - capturePoint.x; + dy = pt.y - capturePoint.y; + + if (dx || dy) + { + if( !moved ) + { + moved = TRUE; + + if( iconic ) /* ok, no system popup tracking */ + { + hOldCursor = SetCursor(hDragCursor); + ShowCursor( TRUE ); + WINPOS_ShowIconTitle( wndPtr, FALSE ); + } + else if(!DragFullWindows) + draw_moving_frame( hdc, &sizingRect, thickframe ); + } + + if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y ); + else + { + RECT newRect = sizingRect; + WPARAM wpSizingHit = 0; + + if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy ); + if (ON_LEFT_BORDER(hittest)) newRect.left += dx; + else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx; + if (ON_TOP_BORDER(hittest)) newRect.top += dy; + else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy; + if(!iconic && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe ); + capturePoint = pt; + + /* determine the hit location */ + if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT) + wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT); + SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect ); + + if (!iconic) + { + if(!DragFullWindows) + draw_moving_frame( hdc, &newRect, thickframe ); + else { + /* To avoid any deadlocks, all the locks on the windows + structures must be suspended before the SetWindowPos */ + iWndsLocks = WIN_SuspendWndsLock(); + SetWindowPos( hwnd, 0, newRect.left, newRect.top, + newRect.right - newRect.left, + newRect.bottom - newRect.top, + ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); + WIN_RestoreWndsLock(iWndsLocks); + } + } + sizingRect = newRect; + } + } + } + + ReleaseCapture(); + if( iconic ) + { + if( moved ) /* restore cursors, show icon title later on */ + { + ShowCursor( FALSE ); + SetCursor( hOldCursor ); + } + DestroyCursor( hDragCursor ); + } + else if (moved && !DragFullWindows) + draw_moving_frame( hdc, &sizingRect, thickframe ); + + if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow())) + ReleaseDC( wndPtr->parent->hwndSelf, hdc ); + else + ReleaseDC( 0, hdc ); + + if ((root_window == DefaultRootWindow(display)) && + (wndPtr->parent->hwndSelf == GetDesktopWindow())) + TSXUngrabServer( display ); + + if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, hwnd, (LPARAM)&sizingRect )) + sizingRect = wndPtr->rectWindow; + + SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 ); + SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L); + + /* window moved or resized */ + if (moved) + { + /* To avoid any deadlocks, all the locks on the windows + structures must be suspended before the SetWindowPos */ + iWndsLocks = WIN_SuspendWndsLock(); + + /* if the moving/resizing isn't canceled call SetWindowPos + * with the new position or the new size of the window + */ + if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) + { + /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */ + if(!DragFullWindows) + SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, + sizingRect.right - sizingRect.left, + sizingRect.bottom - sizingRect.top, + ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); + } + else + { /* restore previous size/position */ + if(DragFullWindows) + SetWindowPos( hwnd, 0, origRect.left, origRect.top, + origRect.right - origRect.left, + origRect.bottom - origRect.top, + ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); + } + + WIN_RestoreWndsLock(iWndsLocks); + } + + if (IsIconic(hwnd)) + { + /* Single click brings up the system menu when iconized */ + + if( !moved ) + { + if( wndPtr->dwStyle & WS_SYSMENU ) + SendMessageA( hwnd, WM_SYSCOMMAND, + SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); + } + else WINPOS_ShowIconTitle( wndPtr, TRUE ); + } + +END: + WIN_ReleaseWndPtr(wndPtr); +} diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec index 391278541b..92e8466f1f 100644 --- a/dlls/x11drv/x11drv.spec +++ b/dlls/x11drv/x11drv.spec @@ -38,6 +38,7 @@ debug_channels (bitblt bitmap clipboard cursor dinput event font gdi graphics @ cdecl SetWindowRgn(long long long) X11DRV_SetWindowRgn @ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon @ cdecl SetWindowText(long wstr) X11DRV_SetWindowText +@ cdecl SysCommandSizeMove(long long) X11DRV_SysCommandSizeMove @ cdecl IsSingleWindow() X11DRV_IsSingleWindow @ cdecl AcquireClipboard() X11DRV_AcquireClipboard @ cdecl ReleaseClipboard() X11DRV_ReleaseClipboard diff --git a/include/nonclient.h b/include/nonclient.h index 064ec8c598..275076ddbe 100644 --- a/include/nonclient.h +++ b/include/nonclient.h @@ -22,5 +22,6 @@ extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM16 wParam, LPARAM lParam ); extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ); extern BOOL NC_DrawSysButton95( HWND hwnd, HDC hdc, BOOL down ); extern BOOL NC_GetSysPopupPos( struct tagWND* wndPtr, RECT* rect ); +extern void NC_GetInsideRect( HWND hwnd, RECT *rect ); #endif /* __WINE_NONCLIENT_H */ diff --git a/include/user.h b/include/user.h index 85f4ad3a14..494f7f34c5 100644 --- a/include/user.h +++ b/include/user.h @@ -81,6 +81,7 @@ typedef struct tagUSER_DRIVER { BOOL (*pSetWindowRgn)(HWND,HRGN,BOOL); HICON (*pSetWindowIcon)(HWND,HICON,BOOL); BOOL (*pSetWindowText)(HWND,LPCWSTR); + void (*pSysCommandSizeMove)(HWND,WPARAM); BOOL (*pIsSingleWindow)(void); } USER_DRIVER; diff --git a/include/win.h b/include/win.h index 8a5b3e1231..310b4c9e2e 100644 --- a/include/win.h +++ b/include/win.h @@ -71,8 +71,6 @@ typedef struct tagWND typedef struct tagWND_DRIVER { void (*pForceWindowRaise)(WND *); - void (*pPreSizeMove)(WND *); - void (*pPostSizeMove)(WND *); void (*pSurfaceCopy)(WND *, HDC, INT, INT, const RECT *, BOOL); BOOL (*pSetHostAttr)(WND *, INT haKey, INT value); } WND_DRIVER; diff --git a/include/x11drv.h b/include/x11drv.h index 7b8671eaf9..b1d654bf14 100644 --- a/include/x11drv.h +++ b/include/x11drv.h @@ -391,8 +391,6 @@ extern Window X11DRV_WND_FindXWindow(struct tagWND *wndPtr); extern void X11DRV_WND_ForceWindowRaise(struct tagWND *pWnd); extern void X11DRV_WND_SetWindowPos(struct tagWND *wndPtr, const struct tagWINDOWPOS *winpos, BOOL bSMC_SETXPOS); extern void X11DRV_WND_SetText(struct tagWND *wndPtr, LPCWSTR text); -extern void X11DRV_WND_PreSizeMove(struct tagWND *wndPtr); -extern void X11DRV_WND_PostSizeMove(struct tagWND *wndPtr); extern void X11DRV_WND_SurfaceCopy(struct tagWND *wndPtr, HDC hdc, INT dx, INT dy, const RECT *clipRect, BOOL bUpdate); extern void X11DRV_WND_SetGravity(struct tagWND* wndPtr, int value ); extern BOOL X11DRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value); diff --git a/windows/nonclient.c b/windows/nonclient.c index c024920f41..35a013341f 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -75,15 +75,6 @@ static const BYTE lpGrayMask[] = { 0xAA, 0xA0, #define HAS_MENU(w) (!((w)->dwStyle & WS_CHILD) && ((w)->wIDmenu != 0)) -#define ON_LEFT_BORDER(hit) \ - (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT)) -#define ON_RIGHT_BORDER(hit) \ - (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT)) -#define ON_TOP_BORDER(hit) \ - (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT)) -#define ON_BOTTOM_BORDER(hit) \ - (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT)) - /*********************************************************************** * WIN_WindowNeedsWMBorder * @@ -109,8 +100,7 @@ BOOL WIN_WindowNeedsWMBorder( DWORD style, DWORD exStyle ) * Compute the size of the window rectangle from the size of the * client rectangle. */ -static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL menu, - DWORD exStyle ) +static void NC_AdjustRect( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) { if (TWEAK_WineLook > WIN31_LOOK) ERR("Called in Win95 mode. Aiee! Please report this.\n" ); @@ -120,13 +110,13 @@ static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL menu, if (!WIN_WindowNeedsWMBorder(style, exStyle)) { if (HAS_THICKFRAME( style, exStyle )) - InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) ); + InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) ); else if (HAS_DLGFRAME( style, exStyle )) - InflateRect16( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) ); + InflateRect( rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) ); else if (HAS_THINFRAME( style )) - InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); + InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); if ((style & WS_CAPTION) == WS_CAPTION) rect->top -= GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER); @@ -178,7 +168,7 @@ static void NC_AdjustRect( LPRECT16 rect, DWORD style, BOOL menu, *****************************************************************************/ static void -NC_AdjustRectOuter95 (LPRECT16 rect, DWORD style, BOOL menu, DWORD exStyle) +NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle) { if(style & WS_ICONIC) return; @@ -186,13 +176,13 @@ NC_AdjustRectOuter95 (LPRECT16 rect, DWORD style, BOOL menu, DWORD exStyle) if (!WIN_WindowNeedsWMBorder(style, exStyle)) { if (HAS_THICKFRAME( style, exStyle )) - InflateRect16( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) ); + InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) ); else if (HAS_DLGFRAME( style, exStyle )) - InflateRect16(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) ); + InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) ); else if (HAS_THINFRAME( style )) - InflateRect16( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); + InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); if ((style & WS_CAPTION) == WS_CAPTION) { @@ -235,15 +225,15 @@ NC_AdjustRectOuter95 (LPRECT16 rect, DWORD style, BOOL menu, DWORD exStyle) *****************************************************************************/ static void -NC_AdjustRectInner95 (LPRECT16 rect, DWORD style, DWORD exStyle) +NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle) { if(style & WS_ICONIC) return; if (exStyle & WS_EX_CLIENTEDGE) - InflateRect16 (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); + InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); if (exStyle & WS_EX_STATICEDGE) - InflateRect16 (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); + InflateRect(rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)); if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL); if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL); @@ -475,13 +465,27 @@ BOOL WINAPI AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu ) BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style, BOOL16 menu, DWORD exStyle ) { - /* Correct the window style */ + RECT rect32; + BOOL ret; - if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */ - style |= WS_CAPTION; + CONV_RECT16TO32( rect, &rect32 ); + ret = AdjustWindowRectEx( &rect32, style, menu, exStyle ); + CONV_RECT32TO16( &rect32, rect ); + return ret; +} + + +/*********************************************************************** + * AdjustWindowRectEx (USER32.@) + */ +BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) +{ + /* Correct the window style */ + + if (!(style & (WS_POPUP | WS_CHILD))) style |= WS_CAPTION; /* Overlapped window */ style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD); exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | - WS_EX_STATICEDGE | WS_EX_TOOLWINDOW); + WS_EX_STATICEDGE | WS_EX_TOOLWINDOW); if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME; TRACE("(%d,%d)-(%d,%d) %08lx %d %08lx\n", @@ -489,32 +493,16 @@ BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style, style, menu, exStyle ); if (TWEAK_WineLook == WIN31_LOOK) - NC_AdjustRect( rect, style, menu, exStyle ); - else { - NC_AdjustRectOuter95( rect, style, menu, exStyle ); - NC_AdjustRectInner95( rect, style, exStyle ); + NC_AdjustRect( rect, style, menu, exStyle ); + else + { + NC_AdjustRectOuter95( rect, style, menu, exStyle ); + NC_AdjustRectInner95( rect, style, exStyle ); } - return TRUE; } -/*********************************************************************** - * AdjustWindowRectEx (USER32.@) - */ -BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, - BOOL menu, DWORD exStyle ) -{ - RECT16 rect16; - BOOL ret; - - CONV_RECT32TO16( rect, &rect16 ); - ret = AdjustWindowRectEx16( &rect16, style, (BOOL16)menu, exStyle ); - CONV_RECT16TO32( &rect16, rect ); - return ret; -} - - /*********************************************************************** * NC_HandleNCCalcSize * @@ -522,7 +510,7 @@ BOOL WINAPI AdjustWindowRectEx( LPRECT rect, DWORD style, */ LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect ) { - RECT16 tmpRect = { 0, 0, 0, 0 }; + RECT tmpRect = { 0, 0, 0, 0 }; LONG result = 0; UINT style = (UINT) GetClassLongA(pWnd->hwndSelf, GCL_STYLE); @@ -553,7 +541,7 @@ LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect ) } if (TWEAK_WineLook > WIN31_LOOK) { - SetRect16 (&tmpRect, 0, 0, 0, 0); + SetRect(&tmpRect, 0, 0, 0, 0); NC_AdjustRectInner95 (&tmpRect, pWnd->dwStyle, pWnd->dwExStyle); winRect->left -= tmpRect.left; winRect->top -= tmpRect.top; @@ -578,7 +566,7 @@ LONG NC_HandleNCCalcSize( WND *pWnd, RECT *winRect ) * but without the borders (if any). * The rectangle is in window coordinates (for drawing with GetWindowDC()). */ -static void NC_GetInsideRect( HWND hwnd, RECT *rect ) +void NC_GetInsideRect( HWND hwnd, RECT *rect ) { WND * wndPtr = WIN_FindWndPtr( hwnd ); @@ -590,68 +578,35 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect ) /* Remove frame from rectangle */ if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) - InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) ); - else - if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) { - InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME)); - /* FIXME: this isn't in NC_AdjustRect? why not? */ - if (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME) + InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) ); + } + else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle )) + { + InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME)); + /* FIXME: this isn't in NC_AdjustRect? why not? */ + if ((TWEAK_WineLook == WIN31_LOOK) && (wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)) InflateRect( rect, -1, 0 ); } - else - if (HAS_THINFRAME( wndPtr->dwStyle )) - InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) ); -END: - WIN_ReleaseWndPtr(wndPtr); - return; -} - - -/*********************************************************************** - * NC_GetInsideRect95 - * - * Get the 'inside' rectangle of a window, i.e. the whole window rectangle - * but without the borders (if any). - * The rectangle is in window coordinates (for drawing with GetWindowDC()). - */ - -static void -NC_GetInsideRect95 (HWND hwnd, RECT *rect) -{ - WND * wndPtr = WIN_FindWndPtr( hwnd ); - - rect->top = rect->left = 0; - rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; - rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top; - - if ((wndPtr->dwStyle & WS_ICONIC) || (wndPtr->dwExStyle & WS_EX_MANAGED)) goto END; - - /* Remove frame from rectangle */ - if (HAS_THICKFRAME (wndPtr->dwStyle, wndPtr->dwExStyle)) - { - InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) ); - } - else if (HAS_DLGFRAME (wndPtr->dwStyle, wndPtr->dwExStyle )) - { - InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME)); - } - else if (HAS_THINFRAME (wndPtr->dwStyle)) + else if (HAS_THINFRAME( wndPtr->dwStyle )) { InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) ); } /* We have additional border information if the window * is a child (but not an MDI child) */ - if ( (wndPtr->dwStyle & WS_CHILD) && - ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) ) - { - if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE) - InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE)); - - if (wndPtr->dwExStyle & WS_EX_STATICEDGE) - InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); + if (TWEAK_WineLook != WIN31_LOOK) + { + if ( (wndPtr->dwStyle & WS_CHILD) && + ( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) ) + { + if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE) + InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE)); + if (wndPtr->dwExStyle & WS_EX_STATICEDGE) + InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); + } } + END: WIN_ReleaseWndPtr(wndPtr); return; @@ -1064,7 +1019,7 @@ NC_DrawSysButton95 (HWND hwnd, HDC hdc, BOOL down) HICON hIcon; RECT rect; - NC_GetInsideRect95( hwnd, &rect ); + NC_GetInsideRect( hwnd, &rect ); hIcon = NC_IconForWindow( wndPtr ); @@ -1107,7 +1062,7 @@ static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed) if( !(wndPtr->dwExStyle & WS_EX_MANAGED) ) { - NC_GetInsideRect95( hwnd, &rect ); + NC_GetInsideRect( hwnd, &rect ); /* A tool window has a smaller Close button */ if(wndPtr->dwExStyle & WS_EX_TOOLWINDOW) @@ -1150,7 +1105,7 @@ static void NC_DrawMaxButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed) if( !(wndPtr->dwExStyle & WS_EX_MANAGED)) { UINT flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX; - NC_GetInsideRect95( hwnd, &rect ); + NC_GetInsideRect( hwnd, &rect ); if (wndPtr->dwStyle & WS_SYSMENU) rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; rect.left = rect.right - GetSystemMetrics(SM_CXSIZE); @@ -1178,7 +1133,7 @@ static void NC_DrawMinButton95(HWND hwnd,HDC16 hdc,BOOL down, BOOL bGrayed) if( !(wndPtr->dwExStyle & WS_EX_MANAGED)) { UINT flags = DFCS_CAPTIONMIN; - NC_GetInsideRect95( hwnd, &rect ); + NC_GetInsideRect( hwnd, &rect ); if (wndPtr->dwStyle & WS_SYSMENU) rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; if (wndPtr->dwStyle & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX)) @@ -1340,25 +1295,6 @@ static void NC_DrawFrame95( InflateRect( rect, -width, -height ); } -/*********************************************************************** - * NC_DrawMovingFrame - * - * Draw the frame used when moving or resizing window. - * - * FIXME: This causes problems in Win95 mode. (why?) - */ -static void NC_DrawMovingFrame( HDC hdc, RECT *rect, BOOL thickframe ) -{ - if (thickframe) - { - RECT16 r16; - CONV_RECT32TO16( rect, &r16 ); - FastWindowFrame16( hdc, &r16, GetSystemMetrics(SM_CXFRAME), - GetSystemMetrics(SM_CYFRAME), PATINVERT ); - } - else DrawFocusRect( hdc, rect ); -} - /*********************************************************************** * NC_DrawCaption @@ -1901,10 +1837,7 @@ BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect ) GetWindowRect( wndPtr->hwndSelf, rect ); else { - if (TWEAK_WineLook == WIN31_LOOK) - NC_GetInsideRect( wndPtr->hwndSelf, rect ); - else - NC_GetInsideRect95( wndPtr->hwndSelf, rect ); + NC_GetInsideRect( wndPtr->hwndSelf, rect ); OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top); if (wndPtr->dwStyle & WS_CHILD) ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)rect ); @@ -1922,393 +1855,6 @@ BOOL NC_GetSysPopupPos( WND* wndPtr, RECT* rect ) return FALSE; } -/*********************************************************************** - * NC_StartSizeMove - * - * Initialisation of a move or resize, when initiatied from a menu choice. - * Return hit test code for caption or sizing border. - */ -static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam, - POINT *capturePoint ) -{ - LONG hittest = 0; - POINT pt; - MSG msg; - RECT rectWindow; - - GetWindowRect(wndPtr->hwndSelf,&rectWindow); - - if ((wParam & 0xfff0) == SC_MOVE) - { - /* Move pointer at the center of the caption */ - RECT rect; - if (TWEAK_WineLook == WIN31_LOOK) - NC_GetInsideRect( wndPtr->hwndSelf, &rect ); - else - NC_GetInsideRect95( wndPtr->hwndSelf, &rect ); - if (wndPtr->dwStyle & WS_SYSMENU) - rect.left += GetSystemMetrics(SM_CXSIZE) + 1; - if (wndPtr->dwStyle & WS_MINIMIZEBOX) - rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; - if (wndPtr->dwStyle & WS_MAXIMIZEBOX) - rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; - pt.x = rectWindow.left + (rect.right - rect.left) / 2; - pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2; - hittest = HTCAPTION; - *capturePoint = pt; - } - else /* SC_SIZE */ - { - while(!hittest) - { - MSG_InternalGetMessage( &msg, 0, 0, WM_KEYFIRST, WM_MOUSELAST, - MSGF_SIZE, PM_REMOVE, FALSE, NULL ); - switch(msg.message) - { - case WM_MOUSEMOVE: - hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt ); - if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) - hittest = 0; - break; - - case WM_LBUTTONUP: - return 0; - - case WM_KEYDOWN: - switch(msg.wParam) - { - case VK_UP: - hittest = HTTOP; - pt.x =(rectWindow.left+rectWindow.right)/2; - pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2; - break; - case VK_DOWN: - hittest = HTBOTTOM; - pt.x =(rectWindow.left+rectWindow.right)/2; - pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2; - break; - case VK_LEFT: - hittest = HTLEFT; - pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2; - pt.y =(rectWindow.top+rectWindow.bottom)/2; - break; - case VK_RIGHT: - hittest = HTRIGHT; - pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2; - pt.y =(rectWindow.top+rectWindow.bottom)/2; - break; - case VK_RETURN: - case VK_ESCAPE: return 0; - } - } - } - *capturePoint = pt; - } - SetCursorPos( pt.x, pt.y ); - NC_HandleSetCursor( wndPtr->hwndSelf, - wndPtr->hwndSelf, MAKELONG( hittest, WM_MOUSEMOVE )); - return hittest; -} - - -/*********************************************************************** - * NC_DoSizeMove - * - * Perform SC_MOVE and SC_SIZE commands. ` - */ -static void NC_DoSizeMove( HWND hwnd, WORD wParam ) -{ - MSG msg; - RECT sizingRect, mouseRect, origRect; - HDC hdc; - LONG hittest = (LONG)(wParam & 0x0f); - HCURSOR16 hDragCursor = 0, hOldCursor = 0; - POINT minTrack, maxTrack; - POINT capturePoint, pt; - WND * wndPtr = WIN_FindWndPtr( hwnd ); - BOOL thickframe = HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ); - BOOL iconic = wndPtr->dwStyle & WS_MINIMIZE; - BOOL moved = FALSE; - DWORD dwPoint = GetMessagePos (); - BOOL DragFullWindows = FALSE; - int iWndsLocks; - - SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); - - pt.x = SLOWORD(dwPoint); - pt.y = SHIWORD(dwPoint); - capturePoint = pt; - - if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || - (wndPtr->dwExStyle & WS_EX_MANAGED)) goto END; - - if ((wParam & 0xfff0) == SC_MOVE) - { - if (!hittest) - hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint ); - if (!hittest) goto END; - } - else /* SC_SIZE */ - { - if (!thickframe) goto END; - if ( hittest && hittest != HTSYSMENU ) hittest += 2; - else - { - SetCapture(hwnd); - hittest = NC_StartSizeMove( wndPtr, wParam, &capturePoint ); - if (!hittest) - { - ReleaseCapture(); - goto END; - } - } - } - - /* Get min/max info */ - - WINPOS_GetMinMaxInfo( wndPtr, NULL, NULL, &minTrack, &maxTrack ); - sizingRect = wndPtr->rectWindow; - origRect = sizingRect; - if (wndPtr->dwStyle & WS_CHILD) - GetClientRect( wndPtr->parent->hwndSelf, &mouseRect ); - else - SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); - if (ON_LEFT_BORDER(hittest)) - { - mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); - mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x ); - } - else if (ON_RIGHT_BORDER(hittest)) - { - mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x ); - mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x ); - } - if (ON_TOP_BORDER(hittest)) - { - mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y ); - mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y); - } - else if (ON_BOTTOM_BORDER(hittest)) - { - mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); - mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); - } - if (wndPtr->dwStyle & WS_CHILD) - { - MapWindowPoints( wndPtr->parent->hwndSelf, 0, - (LPPOINT)&mouseRect, 2 ); - } - SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); - - if (GetCapture() != hwnd) SetCapture( hwnd ); - - if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow())) - { - /* Retrieve a default cache DC (without using the window style) */ - hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE ); - } - else - hdc = GetDC( 0 ); - - if( iconic ) /* create a cursor for dragging */ - { - HICON16 hIcon = GetClassWord(wndPtr->hwndSelf, GCW_HICON); - if(!hIcon) hIcon = (HICON16) SendMessage16( hwnd, WM_QUERYDRAGICON, 0, 0L); - if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE ); - if( !hDragCursor ) iconic = FALSE; - } - - wndPtr->pDriver->pPreSizeMove(wndPtr); - - /* invert frame if WIN31_LOOK to indicate mouse click on caption */ - if( !iconic && TWEAK_WineLook == WIN31_LOOK ) - if(!DragFullWindows) - NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - - while(1) - { - int dx = 0, dy = 0; - - MSG_InternalGetMessage( &msg, 0, 0, 0, 0, MSGF_SIZE, PM_REMOVE, FALSE, NULL ); - - /* Exit on button-up, Return, or Esc */ - if ((msg.message == WM_LBUTTONUP) || - ((msg.message == WM_KEYDOWN) && - ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break; - - if (msg.message == WM_PAINT) - { - if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - UpdateWindow( msg.hwnd ); - if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - continue; - } - - if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) - continue; /* We are not interested in other messages */ - - pt = msg.pt; - - if (msg.message == WM_KEYDOWN) switch(msg.wParam) - { - case VK_UP: pt.y -= 8; break; - case VK_DOWN: pt.y += 8; break; - case VK_LEFT: pt.x -= 8; break; - case VK_RIGHT: pt.x += 8; break; - } - - pt.x = max( pt.x, mouseRect.left ); - pt.x = min( pt.x, mouseRect.right ); - pt.y = max( pt.y, mouseRect.top ); - pt.y = min( pt.y, mouseRect.bottom ); - - dx = pt.x - capturePoint.x; - dy = pt.y - capturePoint.y; - - if (dx || dy) - { - if( !moved ) - { - moved = TRUE; - - if( iconic ) /* ok, no system popup tracking */ - { - hOldCursor = SetCursor(hDragCursor); - ShowCursor( TRUE ); - WINPOS_ShowIconTitle( wndPtr, FALSE ); - } else if(TWEAK_WineLook != WIN31_LOOK) - { - if(!DragFullWindows) - NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - } - } - - if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y ); - else - { - RECT newRect = sizingRect; - WPARAM wpSizingHit = 0; - - if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy ); - if (ON_LEFT_BORDER(hittest)) newRect.left += dx; - else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx; - if (ON_TOP_BORDER(hittest)) newRect.top += dy; - else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy; - if(!iconic && !DragFullWindows) NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - capturePoint = pt; - - /* determine the hit location */ - if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT) - wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT); - SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect ); - - if (!iconic) - { - if(!DragFullWindows) - NC_DrawMovingFrame( hdc, &newRect, thickframe ); - else { - /* To avoid any deadlocks, all the locks on the windows - structures must be suspended before the SetWindowPos */ - iWndsLocks = WIN_SuspendWndsLock(); - SetWindowPos( hwnd, 0, newRect.left, newRect.top, - newRect.right - newRect.left, - newRect.bottom - newRect.top, - ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); - WIN_RestoreWndsLock(iWndsLocks); - } - } - sizingRect = newRect; - } - } - } - - ReleaseCapture(); - if( iconic ) - { - if( moved ) /* restore cursors, show icon title later on */ - { - ShowCursor( FALSE ); - SetCursor( hOldCursor ); - } - DestroyCursor( hDragCursor ); - } - else if(moved || TWEAK_WineLook == WIN31_LOOK) - if(!DragFullWindows) - NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); - - if (wndPtr->parent && (wndPtr->parent->hwndSelf != GetDesktopWindow())) - ReleaseDC( wndPtr->parent->hwndSelf, hdc ); - else - ReleaseDC( 0, hdc ); - - wndPtr->pDriver->pPostSizeMove(wndPtr); - - if (HOOK_IsHooked( WH_CBT )) - { - RECT16* pr = SEGPTR_NEW(RECT16); - if( pr ) - { - CONV_RECT32TO16( &sizingRect, pr ); - if( HOOK_CallHooks16( WH_CBT, HCBT_MOVESIZE, hwnd, - (LPARAM)SEGPTR_GET(pr)) ) - sizingRect = wndPtr->rectWindow; - else - CONV_RECT16TO32( pr, &sizingRect ); - SEGPTR_FREE(pr); - } - } - SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 ); - SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic16(hwnd), 0L); - - /* window moved or resized */ - if (moved) - { - /* To avoid any deadlocks, all the locks on the windows - structures must be suspended before the SetWindowPos */ - iWndsLocks = WIN_SuspendWndsLock(); - - /* if the moving/resizing isn't canceled call SetWindowPos - * with the new position or the new size of the window - */ - if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) - { - /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */ - if(!DragFullWindows) - SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top, - sizingRect.right - sizingRect.left, - sizingRect.bottom - sizingRect.top, - ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); - } - else { /* restore previous size/position */ - if(DragFullWindows) - SetWindowPos( hwnd, 0, origRect.left, origRect.top, - origRect.right - origRect.left, - origRect.bottom - origRect.top, - ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ); - } - - WIN_RestoreWndsLock(iWndsLocks); - } - - if( IsWindow(hwnd) ) - if( wndPtr->dwStyle & WS_MINIMIZE ) - { - /* Single click brings up the system menu when iconized */ - - if( !moved ) - { - if( wndPtr->dwStyle & WS_SYSMENU ) - SendMessageA( hwnd, WM_SYSCOMMAND, - SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y)); - } - else WINPOS_ShowIconTitle( wndPtr, TRUE ); - } - -END: - WIN_ReleaseWndPtr(wndPtr); -} - - /*********************************************************************** * NC_TrackMinMaxBox95 * @@ -2704,7 +2250,8 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ) { case SC_SIZE: case SC_MOVE: - NC_DoSizeMove( hwnd, wParam ); + if (USER_Driver.pSysCommandSizeMove) + USER_Driver.pSysCommandSizeMove( hwnd, wParam ); break; case SC_MINIMIZE: diff --git a/windows/x11drv/wnd.c b/windows/x11drv/wnd.c index 48260d3b29..facff76b52 100644 --- a/windows/x11drv/wnd.c +++ b/windows/x11drv/wnd.c @@ -41,8 +41,6 @@ extern Atom wmChangeState; WND_DRIVER X11DRV_WND_Driver = { X11DRV_WND_ForceWindowRaise, - X11DRV_WND_PreSizeMove, - X11DRV_WND_PostSizeMove, X11DRV_WND_SurfaceCopy, X11DRV_WND_SetHostAttr }; @@ -316,27 +314,6 @@ void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bChangeP WIN_ReleaseWndPtr(winposPtr); } -/***************************************************************** - * X11DRV_WND_PreSizeMove - */ -void X11DRV_WND_PreSizeMove(WND *wndPtr) -{ - /* Grab the server only when moving top-level windows without desktop */ - if ((X11DRV_GetXRootWindow() == DefaultRootWindow(display)) && - (wndPtr->parent->hwndSelf == GetDesktopWindow())) - TSXGrabServer( display ); -} - -/***************************************************************** - * X11DRV_WND_PostSizeMove - */ -void X11DRV_WND_PostSizeMove(WND *wndPtr) -{ - if ((X11DRV_GetXRootWindow() == DefaultRootWindow(display)) && - (wndPtr->parent->hwndSelf == GetDesktopWindow())) - TSXUngrabServer( display ); -} - /***************************************************************** * X11DRV_WND_SurfaceCopy *