[comp.windows.x] Active grabs by X11 server on ButtonPress events

mao@blia.BLI.COM (Mike Olson) (10/11/88)

In an Xlib application (X11R2), when the user presses a mouse button down in
some window that wants the event, the server does the following:

	a) queues the ButtonPress event for delivery to the client.
	b) issues a GrabPointer on behalf of the client for the window that
	   received the ButtonPress event.

I have no quarrel with action (a), and understand why action (b) is taken.
It makes it much easier to guarantee that the same window that received the
ButtonPress also receives the ButtonRelease, if the mouse moves outside the
window in the meantime.  I don't think you could really argue that grabbing
the pointer on behalf of the client is the responsibility of the server; that
behavior belongs in the client, but I do understand why it's done.

My question is this:  is there any way to stop the server from doing the grab?
We have some special circumstances that make it inconvenient.

We're doing top-down event dispatching for applications, using a library
developed here.  Top-down is a *major* win for us in every way but this,
and using a bottom-up dispatcher is out of the question.

Here's the story:

	+ A top-level "application" window is created, with an event loop
	  and some menus and other special knowledge built into it.

	+ The application window gets some children.  The children let the
	  application window know what events they want; the application
	  window does XSelectInput on those events for itself, and keeps
	  track of the interest of the children.

	+ When a mouse button is pressed, the server reports the event to
	  the application window.  It issues a grab on behalf of the
	  application window, even though the pointer is (almost always)
	  inside one of the child windows.  (The application window uses
	  a stupid geometry lookup routine to decide who gets the event).

	+ The grab causes a LeaveNotify event to be posted to the child,
	  even though it still contains the pointer.

It would be best for us to inhibit the grab by the server.  It would be okay
if we could just keep the server from posting the LeaveNotify to the child.
We need a solution that will work one hundred percent of the time.

I suspect the people at CMU who did Andrew have dealt with this before; they
do top-down dispatching, and are doing some of the same things we are.  If
anyone has any idea about a way to fix this problem, I'd like to hear about
it.  Send me email, and I'll summarize, if interest warrants it.

					mike olson
					britton lee, inc.
					...!ucbvax!mtxinu!blia!mao