Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse From: mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) Newsgroups: comp.windows.x Subject: X11R3: PointerMotionMask misbehaving Message-ID: <8903272336.AA08703@Larry.McRCIM.McGill.EDU> Date: 27 Mar 89 23:36:47 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 80 System: Sun-3, release 3.5. X11R3. A couple of things seem to be broken.... I set up a passive grab on a button: XGrabButton( disp, Button2, AnyModifier, rootwin, False, ButtonPressMask | PointerMotionMask, GrabModeSync, GrabModeSync, None, None ); One problem is that I seem to need to explicitly XUngrabPointer when I see a ButtonPress event, or else the grab seems to persist after the button is released (contrary to the documentation I have, which says that a passive grab will deactivate as soon as all buttons are released). The other problem is that under some conditions, I want to move a box around, violating normal window boundaries, when I see this button press come in (I'm writing a window manager). I looked at how uwm does its animation of boxes and wrote the following, which is called under some circumstances when a ButtonPress event is seen: XGrabServer(disp); XAllowEvents(disp,AsyncPointer,CurrentTime); XChangeActivePointerGrab( disp, ButtonPressMask | PointerMotionMask, None, CurrentTime ); while (1) { .... XIfEvent(disp,&e,predicate,""); .... switch (e.type) { .... case ButtonPress: .... case MotionNotify: .... } .... } where predicate is Bool predicate(d,e,a) Display *d; XEvent *e; char *a; { return((e->type == ButtonPress) || (e->type == MotionNotify)); } The problem is, I never see a MotionNotify event. As if that weren't enough, I never see more than one ButtonPress event! Any idea what I'm doing wrong here? (Yes, I do clean up, ungrabbing things, but the problems strike before that.) The XChangeActivePointerGrab call was an attempt to make *certain* that motion events would get through, but it didn't help any. Uwm seems to get around this by doing a spin loop, calling XQueryPointer and doing things when the returned values change. However, that's insanely inefficient, or so it seems to me. I can just imagine what it would do to the network when uwm is not on the same machine as the server. Is the above supposed to work? If so, any idea why it doesn't? If not, what's the proper way to do this? der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu