kwh@sei.cmu.edu (Kurt Hoyt) (11/19/87)
On a uVax running Ultrix 1.2 and (Xqvss X11 and fixes 1-60 (except 45)):
I want to write code to grab and move (or resize) a graphic object (i.e. a
line, rectangle, text, etc.). I have used regions to help pick the object in
conjunction with button press/release events. I now want to get motion
events while a button is down so I can move the object with some sort of
feedback until the button is released. Selecting ButtonMotionMask generates
MotionNotifys whether or not a button is pressed. Selecting
PointerMotionHintMask ONLY generates nothing. Selecting either
ButtonMotionMask or PointerMotionMask along with PointMotionHintMask will
generate one MotionNotify if the pointer moves and no buttons are pressed
and lots of MotionNotifys when any button is pressed (followed by one
MotionNotify after the button is released). XGetMotionEvents consistently
has nothing to report (called initialliy with start = 0, stop =
CurrentTime). None of this matches the documentation or what I expected.
Other selected events: ExposureMask, ButtonPressMask, ButtonReleaseMask,
KeyPressMask. Am I doing something wrong or is it time to write to xbugs?
Thanks.
--
"Not many people know this, but | Kurt Hoyt
I'm famous" | ARPA: kwh@sei.cmu.edu
-- Sam Malone | BITNET: kwh%sei.cmu.edu@cmuccvma
| CSNET: kwh%sei.cmu.edu@relay.cs.net
karlton@decwrl.UUCP (11/20/87)
You have a bug in your server if you are getting MotionNotify events when you move the mouse and have none of the mouse buttons depressed, and have selected for ButtonMotionMask and not selected for PointerMotionMask. PK
oj@apollo.UUCP (11/21/87)
In article <3312@aw.sei.cmu.edu> kwh@sei.cmu.edu (Kurt Hoyt) writes: > >..events while a button is down so I can move the object... >Selecting ButtonMotionMask generates >MotionNotifys whether or not a button is pressed. Write xbugs on this, if you're absolutely sure it's happening, and you haven't inadvertently selected PointerMotionMask. Are the motion events coming from some other window you've enabled them from? > Selecting >PointerMotionHintMask ONLY generates nothing. That's right; PointerMotionHintMask is a modifier for any of the masks that select motion events. >Selecting either >ButtonMotionMask or PointerMotionMask along with PointMotionHintMask will >generate one MotionNotify if the pointer moves and no buttons are pressed >and lots of MotionNotifys when any button is pressed (followed by one >MotionNotify after the button is released). A little confusion here, I fear. If you select ButtonMotionMask without PointerMotionMask, you should not get MotionNotify events without any buttons held down. Check the event.xmotion.state field for (Button1Mask|Button2Mask|Button3Mask...) to be absolutely sure. If you select PointerMotionMask, you should get MotionNotify events whenever the pointer moves. If you ALSO specify PointerMotionHintMask, you *may* get fewer MotionNotify events. These events should have the is_hint field set to True. To be perfectly correct, you must respond to each motion hint with an XQueryPointer or XGetMotionEvents ; there's an optional interlock capability. I use this code fragment to respond to MotionNotify when I'm expecting hints; it seems to work (on Xapollo). XNextEvent ( dpy, &myevent); ... case MotionNotify: /* spin through any excess MotionNotify events */ while ( XCheckMaskEvent (dpy, (PointerMotionMask | ButtonMotionMask), &myevent )); /* break interlock on MotionHint stuff */ if (myevent.xmotion.is_hint) XQueryPointer (dpy, iw, &jw, &jw, &jw, &jw, &xxx, &yyy, &jw); else { xxx = myevent.xmotion.x; yyy = myevent.xmotion.y; } >XGetMotionEvents consistently >has nothing to report (called initialliy with start = 0, stop = >CurrentTime). That's right. No servers yet do motion history buffers; motion history buffers are optional on all servers. To see if you have a motion history buffer available, look at the Display field's motion history buffer. Display * dpy; ... dpy->motion_buffer If it's zero...you're out of luck on motion history buffers. >Other selected events: ExposureMask, ButtonPressMask, ButtonReleaseMask, >KeyPressMask. Note that funny things happen when you select ButtonPressMask without also specifying OwnerGrabButtonMask. The act of pressing the button grabs the pointer; this means that it gets a frozen event mask (except due to the action of the OwnerGrabButtonMask). So, if you were trying to do another XSelectInput in response to the ButtonPress, you were probably not seeing the mask change. /oj