diff --git a/include/winpos.h b/include/winpos.h index 82fadd09d87..c5c53001930 100644 --- a/include/winpos.h +++ b/include/winpos.h @@ -15,6 +15,9 @@ #define SWP_NOCLIENTSIZE 0x0800 #define SWP_NOCLIENTMOVE 0x1000 +/* Wine extra SWP flag */ +#define SWP_WINE_NOHOSTMOVE 0x80000000 + struct tagWINDOWPOS16; typedef struct diff --git a/include/winuser.h b/include/winuser.h index 5118fac5fc2..88d9f85373c 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -2336,6 +2336,7 @@ DECL_WINELIB_TYPE_AW(LPNONCLIENTMETRICS) #define SWP_NOSENDCHANGING 0x0400 #define SWP_DEFERERASE 0x2000 +#define SWP_ASYNCWINDOWPOS 0x4000 #define HWND_DESKTOP ((HWND)0) #define HWND_BROADCAST ((HWND)0xffff) @@ -3542,7 +3543,7 @@ HHOOK WINAPI SetWindowsHookW(INT,HOOKPROC); HHOOK WINAPI SetWindowsHookExA(INT,HOOKPROC,HINSTANCE,DWORD); HHOOK WINAPI SetWindowsHookExW(INT,HOOKPROC,HINSTANCE,DWORD); #define SetWindowsHookEx WINELIB_NAME_AW(SetWindowsHookEx) -BOOL WINAPI SetWindowPos(HWND,HWND,INT,INT,INT,INT,WORD); +BOOL WINAPI SetWindowPos(HWND,HWND,INT,INT,INT,INT,UINT); INT WINAPI SetWindowRgn(HWND,HRGN,BOOL); BOOL WINAPI SetWindowTextA(HWND,LPCSTR); BOOL WINAPI SetWindowTextW(HWND,LPCWSTR); diff --git a/windows/winpos.c b/windows/winpos.c index 5954f180ac6..52476a1df68 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -2449,7 +2449,7 @@ BOOL16 WINAPI SetWindowPos16( HWND16 hwnd, HWND16 hwndInsertAfter, * SetWindowPos (USER32.520) */ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter, - INT x, INT y, INT cx, INT cy, WORD flags) + INT x, INT y, INT cx, INT cy, UINT flags ) { WINDOWPOS winpos; WND * wndPtr,*wndTemp; @@ -2457,7 +2457,7 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter, RECT oldWindowRect, oldClientRect; HRGN visRgn = 0; UINT wvrFlags = 0, uFlags = 0; - BOOL retvalue, resync = FALSE; + BOOL retvalue, resync = FALSE, bChangePos; HWND hwndActive = 0; /* Get current active window from the active queue */ @@ -2474,6 +2474,10 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter, TRACE(win,"hwnd %04x, swp (%i,%i)-(%i,%i) flags %08x\n", hwnd, x, y, x+cx, y+cy, flags); + bChangePos = !(flags & SWP_WINE_NOHOSTMOVE); + flags &= ~SWP_WINE_NOHOSTMOVE; + + /* ------------------------------------------------------------------------ CHECKS */ /* Check window handle */ @@ -2651,7 +2655,7 @@ Pos: /* ----------------------------------------------------------------------- cx = newWindowRect.right - newWindowRect.left; cy = newWindowRect.bottom - newWindowRect.top; - wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, TRUE); + wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, bChangePos); winpos.hwndInsertAfter = tempInsertAfter; bCallDriver = FALSE; @@ -2701,7 +2705,7 @@ Pos: /* ----------------------------------------------------------------------- wndPtr->pDriver->pSetHostAttr(wndPtr, HAK_BITGRAVITY, BGForget ); } - wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, TRUE); + wndPtr->pDriver->pSetWindowPos(wndPtr, &winpos, bChangePos); winpos.hwndInsertAfter = tempInsertAfter; } diff --git a/windows/x11drv/event.c b/windows/x11drv/event.c index 769d76a76f2..d44c171a8db 100644 --- a/windows/x11drv/event.c +++ b/windows/x11drv/event.c @@ -708,32 +708,25 @@ BOOL X11DRV_EVENT_CheckFocus(void) static void EVENT_GetGeometry( Window win, int *px, int *py, unsigned int *pwidth, unsigned int *pheight ) { - Window root, parent, *children; - int xpos, ypos; - unsigned int width, height, border, depth, nb_children; - - if (!TSXGetGeometry( display, win, &root, px, py, pwidth, pheight, - &border, &depth )) return; - if (win == X11DRV_GetXRootWindow()) - { - *px = *py = 0; - return; - } - - for (;;) - { - if (!TSXQueryTree(display, win, &root, &parent, &children, &nb_children)) - return; - TSXFree( children ); - if (parent == X11DRV_GetXRootWindow()) break; - win = parent; - if (!TSXGetGeometry( display, win, &root, &xpos, &ypos, - &width, &height, &border, &depth )) return; - *px += xpos; - *py += ypos; - } -} + Window root, top; + int x, y, width, height, border, depth; + EnterCriticalSection( &X11DRV_CritSection ); + + /* Get the geometry of the window */ + XGetGeometry( display, win, &root, &x, &y, &width, &height, + &border, &depth ); + + /* Translate the window origin to root coordinates */ + XTranslateCoordinates( display, win, root, 0, 0, &x, &y, &top ); + + LeaveCriticalSection( &X11DRV_CritSection ); + + *px = x; + *py = y; + *pwidth = width; + *pheight = height; +} /********************************************************************** * EVENT_ConfigureNotify @@ -785,7 +778,7 @@ static void EVENT_ConfigureNotify( HWND hWnd, XConfigureEvent *event ) if ( flags != (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER) ) SetWindowPos( hWnd, newInsertAfter, x, y, width, height, - flags | SWP_NOACTIVATE ); + flags | SWP_NOACTIVATE | SWP_WINE_NOHOSTMOVE ); } diff --git a/windows/x11drv/wnd.c b/windows/x11drv/wnd.c index 0b98071641a..e988a101833 100644 --- a/windows/x11drv/wnd.c +++ b/windows/x11drv/wnd.c @@ -234,7 +234,8 @@ BOOL X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BO if (wndPtr->flags & WIN_MANAGED) { XClassHint *class_hints = TSXAllocClassHint(); - + XSizeHints* size_hints = TSXAllocSizeHints(); + if (class_hints) { class_hints->res_name = "wineManaged"; @@ -243,19 +244,21 @@ BOOL X11DRV_WND_CreateWindow(WND *wndPtr, CLASS *classPtr, CREATESTRUCTA *cs, BO TSXFree (class_hints); } - if (cs->dwExStyle & WS_EX_DLGMODALFRAME) + if (size_hints) { - XSizeHints* size_hints = TSXAllocSizeHints(); - - if (size_hints) + size_hints->win_gravity = StaticGravity; + size_hints->flags = PWinGravity; + + if (cs->dwExStyle & WS_EX_DLGMODALFRAME) { size_hints->min_width = size_hints->max_width = cs->cx; size_hints->min_height = size_hints->max_height = cs->cy; - size_hints->flags = (PSize | PMinSize | PMaxSize); - TSXSetWMSizeHints( display, X11DRV_WND_GetXWindow(wndPtr), - size_hints, XA_WM_NORMAL_HINTS ); - TSXFree(size_hints); + size_hints->flags |= PMinSize | PMaxSize; } + + TSXSetWMSizeHints( display, X11DRV_WND_GetXWindow(wndPtr), + size_hints, XA_WM_NORMAL_HINTS ); + TSXFree(size_hints); } } @@ -488,6 +491,7 @@ void X11DRV_WND_SetWindowPos(WND *wndPtr, const WINDOWPOS *winpos, BOOL bChangeP XWindowChanges winChanges; int changeMask = 0; WND *winposPtr = WIN_FindWndPtr( winpos->hwnd ); + if ( !winposPtr ) return; if(!wndPtr->hwndSelf) wndPtr = NULL; /* FIXME: WND destroyed, shouldn't happend!!! */