Problem with XWarpPointer(3x)
Problem with XWarpPointer(3x)
- Subject: Problem with XWarpPointer(3x)
- From: Colin Hirsch <email@hidden>
- Date: Sat, 10 May 2003 21:19:39 +0200
Hi Everybody,
the other day I "ported" some old source code of mine from Linux to Jaguar;
it uses Xlib and GLX and compiled right out of the box. Only problem is that
XWarpPointer() does not behave as expected - details:
In order to get mouse movements of any length I use the well-known trick to
warp the pointer back to the center of the window after receiving a motion
event.
At first I tried my old version that did not have the XSelectInput calls,
but worked on Linux with XFree86 some years back. When I then move the
mouse, most of the motion events have a delta pointer position of zero,
i.e. I have to rapidly move the mouse to get even a few jerks out of my
player object.
Without the XWarpPointer everything works as expected - until the mouse
leaves the window.
I then looked for other code examples on the web and found nothing really
different except the additionl calls to XSelectInput taken from the Quake
source code. Unfortunately it does not seem to help...
Any ideas anybody?
Thanks & Greetings, Colin
PS: Code fragment.
[in the "while ( XPending( display_ ) )" loop of the event handler]
switch ( xevent.type )
...
case MotionNotify:
if ( pointer_grabbed )
{
delta_x = xevent.xmotion.x - pointer_x_;
delta_y = xevent.xmotion.y - pointer_y_;
pointer_x_ = xevent.xmotion.x;
pointer_y_ = xevent.xmotion.y;
if ( delta_x || delta_y )
{
player_->do_motion( delta_x, delta_y );
need_motion = true;
}
}
break;
[later in the X event handler]
if ( need_motion )
{
XSelectInput( display_, window_, ExposureMask |
StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask |
KeyReleaseMask | FocusChangeMask );
XWarpPointer( display_, None, window_, 0, 0, 0, 0, width_ / 2,
height_ / 2 );
XSelectInput( display_, window_, ExposureMask |
StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask |
KeyReleaseMask | PointerMotionMask | FocusChangeMask );
pointer_x_ = width_ / 2;
pointer_y_ = height_ / 2;
need_render = true;
}
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/x11-users
X11 for Mac OS X FAQ: http://developer.apple.com/qa/qa2001/qa1232.html
Report issues, request features, feedback: http://developer.apple.com/bugreporter
Do not post admin requests to the list. They will be ignored.