Re: setting pointer position?



Gary Scavone wrote:
> 
> I'm writing a GTK app in which the user can drag icons (buttons)
> around in a window.  When an icon hits the window edge or another
> button, I stop it's motion in the direction of the obstruction.  I'd
> really like to be able to stop the pointer motion in that direction as
> well, but I haven't been able to find a way to do it so far.
> 
> Does anyone know how this might be done?

  Here's what I use to set the cursor position (in screen coordinates).
You might also want to take a look at gdk_pointer_grab () to confine the
cursor inside a window.

void Sys_SetCursorPos (int x, int y)
{
#ifdef WIN32
  SetCursorPos (x, y);
#endif
 
#ifdef __linux__
  XWarpPointer (GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0, 0, 0, 0, x,
y);
#endif
}

Leonardo




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