public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
From: Oliver Schmidt <oschmidt-mailinglists@gmx.de>
To: cygwin-xfree@cygwin.com
Subject: XRaiseWindow for activating windows in multiwindow mode
Date: Sat, 13 Aug 2011 18:39:00 -0000	[thread overview]
Message-ID: <4E46C4CE.6000206@gmx.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 2076 bytes --]

Hi,

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.

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 */
   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

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1405 bytes --]

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 */
   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


[-- Attachment #3: Type: text/plain, Size: 223 bytes --]

--
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/

             reply	other threads:[~2011-08-13 18:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-13 18:39 Oliver Schmidt [this message]
2011-09-03 19:02 ` Jon TURNEY
2011-09-04  8:52   ` Oliver Schmidt
2011-09-04  9:09     ` Oliver Schmidt
2011-09-04 11:18   ` Oliver Schmidt
2011-10-19  9:33     ` Michel Hummel
2011-10-21 10:36       ` Oliver Schmidt
2011-10-21 11:43         ` Michel Hummel
2011-10-21 12:26           ` Oliver Schmidt
2014-06-11 20:50 Patrick Herbst
2014-06-19 10:07 ` Oliver Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E46C4CE.6000206@gmx.de \
    --to=oschmidt-mailinglists@gmx.de \
    --cc=cygwin-xfree@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).