Permalink
Browse files

[X11] Fixed GetCursorState() after SetPosition()

The new position is now immediately reflected in GetCursorPos().
  • Loading branch information...
1 parent 452d61b commit dd16142a3ab26b9e46864fedb340ad08993d9886 @thefiddler thefiddler committed May 13, 2014
Showing with 7 additions and 0 deletions.
  1. +7 −0 Source/OpenTK/Platform/X11/XI2Mouse.cs
@@ -139,6 +139,7 @@ public XI2Mouse()
XIEventMasks.RawButtonPressMask |
XIEventMasks.RawButtonReleaseMask |
XIEventMasks.RawMotionMask |
+ XIEventMasks.MotionMask |
XIEventMasks.DeviceChangedMask |
(XIEventMasks)(1 << (int)ExitEvent)))
{
@@ -313,6 +314,8 @@ public void SetPosition(double x, double y)
{
Functions.XWarpPointer(API.DefaultDisplay,
IntPtr.Zero, window.RootWindow, 0, 0, 0, 0, (int)x, (int)y);
+ Interlocked.Exchange(ref cursor_x, (long)x);
+ Interlocked.Exchange(ref cursor_y, (long)y);
// Mark the expected warp-event so it can be ignored.
if (mouse_warp_event == null)
@@ -352,6 +355,10 @@ void ProcessEvents()
{
switch ((XIEventType)cookie.evtype)
{
+ case XIEventType.Motion:
+ // Nothing to do
+ break;
+
case XIEventType.RawMotion:
case XIEventType.RawButtonPress:
case XIEventType.RawButtonRelease:

0 comments on commit dd16142

Please sign in to comment.