diff options
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwindow.c')
-rw-r--r-- | xorg-server/hw/xwin/winmultiwindowwindow.c | 291 |
1 files changed, 138 insertions, 153 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c index 2329d163e..f87da410e 100644 --- a/xorg-server/hw/xwin/winmultiwindowwindow.c +++ b/xorg-server/hw/xwin/winmultiwindowwindow.c @@ -78,7 +78,7 @@ void winInitMultiWindowClass(void) wcx.hIconSm = g_hSmallIconX; #if CYGMULTIWINDOW_DEBUG - ErrorF ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X); + winDebug ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X); #endif atomXWinClass = RegisterClassEx (&wcx); @@ -98,7 +98,7 @@ winCreateWindowMultiWindow (WindowPtr pWin) winScreenPriv(pScreen); #if CYGMULTIWINDOW_DEBUG - winTrace ("winCreateWindowMultiWindow - pWin: %p\n", pWin); + winDebug ("winCreateWindowMultiWindow - pWin: %p\n", pWin); #endif WIN_UNWRAP(CreateWindow); @@ -131,7 +131,7 @@ winDestroyWindowMultiWindow (WindowPtr pWin) winScreenPriv(pScreen); #if CYGMULTIWINDOW_DEBUG - ErrorF ("winDestroyWindowMultiWindow - pWin: %p\n", pWin); + winDebug ("winDestroyWindowMultiWindow - pWin: %p\n", pWin); #endif WIN_UNWRAP(DestroyWindow); @@ -168,32 +168,31 @@ winPositionWindowMultiWindow (WindowPtr pWin, int x, int y) HWND hWnd = pWinPriv->hWnd; RECT rcNew; RECT rcOld; -#if CYGMULTIWINDOW_DEBUG +#ifdef WINDBG RECT rcClient; RECT *lpRc; #endif DWORD dwExStyle; DWORD dwStyle; -#if CYGMULTIWINDOW_DEBUG - winTrace ("winPositionWindowMultiWindow - pWin: %p\n", pWin); -#endif + winDebug ("winPositionWindowMultiWindow - pWin: %p\n", pWin); WIN_UNWRAP(PositionWindow); fResult = (*pScreen->PositionWindow)(pWin, x, y); WIN_WRAP(PositionWindow, winPositionWindowMultiWindow); -#if CYGWINDOWING_DEBUG - ErrorF ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", + winDebug ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", x, y); -#endif /* Bail out if the Windows window handle is bad */ if (!hWnd) { -#if CYGWINDOWING_DEBUG - ErrorF ("\timmediately return since hWnd is NULL\n"); -#endif + winDebug ("\timmediately return since hWnd is NULL\n"); + if (pWin->redirectDraw != RedirectDrawNone) + { + winDebug("winPositionWindowMultiWindow: Calling compReallocPixmap to make sure the pixmap buffer is valid.\n"); + compReallocPixmap(pWin, x, y, pWin->drawable.width, pWin->drawable.height, pWin->borderWidth); + } return fResult; } @@ -214,7 +213,7 @@ winPositionWindowMultiWindow (WindowPtr pWin, int x, int y) #if CYGMULTIWINDOW_DEBUG lpRc = &rcNew; - ErrorF ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n", + winDebug ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); #endif @@ -232,40 +231,45 @@ winPositionWindowMultiWindow (WindowPtr pWin, int x, int y) GetClientRect (hWnd, &rcClient); lpRc = &rcNew; - ErrorF ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n", + winDebug ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); lpRc = &rcOld; - ErrorF ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n", + winDebug ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); lpRc = &rcClient; - ErrorF ("(%d ms)rcClient (%d, %d)-(%d, %d)\n", + winDebug ("(%d ms)rcClient (%d, %d)-(%d, %d)\n", GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom); #endif /* Check if the old rectangle and new rectangle are the same */ if (!EqualRect (&rcNew, &rcOld)) { -#if CYGMULTIWINDOW_DEBUG - ErrorF ("winPositionWindowMultiWindow - Need to move\n"); -#endif - -#if CYGWINDOWING_DEBUG - ErrorF ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top, + winDebug ("winPositionWindowMultiWindow - Need to move\n"); + winDebug ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top); -#endif - /* Change the position and dimensions of the Windows window */ - MoveWindow (hWnd, - rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, - TRUE); + + /* Change the position and dimensions of the Windows window */ + if (pWinPriv->fWglUsed) + { + int iWidth=rcNew.right - rcNew.left; + int iHeight=rcNew.bottom - rcNew.top; + ScreenToClient(GetParent(hWnd), (LPPOINT)&rcNew); + MoveWindow (hWnd, + rcNew.left, rcNew.top, + iWidth, iHeight, + TRUE); + } + else + MoveWindow (hWnd, + rcNew.left, rcNew.top, + rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, + TRUE); } else { -#if CYGMULTIWINDOW_DEBUG - ErrorF ("winPositionWindowMultiWindow - Not need to move\n"); -#endif + winDebug ("winPositionWindowMultiWindow - Not need to move\n"); } return fResult; @@ -283,9 +287,7 @@ winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask) ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); -#if CYGMULTIWINDOW_DEBUG - ErrorF ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin); -#endif + winDebug ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin); WIN_UNWRAP(ChangeWindowAttributes); fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask); @@ -313,7 +315,7 @@ winUnmapWindowMultiWindow (WindowPtr pWin) winScreenPriv(pScreen); #if CYGMULTIWINDOW_DEBUG - ErrorF ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin); + winDebug ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin); #endif WIN_UNWRAP(UnrealizeWindow); @@ -344,7 +346,7 @@ winMapWindowMultiWindow (WindowPtr pWin) winScreenPriv(pScreen); #if CYGMULTIWINDOW_DEBUG - ErrorF ("winMapWindowMultiWindow - pWin: %08x\n", pWin); + winDebug ("winMapWindowMultiWindow - pWin: %08x\n", pWin); #endif WIN_UNWRAP(RealizeWindow); @@ -395,85 +397,22 @@ winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent) void winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib) { -#if 0 - WindowPtr pPrevWin; - UINT uFlags; - HWND hInsertAfter; - HWND hWnd = NULL; -#endif ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); -#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG - winTrace ("winRestackMultiWindow - %08x\n", pWin); -#endif + winDebug ("winRestackMultiWindow - %08x\n", pWin); WIN_UNWRAP(RestackWindow); if (pScreen->RestackWindow) (*pScreen->RestackWindow)(pWin, pOldNextSib); WIN_WRAP(RestackWindow, winRestackWindowMultiWindow); -#if 1 /* * Calling winReorderWindowsMultiWindow here means our window manager * (i.e. Windows Explorer) has initiative to determine Z order. */ if (pWin->nextSib != pOldNextSib) winReorderWindowsMultiWindow (); -#else - /* Bail out if no window privates or window handle is invalid */ - if (!pWinPriv || !pWinPriv->hWnd) - return; - - /* Get a pointer to our previous sibling window */ - pPrevWin = pWin->prevSib; - - /* - * Look for a sibling window with - * valid privates and window handle - */ - while (pPrevWin - && !winGetWindowPriv(pPrevWin) - && !winGetWindowPriv(pPrevWin)->hWnd) - pPrevWin = pPrevWin->prevSib; - - /* Check if we found a valid sibling */ - if (pPrevWin) - { - /* Valid sibling - get handle to insert window after */ - hInsertAfter = winGetWindowPriv(pPrevWin)->hWnd; - uFlags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE; - - hWnd = GetNextWindow (pWinPriv->hWnd, GW_HWNDPREV); - - do - { - if (GetProp (hWnd, WIN_WINDOW_PROP)) - { - if (hWnd == winGetWindowPriv(pPrevWin)->hWnd) - { - uFlags |= SWP_NOZORDER; - } - break; - } - hWnd = GetNextWindow (hWnd, GW_HWNDPREV); - } - while (hWnd); - } - else - { - /* No valid sibling - make this window the top window */ - hInsertAfter = HWND_TOP; - uFlags = SWP_NOMOVE | SWP_NOSIZE; - } - - /* Perform the restacking operation in Windows */ - SetWindowPos (pWinPriv->hWnd, - hInsertAfter, - 0, 0, - 0, 0, - uFlags); -#endif } @@ -509,14 +448,42 @@ winCreateWindowsWindow (WindowPtr pWin) iHeight = pWin->drawable.height; /* If it's an InputOutput window, and so is going to end up being made visible, - make sure the window actually ends up somewhere where it will be visible */ + make sure the window actually ends up somewhere where it will be visible + Dont't do it by making just one of the two iX and iY CW_USEDEFAULT since + this will create a window at place CW_USEDEFAULT which is 0x80000000 */ if (pWin->drawable.class != InputOnly) { - if ((iX < GetSystemMetrics (SM_XVIRTUALSCREEN)) || (iX > GetSystemMetrics (SM_CXVIRTUALSCREEN))) - iX = CW_USEDEFAULT; + while (1) + { + if (iX < GetSystemMetrics (SM_XVIRTUALSCREEN)) + { + iX = GetSystemMetrics (SM_XVIRTUALSCREEN); + ErrorF("Resetting iX to %d\n",iX); + } + else if (iX > GetSystemMetrics (SM_CXVIRTUALSCREEN)) + { + iX = GetSystemMetrics (SM_CXVIRTUALSCREEN)-iWidth; + ErrorF("Resetting iX to %d\n",iX); + } + else + break; + } - if ((iY < GetSystemMetrics (SM_YVIRTUALSCREEN)) || (iY > GetSystemMetrics (SM_CYVIRTUALSCREEN))) - iY = CW_USEDEFAULT; + while (1) + { + if (iY < GetSystemMetrics (SM_YVIRTUALSCREEN)) + { + iY = GetSystemMetrics (SM_YVIRTUALSCREEN); + ErrorF("Resetting iY to %d\n",iY); + } + else if (iY > GetSystemMetrics (SM_CYVIRTUALSCREEN)) + { + iY = GetSystemMetrics (SM_CYVIRTUALSCREEN)-iHeight; + ErrorF("Resetting iY to %d\n",iY); + } + else + break; + } } winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY); @@ -588,14 +555,20 @@ winCreateWindowsWindow (WindowPtr pWin) if (hIcon) SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); if (hIconSmall) SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall); + /* If we asked the native WM to place the window, synchronize the X window position. + Do this before the next SetWindowPos because this one is generating a WM_STYLECHANGED + message which is causing a window move, which is wrong if the Xwindow does not + have the correct coordinates yet */ + if (iX == CW_USEDEFAULT) + { + winAdjustXWindow(pWin, hWnd); + } + /* Change style back to popup, already placed... */ SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); SetWindowPos (hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - - /* Adjust the X window to match the window placement we actually got... */ - winAdjustXWindow (pWin, hWnd); - + /* Make sure it gets the proper system menu for a WS_POPUP, too */ GetSystemMenu (hWnd, TRUE); @@ -682,7 +655,7 @@ winUpdateWindowsWindow (WindowPtr pWin) HWND hWnd = pWinPriv->hWnd; #if CYGMULTIWINDOW_DEBUG - ErrorF ("winUpdateWindowsWindow\n"); + winDebug ("winUpdateWindowsWindow\n"); #endif /* Check if the Windows window's parents have been destroyed */ @@ -706,13 +679,49 @@ winUpdateWindowsWindow (WindowPtr pWin) } else if (hWnd != NULL) { - /* Destroy the Windows window if its parents are destroyed */ - winDestroyWindowsWindow (pWin); - assert (pWinPriv->hWnd == NULL); + if (pWinPriv->fWglUsed) + { + /* We do not need to destroy the window but to reparent it and move it to the + correct place when it is an opengl window */ + int offsetx; + int offsety; + HWND hParentWnd; + WindowPtr pParent=pWin->parent; + + while (pParent) + { + winWindowPriv(pParent); + hParentWnd=pWinPriv->hWnd; + if (hParentWnd) + break; + pParent=pParent->parent; + } + + if (pParent) + { + offsetx=pParent->drawable.x; + offsety=pParent->drawable.y; + } + else + { + offsetx=0; + offsety=0; + } + winDebug ("-winUpdateWindowsWindow: %x changing parent to %x and moving to %d,%d\n",pWinPriv->hWnd,hParentWnd,pWin->drawable.x-offsetx,pWin->drawable.y-offsety); + SetParent(pWinPriv->hWnd,hParentWnd); + SetWindowPos(pWinPriv->hWnd,NULL,pWin->drawable.x-offsetx,pWin->drawable.y-offsety,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW); + } + else + { + /* Destroy the Windows window if its parents are destroyed */ + /* First check if we need to release the DC when it is an opengl window */ + winDestroyWindowsWindow (pWin); + assert (pWinPriv->hWnd == NULL); + } } #if CYGMULTIWINDOW_DEBUG - ErrorF ("-winUpdateWindowsWindow\n"); + winDebug ("-winUpdateWindowsWindow\n"); #endif } @@ -731,7 +740,7 @@ winGetWindowID (WindowPtr pWin) FindClientResourcesByType (c, RT_WINDOW, winFindWindow, &wi); #if CYGMULTIWINDOW_DEBUG - ErrorF ("winGetWindowID - Window ID: %d\n", wi.id); + winDebug ("winGetWindowID - Window ID: %d\n", wi.id); #endif return wi.id; @@ -769,17 +778,13 @@ winReorderWindowsMultiWindow (void) DWORD dwCurrentProcessID = GetCurrentProcessId (); DWORD dwWindowProcessID = 0; -#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG - winTrace ("winReorderWindowsMultiWindow\n"); -#endif + winDebug ("winReorderWindowsMultiWindow\n"); if (fRestacking) { /* It is a recusive call so immediately exit */ -#if CYGWINDOWING_DEBUG - ErrorF ("winReorderWindowsMultiWindow - " + winDebug ("winReorderWindowsMultiWindow - " "exit because fRestacking == TRUE\n"); -#endif return; } fRestacking = TRUE; @@ -837,9 +842,7 @@ winMinimizeWindow (Window id) winPrivScreenPtr pScreenPriv = NULL; winScreenInfo *pScreenInfo = NULL; -#if CYGWINDOWING_DEBUG - ErrorF ("winMinimizeWindow\n"); -#endif + winDebug ("winMinimizeWindow\n"); dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess); if (!pWin) @@ -852,7 +855,7 @@ winMinimizeWindow (Window id) if (pScreen) pScreenPriv = winGetScreenPriv(pScreen); if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; -#ifdef XWIN_MULTIWINDOWEXTWM +#ifdef XWIN_MULTIWINDOWINTWM if (pScreenPriv && pScreenInfo->fInternalWM) { pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); @@ -881,9 +884,8 @@ winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt, ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); -#if CYGWINDOWING_DEBUG - ErrorF ("CopyWindowMultiWindow\n"); -#endif + winDebug ("CopyWindowMultiWindow\n"); + WIN_UNWRAP(CopyWindow); (*pScreen->CopyWindow)(pWin, oldpt, oldRegion); WIN_WRAP(CopyWindow, winCopyWindowMultiWindow); @@ -900,9 +902,7 @@ winMoveWindowMultiWindow (WindowPtr pWin, int x, int y, ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); -#if CYGWINDOWING_DEBUG - ErrorF ("MoveWindowMultiWindow to (%d, %d)\n", x, y); -#endif + winDebug ("MoveWindowMultiWindow to (%d, %d)\n", x, y); WIN_UNWRAP(MoveWindow); (*pScreen->MoveWindow)(pWin, x, y, pSib, kind); @@ -920,9 +920,8 @@ winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w, ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); -#if CYGWINDOWING_DEBUG - ErrorF ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h); -#endif + winDebug ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h); + WIN_UNWRAP(ResizeWindow); (*pScreen->ResizeWindow)(pWin, x, y, w, h, pSib); WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow); @@ -952,15 +951,11 @@ winAdjustXWindow (WindowPtr pWin, HWND hwnd) #define WIDTH(rc) (rc.right - rc.left) #define HEIGHT(rc) (rc.bottom - rc.top) -#if CYGWINDOWING_DEBUG - ErrorF ("winAdjustXWindow\n"); -#endif + winDebug ("winAdjustXWindow\n"); if (IsIconic (hwnd)) { -#if CYGWINDOWING_DEBUG - ErrorF ("\timmediately return because the window is iconized\n"); -#endif + winDebug ("\timmediately return because the window is iconized\n"); /* * If the Windows window is minimized, its WindowRect has * meaningless values so we don't adjust X window to it. @@ -976,34 +971,26 @@ winAdjustXWindow (WindowPtr pWin, HWND hwnd) x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN); y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN); SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height); -#ifdef CYGMULTIWINDOW_DEBUG winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); -#endif dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE); dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE); -#ifdef CYGMULTIWINDOW_DEBUG winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle); -#endif AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle); /* The source of adjust */ GetWindowRect (hwnd, &rcWin); -#ifdef CYGMULTIWINDOW_DEBUG winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", rcWin.left, rcWin.top, rcWin.right, rcWin.bottom, rcWin.right - rcWin.left, rcWin.bottom - rcWin.top); winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom, rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top); -#endif if (EqualRect (&rcDraw, &rcWin)) { /* Bail if no adjust is needed */ -#if CYGWINDOWING_DEBUG - ErrorF ("\treturn because already adjusted\n"); -#endif + winDebug ("\treturn because already adjusted\n"); return 0; } @@ -1023,10 +1010,8 @@ winAdjustXWindow (WindowPtr pWin, HWND hwnd) vlist[1] = pDraw->y + dY - wBorderWidth(pWin); vlist[2] = pDraw->width + dW; vlist[3] = pDraw->height + dH; -#if CYGWINDOWING_DEBUG - ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1], + winDebug ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1], vlist[2], vlist[3]); -#endif return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin)); |