andy@lgc.COM (01/13/91)
uunet!sting.berkeley.edu!scott (Scott Silvey) writes: > Basically, on a ButtonPress event, I want to start tracking the mouse by > installing a PointerMotion event handler. Unfortionately, the PointerMotion > handler doesn't actually get registered ... annoying as hell. The problem here is the implicit pointer grab that the server starts when the pointer button goes down (see 8.4.1.1 of the Scheifler/Gettys/Newman book). That grab selects for those pointer events that you were already selected for when the button went down. Changes made with XSelectInput (via XtAddEventHandler) while the button is still down don't take effect until the button is released, which is not what you want. I think if you call XChangeActivePointerGrab in your button press event handler with a mask that includes PointerMotionMask and ButtonReleaseMask, your problem will go away (but I haven't actually run the test). Andy Dysart (andy@lgc.com) Landmark Graphics Corp. Tel: (713) 579-4762 Houston, TX 77094 Fax: (713) 579-4814
rws@expo.lcs.mit.EDU (Bob Scheifler) (01/13/91)
The problem here is the implicit pointer grab that the server starts when the pointer button goes down (see 8.4.1.1 of the Scheifler/Gettys/Newman book). Good work! I was just about to send a message saying the same thing. I think if you call XChangeActivePointerGrab in your button press event handler with a mask that includes PointerMotionMask and ButtonReleaseMask, your problem will go away (but I haven't actually run the test). I have. To do it right, you should also specify the time from the event in the call: ... XtAddEventHandler(canvas, PointerMotionMask, FALSE, motion, NULL); XChangeActivePointerGrab(XtDisplay(canvas), PointerMotionMask|ButtonReleaseMask, None, evt->xbutton.time);
scott@graft.Berkeley.EDU (Scott Silvey) (01/15/91)
rws@expo.lcs.mit.EDU (Bob Scheifler) writes: |>> I think if you call XChangeActivePointerGrab in your button press |>> event handler with a mask that includes PointerMotionMask and |>> ButtonReleaseMask, your problem will go away (but I haven't actually |>> run the test). |> |> I have. To do it right, you should also specify the time from the event in |> the call: |> ... |> XtAddEventHandler(canvas, PointerMotionMask, FALSE, motion, NULL); |> XChangeActivePointerGrab(XtDisplay(canvas), |> PointerMotionMask|ButtonReleaseMask, |> None, evt->xbutton.time); Thank you gentlemen for your prompt replies. This indeed corrects the problem. This seems a rather obscure fix to me (although I see why it is necessary). Is it an oversight that XtAddEventHandler doesn't already make this call? Or was it a design decision to omit it because XtAddEventHandler would then have to do specialized work based on the event mask it was called with? /-----------------------------------------------------------------------------\ | Scott Silvey | Bumper Sticker seen in ( VERY liberal ) Berkeley: | | scott@xcf.berkeley.edu | | | Flames to /dev/null. | "US OUT OF NORTH AMERICA!" | \-----------------------------------------------------------------------------/