This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

XRaiseWindow for activating windows in multiwindow mode


as reported in

windows are not raised from the Cygwin X Server in multiwindow
mode, if a program wants to programmatically activate a window.

I played around and figured out that the problem can be solved by 
invoking the windows function SetForegroundWindow if a top level 
window is to be restacked and has no previous sibling.

I enclose the patch in this email. It works fine for me, but 
I'm not sure if it has any side effects for other configurations 
or usage patterns.

It would be nice if this feature could be integrated into future
versions of the Cygwin X Server.

Best regards,

diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 956a9a5..22390b3 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -465,6 +465,7 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
   HWND			hInsertAfter;
   HWND                  hWnd = NULL;
+  static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
   ScreenPtr		pScreen = pWin->drawable.pScreen;
@@ -472,10 +473,27 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
   winTrace ("winRestackMultiWindow - %08x\n", pWin);
+  if (fRestacking)
+    {
+      /* It is a recusive call so immediately exit */
+      ErrorF ("winRestackWindowMultiWindow - "
+	      "exit because fRestacking == TRUE\n");
+      return;
+    }
+  fRestacking = TRUE;
    if (pScreen->RestackWindow) 
      (*pScreen->RestackWindow)(pWin, pOldNextSib);
    WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
+  if (isToplevelWindow(pWin) && pWin->prevSib == NULL)
+    {
+      winWindowPriv(pWin);
+      SetForegroundWindow(pWinPriv->hWnd);
+    }
 #if 1
@@ -538,6 +556,8 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
 		0, 0,
+  fRestacking = FALSE;
 static void

Attachment: patch.txt
Description: Text document

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]