This is the mail archive of the
mailing list for the Cygwin XFree86 project.
Re: XRaiseWindow for activating windows in multiwindow mode
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: cygwin-xfree at cygwin dot com
- Cc: oschmidt-mailinglists at gmx dot de
- Date: Sat, 03 Sep 2011 20:01:50 +0100
- Subject: Re: XRaiseWindow for activating windows in multiwindow mode
- References: <4E46C4CE.email@example.com>
- Reply-to: cygwin-xfree <cygwin-xfree at cygwin dot com>
- Reply-to: cygwin-xfree at cygwin dot com
On 13/08/2011 19:39, Oliver Schmidt wrote:
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.
Thanks for looking into this, and for the patch.
There definitely are some problems in this area, but I'm not sure this is the
'correct' fix, though.
The code as it stands is the product of some ... erm ... historical compromises.
If I am reading the code correctly, it looks like currently no attempt is made
to synchronize changes in the X window Z-order (e.g. made by XRaiseWindow())
to the native Windows window Z-order, and the comment in  seems to bear
this out. The code which perhaps would do this is in the disabled branch of
the #if/#else/#endif in winRestackWindowMultiWindow()
The relevant thread seems to be  and the relevant change seems to be ,
but I can't reconstruct the reasoning behind it.
As discussed in the thread  various scenarios, e.g. AOT windows, native
windows interleaved with X windows in the native Z order, Windows with
focus-follows-mouse enabled via TweakUI all need testing after trying to fix
this, to ensure you haven't regressed them.
It would be nice if this feature could be integrated into future
versions of the Cygwin X Server.
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 956a9a5..22390b3 100644
@@ -465,6 +465,7 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
HWND hWnd = NULL;
+ static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
I'd like this patch more if you said why recursive calls can occur, and why
they must be avoided.
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");
+ fRestacking = TRUE;
+ if (isToplevelWindow(pWin)&& pWin->prevSib == NULL)
@@ -538,6 +556,8 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
+ fRestacking = FALSE;
Volunteer Cygwin/X X Server maintainer
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html