[PATCH 04/13] Xming: Correctly parent XA_WM_TRANSIENT_FOR windows in -multiwindow mode when a windows window is created.

Jon TURNEY jon.turney at dronecode.org.uk
Wed Jan 7 12:03:59 PST 2009


From: Colin Harrison <colin.harrison at virgin.net>

Fix internal WM to correctly parent XA_WM_TRANSIENT_FOR windows in -multiwindow mode when a windows window is created,
and to de-iconize parent windows when a child window acquires focus.

XXX: Perhaps we should also shuffle parent(s) forward through Z-order when a child acquires focus?

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 hw/xwin/winmultiwindowwindow.c  |   15 ++++++++++++++-
 hw/xwin/winmultiwindowwndproc.c |    8 ++++++++
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 6cad631..2399d5a 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -1,5 +1,6 @@
 /*
  *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
  *
  *Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -28,6 +29,7 @@
  * Authors:	Kensuke Matsuzaki
  *		Earle F. Philhower, III
  *		Harold L Hunt II
+ *              Colin Harrison
  */
 
 #ifdef HAVE_XWIN_CONFIG_H
@@ -483,6 +485,7 @@ winCreateWindowsWindow (WindowPtr pWin)
   int			iWidth;
   int			iHeight;
   HWND			hWnd;
+  HWND			hFore = NULL;
   WNDCLASSEX		wc;
   winWindowPriv(pWin);
   HICON			hIcon;
@@ -493,6 +496,7 @@ winCreateWindowsWindow (WindowPtr pWin)
   static int		s_iWindowID = 0;
   winPrivScreenPtr	pScreenPriv = pWinPriv->pScreenPriv;
   WinXSizeHints         hints;
+  WindowPtr		pDaddy;
 
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
@@ -567,6 +571,15 @@ winCreateWindowsWindow (WindowPtr pWin)
   wc.lpszClassName = pszClass;
   RegisterClassEx (&wc);
 
+    if (winMultiWindowGetTransientFor (pWin, &pDaddy))
+    {
+      if (pDaddy)
+      {
+        hFore = GetForegroundWindow();
+        if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
+      }
+    }
+
   /* Create the window */
   /* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
   /* CW_USEDEFAULT, change back to popup after creation */
@@ -578,7 +591,7 @@ winCreateWindowsWindow (WindowPtr pWin)
 			  iY,			/* Vertical position */
 			  iWidth,		/* Right edge */ 
 			  iHeight,		/* Bottom edge */
-			  (HWND) NULL,		/* No parent or owner window */
+			  hFore,		/* Null or Parent window if transient*/
 			  (HMENU) NULL,		/* No menu */
 			  GetModuleHandle (NULL), /* Instance handle */
 			  pWin);		/* ScreenPrivates */
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 8eadf45..3fc3cce 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -1,5 +1,6 @@
 /*
  *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
  *
  *Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -28,6 +29,7 @@
  * Authors:	Kensuke Matsuzaki
  *		Earle F. Philhower, III
  *		Harold L Hunt II
+ *              Colin Harrison
  */
 
 #ifdef HAVE_XWIN_CONFIG_H
@@ -655,6 +657,12 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
       if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
 	break;
 
+      {
+	/* Get the parent window for transient handling */
+	HWND hParent = GetParent(hwnd);
+	if (hParent && IsIconic(hParent)) ShowWindow (hParent, SW_RESTORE);
+      }
+
       winRestoreModeKeyStates ();
 
       /* Add the keyboard hook if possible */
-- 
1.6.0.4




More information about the xorg mailing list