Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ll-xn!husc6!mit-eddie!apollo!oj From: oj@apollo.UUCP Newsgroups: comp.windows.x Subject: Re: Problem with motion event handling? Message-ID: <3898d627.d5b2@apollo.uucp> Date: Fri, 20-Nov-87 18:26:00 EST Article-I.D.: apollo.3898d627.d5b2 Posted: Fri Nov 20 18:26:00 1987 Date-Received: Sun, 22-Nov-87 12:39:10 EST References: <3312@aw.sei.cmu.edu> Reply-To: oj@apollo.UUCP (Ellis Oliver Jones) Organization: Apollo Computer, Chelmsford, MA Lines: 74 Keywords: X11 motion events 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