Re: Movinf the mouse pointer



Funky Example:

#include <gdk/gdkx.h>
#include <stdlib.h>


gboolean
on_window1_button_release_event        (GtkWidget       *widget,
                                        GdkEventButton  *event,
                                        gpointer         user_data)
{
  Window   win = GDK_WINDOW_XID(widget->window);
  Display *dpy = GDK_WINDOW_XDISPLAY(widget->window);

  int  dx   = random() % 100 - 50;
  int  dy   = random() % 100 - 50;

  XWarpPointer(dpy, win, None, 0, 0, 0, 0, dx, dy);

  return FALSE;
}

I passed None to the third argument (dest_w) to make the warping
relative:
"If dest_w is None, XWarpPointer moves the pointer by the offsets
(dest_x, dest_y) relative to the current position of the pointer."

See man page of XWarpPointer a detailed description.

Hans.
 
On Tue, 2005-06-14 at 09:46 +0200, Luca Cappa wrote:
> Valdis Kletnieks vt edu wrote:
> 
> >On Mon, 13 Jun 2005 14:38:27 +0200, Luca Cappa said:
> >
> >  
> >
> >>My problem is that I would like to reset the mouse pointer position 
> >>after each delta movement has been detected: in this
> >>way the mouse pointer is always placed in the original position it was 
> >>when the mouse button was pressed.
> >>    
> >>
> >
> >Please note that most UI design guides rate "warping the mouse pointer" as a
> >fairly anti-social thing to do, because it confuses users who expect the mouse
> >pointer to be where they left it.  If their next action is taken thinking that
> >the mouse pointer is *here*, when it's actually jsut been moved back 150 pixels
> >to where it *was*, Very Strange Things can happen (for instance, the *next*
> >drag-n-(drop,select,zoom,ec) isn't what the user intended, and so on).
> >
> >Even most "rotate the view" applications leave the mouse where it at the
> >end of the rotate - otherwise Odd Things can happen.  Consider:
> >
> >1) User starts at 1,0,0 (out on the X axis).
> >2) User rotates the model 90 degrees with a drag to 0,1,0 (out the Y axis)
> >
> >3a) Mouse left where it was: User rotates the model with an "up" to 0,1,1 - this causes a rotate around X.
> >
> >3b) Mouse warped back to 1,0,0 and user doesn't notice, does the *same* "up",
> >and now the model rotates around the Y axis instead of X.
> >
> >It violates the "principle of least surprise" that if they had done one continuous
> >drag from (1) to (2) to (3), it rotates one way, but if they break it into two
> >pieces it does a different rotate....
> >
> >Just something to think about as you design....
> >  
> >
> Yes, I agree with you.  In my problem i exposed I said also that
> "When this process  is going on, the mouse is hidden (i.e. its shape is 
> an empty image). "
> so the user would not notice that the mouse is being reset (moved) many 
> times, and when the rotating of the 3D view ends (i.e.
> left mouse button released) the mouse pop up again in the original 
> position it was when it was hidden (i.e. left mouse button held down).
> 
> Ii just need a function like some one suggested already to me as:
> 
> int XWarpPointer(Display *display, Window src_w, Window dest_w, int
> 
>               src_x, int src_y, unsigned int src_width, unsigned int
>               src_height, int dest_x, int dest_y);
> 
> which still I have to understand how it works :-)
> 
> Greetings,
> Luca
> 
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 
-- 
I said 'No' to the EU constitution

Bye bye Chirac, bye bye Schroeder, we won't miss you




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]