]> source.dussan.org Git - tigervnc.git/commitdiff
Let XserverDesktop handle syncing cursor position
authorPierre Ossman <ossman@cendio.se>
Mon, 14 Jul 2014 11:36:47 +0000 (13:36 +0200)
committerPierre Ossman <ossman@cendio.se>
Mon, 14 Jul 2014 11:36:47 +0000 (13:36 +0200)
This makes InputDevice cleaner and just a glue layer for Xorg
input devices.

unix/xserver/hw/vnc/Input.cc
unix/xserver/hw/vnc/Input.h
unix/xserver/hw/vnc/XserverDesktop.cc
unix/xserver/hw/vnc/XserverDesktop.h

index 1474f93a3d733eae9afe134990dc2cdcce67b917..46b02fd18eed7f74144d4251804427dda205d6ea 100644 (file)
@@ -116,8 +116,8 @@ static void enqueueEvents(DeviceIntPtr dev, int n)
 }
 #endif /* XORG < 111 */
 
-InputDevice::InputDevice(rfb::VNCServerST *_server)
-       : server(_server), initialized(false), oldButtonMask(0)
+InputDevice::InputDevice()
+       : initialized(false), oldButtonMask(0)
 {
        int i;
 
@@ -195,13 +195,9 @@ void InputDevice::PointerMove(const rfb::Point &pos)
        cursorPos = pos;
 }
 
-void InputDevice::PointerSync(void)
+const rfb::Point &InputDevice::getPointerPos(void)
 {
-       if (cursorPos.equals(oldCursorPos))
-               return;
-
-       oldCursorPos = cursorPos;
-       server->setCursorPos(cursorPos);
+       return cursorPos;
 }
 
 static int pointerProc(DeviceIntPtr pDevice, int onoff)
index e893049e5f5df6273f94b2966fa232b7890a88f7..c996cb0b3c50695356e8f44953044e8093248669 100644 (file)
 
 #include <list>
 
-#include <rfb/VNCServerST.h>
+#include <rdr/types.h>
+#include <rfb/Rect.h>
 
 extern "C" {
 #include "input.h"
+/* The Xorg headers define macros that wreak havoc with STL */
+#undef max
 };
 
 #include "xorg-version.h"
@@ -41,7 +44,7 @@ extern "C" {
 class InputDevice {
 public:
        /* Create new InputDevice instance */
-       InputDevice(rfb::VNCServerST *_server);
+       InputDevice();
 
        /*
         * Press or release buttons. Relationship between buttonMask and
@@ -52,12 +55,10 @@ public:
        /* Move pointer to target location (point coords are absolute). */
        void PointerMove(const rfb::Point &point);
 
-       /*
-        * Send pointer position to clients. If not called then Move() calls
-        * won't be visible to VNC clients.
-        */
-       void PointerSync(void);
+       /* Get current known location of the pointer */
+       const rfb::Point &getPointerPos(void);
 
+       /* Press or release one or more keys to get the given symbol */
        void KeyboardPress(rdr::U32 keysym) { keyEvent(keysym, true); }
        void KeyboardRelease(rdr::U32 keysym) { keyEvent(keysym, false); }
 
@@ -103,13 +104,12 @@ private:
 #endif
 
 private:
-       rfb::VNCServerST *server;
        bool initialized;
        DeviceIntPtr keyboardDev;
        DeviceIntPtr pointerDev;
 
        int oldButtonMask;
-       rfb::Point cursorPos, oldCursorPos;
+       rfb::Point cursorPos;
 
        KeySym pressedKeys[256];
 };
index b0d4601e347d1d00da546623650b3c50f310964e..cd76d0684510289d9ff171a86643ef56e94a03ad 100644 (file)
@@ -689,7 +689,11 @@ void XserverDesktop::wakeupHandler(fd_set* fds, int nfds)
         }
       }
 
-      inputDevice->PointerSync();
+      // We are responsible for propagating mouse movement between clients
+      if (!oldCursorPos.equals(inputDevice->getPointerPos())) {
+        oldCursorPos = inputDevice->getPointerPos();
+        server->setCursorPos(oldCursorPos);
+      }
     }
 
     // Then let the timers do some processing. Rescheduling is done in
index fb247b048e06f44ad1f61dbc27c20bce6fd65105..ca6e8af9d1735c995053bf842691d45140ad3f3e 100644 (file)
@@ -153,5 +153,7 @@ private:
   typedef std::map<RROutputPtr, rdr::U32> OutputIdMap;
   OutputIdMap outputIdMap;
 #endif
+
+  rfb::Point oldCursorPos;
 };
 #endif