]> source.dussan.org Git - tigervnc.git/commitdiff
Adjust client pointer coordinates to absolute
authorPierre Ossman <ossman@cendio.se>
Thu, 18 Aug 2016 14:16:45 +0000 (16:16 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 18 Aug 2016 14:16:45 +0000 (16:16 +0200)
The client is not aware of where the screen is placed so it will give
us screen relative coordinates. Convert to and from these and absolute
coordinates before interacting with the input layer.

unix/xserver/hw/vnc/XorgGlue.c
unix/xserver/hw/vnc/XorgGlue.h
unix/xserver/hw/vnc/XserverDesktop.cc

index d7892b1839fcd672c5f6c86d7d15e02483aae69c..712ed6afc80e693a3f02d89430c4ee09e25404cc 100644 (file)
@@ -92,6 +92,16 @@ void vncGetScreenFormat(int scrIdx, int *depth, int *bpp,
   *blueMask = vis->blueMask;
 }
 
+int vncGetScreenX(int scrIdx)
+{
+  return screenInfo.screens[scrIdx]->x;
+}
+
+int vncGetScreenY(int scrIdx)
+{
+  return screenInfo.screens[scrIdx]->y;
+}
+
 int vncGetScreenWidth(int scrIdx)
 {
   return screenInfo.screens[scrIdx]->width;
index 92b0d18de074ac91efb80bb4e00e256c0b0ba55f..5cae860a162ec4ab5c51f3f467ba24bdf0b150cc 100644 (file)
@@ -33,6 +33,8 @@ void vncGetScreenFormat(int scrIdx, int *depth, int *bpp,
                         int *trueColour, int *bigEndian,
                         int *redMask, int *greenMask, int *blueMask);
 
+int vncGetScreenX(int scrIdx);
+int vncGetScreenY(int scrIdx);
 int vncGetScreenWidth(int scrIdx);
 int vncGetScreenHeight(int scrIdx);
 
index 4eaa41f3982209c3cace04d3506ebacde01691f0..4f82a54425089725b0476282e2dd5d4840cd926a 100644 (file)
@@ -514,6 +514,8 @@ void XserverDesktop::readWakeupHandler(fd_set* fds, int nfds)
       // We are responsible for propagating mouse movement between clients
       int cursorX, cursorY;
       vncGetPointerPos(&cursorX, &cursorY);
+      cursorX -= vncGetScreenX(screenIndex);
+      cursorY -= vncGetScreenY(screenIndex);
       if (oldCursorPos.x != cursorX || oldCursorPos.y != cursorY) {
         oldCursorPos.x = cursorX;
         oldCursorPos.y = cursorY;
@@ -648,7 +650,8 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
 
 void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
 {
-  vncPointerMove(pos.x, pos.y);
+  vncPointerMove(pos.x + vncGetScreenX(screenIndex),
+                 pos.y + vncGetScreenY(screenIndex));
   vncPointerButtonAction(buttonMask);
 }