[comp.windows.x] selecting ButtonPress and grabs

adrian@spike.ora.COM (Adrian Nye) (02/15/91)

> From: rory@maccs.dcss.mcmaster.ca (Rory Jacobs)
> 
> I spent the afternoon discovering that useing ButtonMotionMask
> (a mask for a MotionNotify), does not work on the sun sparcstaion
> (sun 4) I am using, when the ButtonPress event is selected!
> Is this my imagination?  The reason I wonder about this is
> O'Reilly volume one, by Adrian Nye, example code is on the system
> (came with the X window Release 4 distribution), that has both.

There was a bug in our example code, and I think it was subtle enough
that others might be interested in it.

The program creates one large window and a small subwindow.  The large 
window takes ButtonPress events to exit, and the small subwindow
draws dots whenever the pointer is moved with a button held down.  

If you select ButtonPressMask alone for the parent, and 
ButtonMotionMask alone for the child, it does not work!  The reason 
is that when the ButtonPress occurs, it propagates to the parent, and 
initiates a grab of all pointer events.  (This is an automatic grab, 
not the result of an XGrabButton or XGrabPointer call).  Since the 
parent did not select motion events, no MotionNotify events are 
received by the program.

The moral of the story is that if a parent (or any ancestor) selects 
ButtonPress events, then its children must also select ButtonPress 
events in order for the children to get any other type of pointer 
events (including MotionNotify, EnterNotify, LeaveNotify).