I'd like to be able to set the mouse position (for reasons to do with
writing GUI interfaces that suck less). Btw. I've got a bunch of
patches (see the issues I submited) and I'd like to avoid having to
keep a forked repository of pyglet around, any idea?

Anyway I propose a patch like this:
===================================================================
--- pyglet/window/xlib/__init__.py      (revision 2421)
+++ pyglet/window/xlib/__init__.py      (working copy)
@@ -574,6 +574,15 @@
             else:
                 xlib.XUndefineCursor(self._x_display, self._window)

+    def set_mouse_position(self, x, y):
+        xlib.XWarpPointer(self._x_display,
+            0,              # src window
+            self._window,   # dst window
+            0, 0,           # src x, y
+            0, 0,           # src w, h
+            x, self._height - y,
+        )
+
     def _update_exclusivity(self):
         mouse_exclusive = self._active and self._mouse_exclusive
         keyboard_exclusive = self._active and
self._keyboard_exclusive
@@ -596,20 +605,10 @@
                 x = self._width / 2
                 y = self._height / 2
                 self._mouse_exclusive_client = x, y
-                xlib.XWarpPointer(self._x_display,
-                    0,              # src window
-                    self._window,   # dst window
-                    0, 0,           # src x, y
-                    0, 0,           # src w, h
-                    x, y)
+                self.set_mouse_position(x, y)
             elif self._fullscreen and not self.screen._xinerama:
                 # Restrict to fullscreen area (prevent viewport
scrolling)
-                xlib.XWarpPointer(self._x_display,
-                    0,              # src window
-                    self._view,     # dst window
-                    0, 0,           # src x, y
-                    0, 0,           # src w, h
-                    0, 0)
+                self.set_mouse_position(0, 0)
                 r = xlib.XGrabPointer(self._x_display, self._view,
                     True, 0,
                     xlib.GrabModeAsync,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to