summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-01-11 21:06:57 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-01-15 13:48:52 +0000
commite34038e67dd8e0290b84e78a350d5ec725699bb4 (patch)
treea99959174eb99a1fa9c1988098f55e33f727c8fe
parent52308bfe807fa3bed76129ca052701a79f52b93c (diff)
Delete and start again
Delete all the historical crap for dealing with window activation and raising. Let's start again, but this time with a clue :-) Describe WM_ACTIVATE WM_SETFOCUS and XSetInputFocus XRaiseWindow here Fixes to winRestackWindowMultiWindow(): - Don't implicity WM_ACTIVATE if we restack to top - Correct logic checking for an X-window above us which has an associated HWND Just do a full X restack on WM_WINDOWPOSCHANGED. Reliably converting the hWndInsertAfter that is given to the X window to restack after is hard (and we didn't even try to do it right except when we ended up topmost) Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--hw/xwin/winmultiwindowwindow.c102
-rw-r--r--hw/xwin/winmultiwindowwm.c77
-rw-r--r--hw/xwin/winmultiwindowwndproc.c95
-rw-r--r--hw/xwin/winwin32rootlesswndproc.c7
4 files changed, 59 insertions, 222 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 2329d163e..14590109b 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -395,85 +395,80 @@ 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;
+ winWindowPriv(pWin);
winScreenPriv(pScreen);
-#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
- winTrace ("winRestackMultiWindow - %08x\n", pWin);
-#endif
-
WIN_UNWRAP(RestackWindow);
- if (pScreen->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
+ Ignore spurious calls made if ROOTLESS is defined, as there is
+ nothing to do if the window is already in the right place
+ */
+ if (pWin->nextSib == pOldNextSib)
+ return;
+
+ winDebug ("winRestackMultiWindow: pWin %08x XID %08x\n", pWin, pWin->drawable.id);
+#if 1
+ winDebug ("winRestackMultiWindow: old next sib pWin %08x XID %08x\n", pOldNextSib, pOldNextSib ? pOldNextSib->drawable.id : 0);
+ winDebug ("winRestackMultiWindow: new next sib pWin %08x XID %08x\n", pWin->nextSib, pWin->nextSib ? pWin->nextSib->drawable.id : 0);
+#endif
+
/* 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
+ * Look for a previous sibling window with
* valid privates and window handle
*/
+ pPrevWin = pWin;
+
+ do
+ {
+ pPrevWin = pPrevWin->prevSib;
+#if 0
+ if (pPrevWin)
+ {
+ winDebug ("winRestackMultiWindow: pPrevWin %08x, XID %08x\n", pPrevWin, pPrevWin->drawable.id);
+ winDebug ("winRestackMultiWindow: has winPriv %08x hwnd %08x\n", winGetWindowPriv(pPrevWin), winGetWindowPriv(pPrevWin) ? (winGetWindowPriv(pPrevWin)->hWnd) : 0);
+ }
+#endif
+ }
while (pPrevWin
- && !winGetWindowPriv(pPrevWin)
- && !winGetWindowPriv(pPrevWin)->hWnd)
- pPrevWin = pPrevWin->prevSib;
-
+ && !(winGetWindowPriv(pPrevWin) && winGetWindowPriv(pPrevWin)->hWnd));
+
+ /* Stop if pPrevWin == NULL, or winGetWindowPriv(pPrevWin) exists and is not NULL */
+
/* 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);
+ assert(hInsertAfter != HWND_TOP);
}
else
{
/* No valid sibling - make this window the top window */
hInsertAfter = HWND_TOP;
- uFlags = SWP_NOMOVE | SWP_NOSIZE;
}
-
+
+#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
+ winDebug ("winRestackMultiWindow: hwnd %08x hwndInsertAfter %08x\n",
+ pWinPriv->hWnd, hInsertAfter);
+#endif
+
/* Perform the restacking operation in Windows */
SetWindowPos (pWinPriv->hWnd,
hInsertAfter,
0, 0,
0, 0,
- uFlags);
-#endif
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
@@ -611,8 +606,6 @@ winCreateWindowsWindow (WindowPtr pWin)
(*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
}
-
-Bool winInDestroyWindowsWindow = FALSE;
/*
* winDestroyWindowsWindow - Destroy a Windows window associated
* with an X window
@@ -622,7 +615,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
{
MSG msg;
winWindowPriv(pWin);
- BOOL oldstate = winInDestroyWindowsWindow;
HICON hIcon;
HICON hIconSm;
@@ -632,8 +624,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
if (pWinPriv->hWnd == NULL)
return;
- 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);
@@ -664,8 +654,6 @@ winDestroyWindowsWindow (WindowPtr pWin)
}
}
- winInDestroyWindowsWindow = oldstate;
-
winDebug("winDestroyWindowsWindow - done\n");
}
@@ -755,7 +743,9 @@ winFindWindow (pointer value, XID id, pointer cdata)
/*
- * winReorderWindowsMultiWindow -
+ * winReorderWindowsMultiWindow -
+ *
+ * Re-order the X windows so their order follows the native Window order
*/
void
@@ -798,11 +788,11 @@ winReorderWindowsMultiWindow (void)
{
pWinSib = pWin;
pWin = GetProp (hwnd, WIN_WINDOW_PROP);
-
+
if (!pWinSib)
{ /* 1st window - raise to the top */
vlist[0] = Above;
-
+
ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
}
else
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 85ad19928..1b9e5d27a 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -194,11 +194,6 @@ winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
static void
winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
-#if 0
-static void
-PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction);
-#endif
-
static Bool
CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM);
@@ -615,74 +610,6 @@ UpdateName (WMInfoPtr pWMInfo, Window iWindow)
}
-#if 0
-/*
- * Fix up any differences between the X11 and Win32 window stacks
- * starting at the window passed in
- */
-static void
-PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
-{
- Atom atmType;
- int fmtRet;
- unsigned long items, remain;
- HWND hWnd, *retHwnd;
- DWORD myWinProcID, winProcID;
- Window xWindow;
- WINDOWPLACEMENT wndPlace;
-
- hWnd = NULL;
- /* See if we can get the cached HWND for this window... */
- if (XGetWindowProperty (pWMInfo->pDisplay,
- iWindow,
- pWMInfo->atmPrivMap,
- 0,
- 1,
- False,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- &atmType,
- &fmtRet,
- &items,
- &remain,
- (unsigned char **) &retHwnd) == Success)
- {
- if (retHwnd)
- {
- hWnd = *retHwnd;
- XFree (retHwnd);
- }
- }
-
- if (!hWnd) return;
-
- GetWindowThreadProcessId (hWnd, &myWinProcID);
- hWnd = GetNextWindow (hWnd, direction);
-
- while (hWnd) {
- GetWindowThreadProcessId (hWnd, &winProcID);
- if (winProcID == myWinProcID)
- {
- wndPlace.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement (hWnd, &wndPlace);
- if ( !(wndPlace.showCmd==SW_HIDE ||
- wndPlace.showCmd==SW_MINIMIZE) )
- {
- xWindow = (Window)GetProp (hWnd, WIN_WID_PROP);
- if (xWindow)
- {
- if (direction==GW_HWNDPREV)
- XRaiseWindow (pWMInfo->pDisplay, xWindow);
- else
- XLowerWindow (pWMInfo->pDisplay, xWindow);
- }
- }
- }
- hWnd = GetNextWindow(hWnd, direction);
- }
-}
-#endif /* PreserveWin32Stack */
-
-
/*
* winMultiWindowWMProc
*/
@@ -747,9 +674,7 @@ winMultiWindowWMProc (void *pArg)
#endif
/* Raise the window */
XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
-#if 0
- PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV);
-#endif
+
break;
case WM_WM_LOWER:
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 454dd5fa9..db841b345 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -266,23 +266,6 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
return TRUE;
}
-extern Bool winInDestroyWindowsWindow;
-static Bool winInRaiseWindow = FALSE;
-static void winRaiseWindow(WindowPtr pWin)
-{
- if (!winInDestroyWindowsWindow && !winInRaiseWindow)
- {
- BOOL oldstate = winInRaiseWindow;
- XID vlist[1] = { 0 };
- winInRaiseWindow = TRUE;
- /* Call configure window directly to make sure it gets processed
- * in time
- */
- ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
- winInRaiseWindow = oldstate;
- }
-}
-
static
void winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
{
@@ -706,8 +689,15 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
/* Add the keyboard hook if possible */
if (g_fKeyboardHookLL)
g_fKeyboardHookLL = winInstallKeyboardHookLL ();
+
+ /* Tell our Window Manager thread to XSetInputFocus the X window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+
return 0;
-
+
case WM_KILLFOCUS:
/* Pop any pressed keys since we are losing keyboard focus */
winKeybdReleaseKeys ();
@@ -803,26 +793,6 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
/* Pass the message to the root window */
SendMessage (hwndScreen, message, wParam, lParam);
- if (LOWORD(wParam) != WA_INACTIVE)
- {
- /* Raise the window to the top in Z order */
- /* ago: Activate does not mean putting it to front! */
- /*
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- */
-
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized)
- if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
- /* Prevent the mouse wheel from stalling when another window is minimized */
- if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
- (HWND)lParam != NULL && (HWND)lParam != (HWND)GetParent(hwnd))
- SetFocus(hwnd);
return 0;
case WM_ACTIVATEAPP:
@@ -963,56 +933,15 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
#if CYGWINDOWING_DEBUG
winDebug ("\twindow z order was changed\n");
#endif
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
-#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
-#endif
- /* Raise the window to the top in Z order */
- winRaiseWindow(pWin);
- }
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
-#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
-#endif
- winRaiseWindow(pWin);
- }
- }
- }
+ needRestack = TRUE;
+
+ }
}
/*
* Pass the message to DefWindowProc to let the function
* break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
*/
- break;
+ break;
case WM_ENTERSIZEMOVE:
hasEnteredSizeMove = TRUE;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index c60a76cba..b8104db6c 100644
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -829,17 +829,10 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
{
if (winIsInternalWMRunning(pScreenInfo))
{
-#if 0
/* Raise the window to the top in Z order */
wmMsg.msg = WM_WM_RAISE;
if (fWMMsgInitialized)
winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
-#endif
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized)
- if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
}
winWindowsWMSendEvent(WindowsWMControllerNotify,
WindowsWMControllerNotifyMask,