Skip to content

Commit

Permalink
Adjust client pointer coordinates to absolute
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CendioOssman committed Aug 18, 2016
1 parent 2a66f6f commit af7fb8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions unix/xserver/hw/vnc/XorgGlue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions unix/xserver/hw/vnc/XorgGlue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion unix/xserver/hw/vnc/XserverDesktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit af7fb8d

Please sign in to comment.