aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwindow.c')
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c219
1 files changed, 74 insertions, 145 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 038f9497f..c318f77ad 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -47,7 +47,7 @@
extern HICON g_hIconX;
extern HICON g_hSmallIconX;
extern HWND g_hDlgDepthChange;
-extern Bool g_fNativeGl;
+extern Bool g_fNativeGl;
/*
* Prototypes for local functions
@@ -88,7 +88,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);
@@ -108,7 +108,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);
@@ -118,6 +118,7 @@ winCreateWindowMultiWindow (WindowPtr pWin)
/* Initialize some privates values */
pWinPriv->hRgn = NULL;
pWinPriv->hWnd = NULL;
+ pWinPriv->GlCtxWnd = FALSE;
pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
pWinPriv->fXKilled = FALSE;
@@ -138,7 +139,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,32 +176,26 @@ 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");
return fResult;
}
@@ -221,7 +216,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
@@ -239,30 +234,26 @@ 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 */
+
+ /* Change the position and dimensions of the Windows window */
MoveWindow (hWnd,
rcNew.left, rcNew.top,
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
@@ -270,9 +261,7 @@ winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
}
else
{
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winPositionWindowMultiWindow - Not need to move\n");
-#endif
+ winDebug ("winPositionWindowMultiWindow - Not need to move\n");
}
return fResult;
@@ -290,9 +279,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);
@@ -320,7 +307,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);
@@ -351,7 +338,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);
@@ -383,7 +370,7 @@ winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winReparentMultiWindow - pWin: %08x\n", pWin);
+ winDebug ("winReparentMultiWindow - pWin: %08x\n", pWin);
#endif
WIN_UNWRAP(ReparentWindow);
@@ -403,85 +390,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
}
@@ -503,12 +427,13 @@ winCreateWindowsWindow (WindowPtr pWin)
winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
WinXSizeHints hints;
WindowPtr pDaddy;
+ DWORD dwStyle;
+ DWORD dwExStyle;
+ RECT rc;
winInitMultiWindowClass();
-#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
-#endif
+ winDebug ("winCreateWindowsWindow - pWin: %08x\n", pWin);
iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
@@ -547,10 +472,24 @@ winCreateWindowsWindow (WindowPtr pWin)
/* Create the window */
/* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
/* CW_USEDEFAULT, change back to popup after creation */
- hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+
+ dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ dwExStyle = WS_EX_TOOLWINDOW;
+ rc;
+ rc.top = 0;
+ rc.left = 0;
+ rc.bottom = iHeight;
+ rc.right = iWidth;
+ AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
+ iHeight = rc.bottom - rc.top;
+ iWidth = rc.right - rc.left;
+
+ winDebug("winCreateWindowsWindow - window size %dx%d\n", iWidth, iHeight);
+
+ hWnd = CreateWindowExA (dwExStyle, /* Extended styles */
WINDOW_CLASS_X, /* Class name */
WINDOW_TITLE_X, /* Window name */
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ dwStyle, /* Styles */
iX, /* Horizontal position */
iY, /* Vertical position */
iWidth, /* Right edge */
@@ -571,6 +510,10 @@ 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 */
+ if ((iX == CW_USEDEFAULT) || (iY == 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,
@@ -602,9 +545,11 @@ winDestroyWindowsWindow (WindowPtr pWin)
MSG msg;
winWindowPriv(pWin);
BOOL oldstate = winInDestroyWindowsWindow;
+ HICON hIcon;
+ HICON hIconSm;
#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winDestroyWindowsWindow\n");
+ winDebug ("winDestroyWindowsWindow\n");
#endif
/* Bail out if the Windows window handle is invalid */
@@ -613,6 +558,10 @@ winDestroyWindowsWindow (WindowPtr pWin)
winInDestroyWindowsWindow = TRUE;
+ /* Store the info we need to destroy after this window is gone */
+ hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
+ hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
+
SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
/* Destroy the Windows window */
DestroyWindow (pWinPriv->hWnd);
@@ -620,6 +569,10 @@ winDestroyWindowsWindow (WindowPtr pWin)
/* Null our handle to the Window so referencing it will cause an error */
pWinPriv->hWnd = NULL;
+ /* Destroy any icons we created for this window */
+ winDestroyIcon(hIcon);
+ winDestroyIcon(hIconSm);
+
/* Process all messages on our queue */
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
@@ -632,7 +585,7 @@ winDestroyWindowsWindow (WindowPtr pWin)
winInDestroyWindowsWindow = oldstate;
#if CYGMULTIWINDOW_DEBUG
- ErrorF ("-winDestroyWindowsWindow\n");
+ winDebug ("-winDestroyWindowsWindow\n");
#endif
}
@@ -649,7 +602,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 */
@@ -678,7 +631,7 @@ winUpdateWindowsWindow (WindowPtr pWin)
}
#if CYGMULTIWINDOW_DEBUG
- ErrorF ("-winUpdateWindowsWindow\n");
+ winDebug ("-winUpdateWindowsWindow\n");
#endif
}
@@ -697,7 +650,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;
@@ -735,17 +688,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;
@@ -803,9 +752,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)
@@ -847,9 +794,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);
@@ -866,9 +812,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);
@@ -886,9 +830,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);
@@ -918,15 +861,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.
@@ -942,34 +881,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;
}
@@ -989,10 +920,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));