[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1009.0. "Help: How to enable/disable PointerMotion ?" by PDVAX::P_DAVIS (Peter Davis) Fri Jun 23 1989 12:01

    I'm trying to change the event mask for XSelectInput during my
    application, so I can selectively enable and disable motion events.  It
    doesn't seem to work the way I'm doing it.  Any suggestions?
    
    In simplest terms, the application has two states: dragging and not
    dragging.  When the application is dragging, I want to get motion
    events, so I can do rubber-banding, etc.  When not dragging, I don't
    need the motion events, so it's less burdensome all around to not get
    them.
    
    This is simple if I just follow the model of dragging when the button
    is down, and not when it is up.  That's what the ButtonMotionMask does
    for me.  However, I also want it to work so that if the button release
    comes within, say, � second of the button press, then I ignore the
    release, keep dragging, and let the following button press/release end
    the dragging.  In other words, you can drag by holding the button down,
    OR you can click (and release), move the pointer, and then click (and
    release) again.
    
    To do this, I want to explicitly enable PointerMotionMask when
    dragging is turned on, and disable it when dragging is turned off. 
    The logic seems to work ok if I leave PointerMotionMask on all the
    time, but enabling it and disabling it doesn't work.
    
    Someone suggested that the passive grab during the ButtonPress event
    may be preventing me from issuing XSelectInput calls.  Is that right?
    
    The event loop, in skeleton, looks like:
    
    while (waiting)
      {
    	XNextEvent (disp, &event)
    	switch (event.type)
    
    	  case ButtonPress:
    	    if (!dragging)
    	      {
    		dragging = TRUE;
    		begin_time = event.xbutton.time;
    		XSelectInput ( ... mask_that_includes_PointerMotionMask );
    		...
    	      }
    	    break;
    
    	  case MotionNotify:
    	    if (dragging) { ... do dragging things ...}
    	    break;
    
    	  case ButtonRelease:
    	    if (dragging)
    	      {
    		if (event.xbutton.time - begin_time > THRESHOLD)
    		  {
    		    dragging = FALSE;
    		    XSelectInput (... mask_without_PointerMotionMask );
    		    ...
    		  }
    	      }
    	    break;
      }

T.RTitleUserPersonal
Name
DateLines
1009.1Try pointer motion hintsPOOL::BUFORDOhayo, y'all!Fri Jun 23 1989 13:4015
    Have you considered using pointer motion hints?  Basically, motion
    hints tells the server to send a MotionNotify the first time the
    pointer moves, then not to send anymore until the client makes a
    QueryPointer request.  
    
    If I remember correctly, the window manager used to use motion hints
    for all of its mouse tracking as a mechanism for throttling the
    MotionNotify arrival rate.  It didn't actually use the value returned
    by QueryPointer-- it just made the call to say "OK, I'm ready for
    another MotionNotify now..."  I do not know whether this algorithm is
    still being used or what...
    
    
    John B.

1009.2PDVAX::P_DAVISPeter DavisFri Jun 23 1989 15:2514
    Re/ .1:
    
    Thanks.  I didn't have a good description of how PointerMotionHints
    works.  The one in Scheifler/Gettys/Newman is somewhat vague, and makes
    it sound like its at the server's discretion when to deliver motion
    events.
    
    If XQueryPointer "enables" MotionNotify events, how can I disable them
    again?  By doing another XSelectInput with the PointerMotionHints on?
    
    Thanks.
    
    -pd