aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwindow.c')
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winmultiwindowwindow.c270
1 files changed, 125 insertions, 145 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 44ad19302..94956863b 100644..100755
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -83,7 +83,7 @@ winInitMultiWindowClass(void)
wcx.hIconSm = hIconSmall;
#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);
@@ -104,7 +104,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);
@@ -137,7 +137,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);
@@ -175,30 +175,29 @@ winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
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", x, y);
-#endif
+ winDebug ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", x, y);
/* 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;
}
@@ -219,7 +218,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
@@ -237,37 +236,41 @@ 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);
+ 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;
@@ -285,9 +288,7 @@ winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask)
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);
@@ -315,7 +316,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);
@@ -346,7 +347,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);
@@ -398,76 +399,23 @@ 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
}
/*
@@ -502,15 +450,36 @@ 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;
-
- if ((iY < GetSystemMetrics(SM_YVIRTUALSCREEN)) ||
- (iY > GetSystemMetrics(SM_CYVIRTUALSCREEN)))
- iY = 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;
+ }
+
+ 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,
@@ -577,16 +546,20 @@ winCreateWindowsWindow(WindowPtr pWin)
}
pWinPriv->hWnd = hWnd;
+ /* 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);
@@ -670,7 +643,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 */
@@ -689,13 +662,44 @@ winUpdateWindowsWindow(WindowPtr pWin)
UpdateWindow(pWinPriv->hWnd);
}
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
}
@@ -713,7 +717,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;
@@ -748,16 +752,12 @@ 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;
@@ -809,9 +809,7 @@ winMinimizeWindow(Window id)
ScreenPtr pScreen = NULL;
winPrivScreenPtr pScreenPriv = NULL;
-#if CYGWINDOWING_DEBUG
- ErrorF("winMinimizeWindow\n");
-#endif
+ winDebug("winMinimizeWindow\n");
dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
DixUnknownAccess);
@@ -824,7 +822,7 @@ winMinimizeWindow(Window id)
if (pScreen)
pScreenPriv = winGetScreenPriv(pScreen);
-#ifdef XWIN_MULTIWINDOWEXTWM
+#ifdef XWIN_MULTIWINDOWINTWM
if (pScreenPriv && pScreenPriv->pScreenInfo->fInternalWM) {
pRLWinPriv =
(win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
@@ -852,9 +850,8 @@ winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt, RegionPtr oldRegion)
winScreenPriv(pScreen);
-#if CYGWINDOWING_DEBUG
- ErrorF("CopyWindowMultiWindow\n");
-#endif
+ winDebug("CopyWindowMultiWindow\n");
+
WIN_UNWRAP(CopyWindow);
(*pScreen->CopyWindow) (pWin, oldpt, oldRegion);
WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
@@ -871,9 +868,7 @@ winMoveWindowMultiWindow(WindowPtr pWin, int x, int y,
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);
@@ -891,9 +886,8 @@ winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w,
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);
@@ -922,14 +916,10 @@ 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.
@@ -945,34 +935,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;
}
@@ -992,10 +974,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],
- vlist[2], vlist[3]);
-#endif
+ winDebug("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
+ vlist[2], vlist[3]);
return ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight,
vlist, wClient(pWin));