From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31561 invoked by alias); 3 Sep 2011 19:02:00 -0000 Received: (qmail 31552 invoked by uid 22791); 3 Sep 2011 19:01:59 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_JMF_BR,RCVD_IN_RP_RNBL X-Spam-Check-By: sourceware.org Received: from smtpout.karoo.kcom.com (HELO smtpout.karoo.kcom.com) (212.50.160.34) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Sep 2011 19:01:45 +0000 Received: from 213-152-38-55.dsl.eclipse.net.uk (HELO [192.168.0.6]) ([213.152.38.55]) by smtpout.karoo.kcom.com with ESMTP; 03 Sep 2011 20:01:43 +0100 Message-ID: <4E62799E.2090204@dronecode.org.uk> Date: Sat, 03 Sep 2011 19:02:00 -0000 From: Jon TURNEY Reply-To: cygwin-xfree User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20110817 Thunderbird/7.0 MIME-Version: 1.0 To: cygwin-xfree@cygwin.com CC: oschmidt-mailinglists@gmx.de Subject: Re: XRaiseWindow for activating windows in multiwindow mode References: <4E46C4CE.6000206@gmx.de> In-Reply-To: <4E46C4CE.6000206@gmx.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-xfree-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-xfree-owner@cygwin.com Reply-To: cygwin-xfree@cygwin.com Mail-Followup-To: cygwin-xfree@cygwin.com X-SW-Source: 2011-09/txt/msg00000.txt.bz2 On 13/08/2011 19:39, Oliver Schmidt wrote: > as reported in > > http://www.cygwin.com/ml/cygwin-xfree/2005-06/msg00072.html > > 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 [1] 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 [2] and the relevant change seems to be [3], but I can't reconstruct the reasoning behind it. As discussed in the thread [2] 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. [1] http://sourceware.org/ml/cygwin-xfree/2004-12/msg00074.html [2] http://sourceware.org/ml/cygwin-xfree/2004-03/msg00540.html [3] http://cgit.freedesktop.org/xorg/xserver/commit/?h=CYGWIN&id=40bb4441ac7c87cfa0c62e8553c7e53b9fe4d765 > It would be nice if this feature could be integrated into future > versions of the Cygwin X Server. > > Best regards, > Oliver > > > 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; > #endif > + 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; > winScreenPriv(pScreen); > > @@ -472,10 +473,27 @@ winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib) > winTrace ("winRestackMultiWindow - %08x\n", pWin); > #endif > > + if (fRestacking) > + { > + /* It is a recusive call so immediately exit */ > +#if CYGWINDOWING_DEBUG > + ErrorF ("winRestackWindowMultiWindow - " > + "exit because fRestacking == TRUE\n"); > +#endif > + return; > + } > + fRestacking = TRUE; > + > WIN_UNWRAP(RestackWindow); > 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, > uFlags); > #endif > + > + fRestacking = FALSE; > } > > static void -- Jon TURNEY Volunteer Cygwin/X X Server maintainer -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://x.cygwin.com/docs/ FAQ: http://x.cygwin.com/docs/faq/