This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
Re: Removing focus from X
- From: "Gerald S. Williams" <gsw at agere dot com>
- To: <cygwin-xfree at cygwin dot com>
- Date: Thu, 14 Nov 2002 16:30:39 -0500
- Subject: Re: Removing focus from X
- Reply-to: cygwin-xfree at cygwin dot com
Thanks Harold, that change to win.h did the trick. Too bad
my patch didn't work as well. :-(
As per Harold's advice, I added a call to XCloseDisplay().
Here is the revised (still crude) patch to winwndproc.c:
Index: winwndproc.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xwin/winwndproc.c,v
retrieving revision 1.23
diff -u -1 -0 -r1.23 winwndproc.c
--- winwndproc.c 2002/10/17 08:18:25 1.23
+++ winwndproc.c 2002/11/14 21:19:55
@@ -29,20 +29,44 @@
* Suhaib M Siddiqi
* Peter Busch
* Harold L Hunt II
* MATSUZAKI Kensuke
*/
/* $XFree86: xc/programs/Xserver/hw/xwin/winwndproc.c,v 1.23 2002/10/17 08:18:25 alanh Exp $ */
#include "win.h"
#include <commctrl.h>
+#define KILL_FOCUS_ENHANCEMENT 1
+#if KILL_FOCUS_ENHANCEMENT
+
+#define INCLUDE_XLIB_WORKAROUND 1
+#if INCLUDE_XLIB_WORKAROUND
+typedef void Display;
+
+extern Display *XOpenDisplay(
+ const char* /* display_name */
+);
+
+extern void XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+extern int XCloseDisplay(
+ Display* /* display */
+);
+#endif /* INCLUDE_XLIB_WORKAROUND */
+#endif /* KILL_FOCUS_ENHANCEMENT */
+
BOOL CALLBACK
winChangeDepthDlgProc (HWND hDialog, UINT message,
WPARAM wParam, LPARAM lParam);
/*
* Called by winWakeupHandler
* Processes current Windows message
*/
@@ -831,20 +855,34 @@
case WM_KILLFOCUS:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
/* Store the state of all mode keys */
winStoreModeKeyStates (s_pScreen);
/* Release any pressed keys */
winKeybdReleaseKeys ();
+
+#if KILL_FOCUS_ENHANCEMENT
+ /* Remove focus from all X windows (crude implementation) */
+ {
+ Display *display = XOpenDisplay(NULL);
+
+ if (display)
+ {
+ /* Revert is ignored... */
+ XSetInputFocus(display,None,RevertToNone,CurrentTime);
+ XCloseDisplay(display);
+ }
+ }
+#endif /* KILL_FOCUS_ENHANCEMENT */
return 0;
#if WIN_NEW_KEYBOARD_SUPPORT
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
case WM_SYSKEYUP:
case WM_KEYUP:
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
===============================
However, in -rootless mode, the patch doesn't seem to make
any difference. And without -rootless, all of X seems to
hang as soon as I launch wmaker (I'm using WindowMaker as
my current window manager).
I realize that the patch needs cleaning up, but I wasn't
expecting the results I saw. Any thoughts?
-Jerry