Subject: xsrc/8136: recovering from grabby X applications
To: None <gnats-bugs@gnats.netbsd.org>
From: Charles M. Hannum <root@ihack.net>
List: netbsd-bugs
Date: 08/02/1999 12:55:17
>Number:         8136
>Category:       xsrc
>Synopsis:       recovering from grabby X applications
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    xsrc-manager (NetBSD X11 bug manager)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug  2 12:50:01 1999
>Last-Modified:
>Originator:     Charles M. Hannum
>Organization:
        Internetwork Hacker
>Release:        all
>Environment:
        n/a


>Description:
	One of the more common application failures these days is for
	an application (e.g. Netscape Communicator) to wedge while it
	has the keyboard and/or mouse grabbed (e.g. because a menu or
	modal dialog box is being displayed).  On major vendor systems
	(i.e. without virtual terminals) it is sometimes impossible to
	recover from this without rebooting the machine, or at least
	killing the X server -- and it is always annoying.

	I have decided to add another panic button (a la
	Ctrl-Alt-BackSpace), which terminates connections to any
	clients which currently have an active GrabServer,
	GrabKeyboard, or GrabPointer.  The choice of key sequence, and
	the exact implementation are negotiable, but I think this is a
	handy feature to have.

>How-To-Repeat:
        Run Communicator for a while.  You're bound to lose at some
	point.

>Fix:
	This patch has also been sent to xfree86@xfree86.org.

-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----
Index: dix/dispatch.c
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/dix/dispatch.c,v
retrieving revision 1.1.1.2
diff -c -2 -r1.1.1.2 dispatch.c
*** dispatch.c	1997/06/30 12:53:53	1.1.1.2
--- dispatch.c	1999/08/02 19:32:58
***************
*** 66,69 ****
--- 66,70 ----
  #include "swapreq.h"
  #include "dixevents.h"
+ #include "inputstr.h"
  #ifdef XCSECURITY
  #define _SECURITY_SERVER
***************
*** 3953,3955 ****
--- 3954,3972 ----
  {
      client->noClientException = -1;
+ }
+ 
+ void
+ KillGrabbers()
+ {
+     extern InputInfo inputInfo;
+     ClientPtr client;
+ 
+     if (grabState != GrabNone)
+         CloseDownClient(grabClient);
+     if (inputInfo.pointer->grab && 
+         (client = LookupClient(inputInfo.pointer->grab->resource, NullClient)))
+         CloseDownClient(client);
+     if (inputInfo.keyboard->grab &&
+         (client = LookupClient(inputInfo.keyboard->grab->resource, NullClient)))
+         CloseDownClient(client);
  }
Index: hw/xfree86/common/xf86Events.c
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v
retrieving revision 1.3
diff -c -2 -r1.3 xf86Events.c
*** xf86Events.c	1999/01/20 10:10:27	1.3
--- xf86Events.c	1999/08/02 19:32:59
***************
*** 694,697 ****
--- 694,701 ----
  	break;
  	
+       case KEY_KP_Multiply:
+ 	KillGrabbers();
+ 	return;
+ 
  	/*
  	 * The idea here is to pass the scancode down to a list of
-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----

>Audit-Trail:
>Unformatted: