mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2026-07-17 16:36:49 +00:00
VNC-14 addressed code review comments
This commit is contained in:
parent
f1a1bd5557
commit
763a6f4972
6 changed files with 55 additions and 13 deletions
|
|
@ -78,6 +78,12 @@ namespace rfb {
|
||||||
// the relevant RFB protocol messages from clients.
|
// the relevant RFB protocol messages from clients.
|
||||||
// See InputHandler for method signatures.
|
// See InputHandler for method signatures.
|
||||||
|
|
||||||
|
virtual Point directMouseEventWithPosition(int dx, int dy, int buttonMask,
|
||||||
|
int scrollX, int scrollY) {
|
||||||
|
directMouseEvent(dx, dy, buttonMask, scrollX, scrollY);
|
||||||
|
return Point();
|
||||||
|
}
|
||||||
|
|
||||||
// handleClipboardAnnounce() is called to indicate a change in the
|
// handleClipboardAnnounce() is called to indicate a change in the
|
||||||
// clipboard on a client. Call VNCServer::requestClipboard() to
|
// clipboard on a client. Call VNCServer::requestClipboard() to
|
||||||
// access the actual data.
|
// access the actual data.
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,8 @@ void SMsgReader::readVideoEncodersRequest() const {
|
||||||
void SMsgReader::readDirectMouseEvent()
|
void SMsgReader::readDirectMouseEvent()
|
||||||
{
|
{
|
||||||
// Wire format (9 bytes after the type byte):
|
// Wire format (9 bytes after the type byte):
|
||||||
// byte 0: button mask (bit 0=left, 1=right, 2=middle, 3=side, 4=extra)
|
// byte 0: VNC button mask. Button N uses bit N-1, so the common buttons
|
||||||
|
// are bit 0=left, bit 1=middle, bit 2=right.
|
||||||
// bytes 1-2: dx (int16 BE)
|
// bytes 1-2: dx (int16 BE)
|
||||||
// bytes 3-4: dy (int16 BE)
|
// bytes 3-4: dy (int16 BE)
|
||||||
// bytes 5-6: scroll dx (int16 BE)
|
// bytes 5-6: scroll dx (int16 BE)
|
||||||
|
|
|
||||||
|
|
@ -815,16 +815,23 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool
|
||||||
void VNCSConnectionST::directMouseEvent(int dx, int dy, int buttonMask,
|
void VNCSConnectionST::directMouseEvent(int dx, int dy, int buttonMask,
|
||||||
int scrollX, int scrollY)
|
int scrollX, int scrollY)
|
||||||
{
|
{
|
||||||
pointerEventTime = lastEventTime = time(0);
|
pointerEventTime = lastEventTime = time(nullptr);
|
||||||
server->lastUserInputTime = lastEventTime;
|
server->lastUserInputTime = lastEventTime;
|
||||||
if (!(accessRights & AccessPtrEvents))
|
if (!(accessRights & AccessPtrEvents))
|
||||||
return;
|
return;
|
||||||
if (!rfb::Server::acceptPointerEvents)
|
if (!rfb::Server::acceptPointerEvents)
|
||||||
return;
|
return;
|
||||||
|
if (server->pointerClient && server->pointerClient != this)
|
||||||
|
return;
|
||||||
|
|
||||||
// Route through the desktop interface, which handles both uinput
|
if (buttonMask)
|
||||||
// writes and X11 cursor updates.
|
server->pointerClient = this;
|
||||||
server->desktop->directMouseEvent(dx, dy, buttonMask, scrollX, scrollY);
|
else
|
||||||
|
server->pointerClient = nullptr;
|
||||||
|
|
||||||
|
pointerEventPos =
|
||||||
|
server->desktop->directMouseEventWithPosition(dx, dy, buttonMask,
|
||||||
|
scrollX, scrollY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
#include "vncExtInit.h"
|
#include "vncExtInit.h"
|
||||||
#include "RFBGlue.h"
|
#include "RFBGlue.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
#if XORG >= 110
|
#if XORG >= 110
|
||||||
#include "inpututils.h"
|
#include "inpututils.h"
|
||||||
|
|
@ -767,7 +764,6 @@ static void vncKeysymKeyboardEvent(KeySym keysym, int down)
|
||||||
mieqProcessInputEvents();
|
mieqProcessInputEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if INPUTTHREAD
|
#if INPUTTHREAD
|
||||||
/** This function is called in Xserver/os/inputthread.c when starting
|
/** This function is called in Xserver/os/inputthread.c when starting
|
||||||
the input thread. */
|
the input thread. */
|
||||||
|
|
|
||||||
|
|
@ -513,18 +513,49 @@ void XserverDesktop::pointerEvent(const Point& pos, int buttonMask,
|
||||||
|
|
||||||
void XserverDesktop::directMouseEvent(int dx, int dy, int buttonMask,
|
void XserverDesktop::directMouseEvent(int dx, int dy, int buttonMask,
|
||||||
int scrollX, int scrollY)
|
int scrollX, int scrollY)
|
||||||
|
{
|
||||||
|
directMouseEventWithPosition(dx, dy, buttonMask, scrollX, scrollY);
|
||||||
|
}
|
||||||
|
|
||||||
|
rfb::Point XserverDesktop::directMouseEventWithPosition(int dx, int dy,
|
||||||
|
int buttonMask, int scrollX, int scrollY)
|
||||||
{
|
{
|
||||||
// Move the X11 cursor via XTest (relative injection).
|
// Move the X11 cursor via XTest (relative injection).
|
||||||
// buttonMask uses standard VNC convention (bit 0=left, 1=middle, 2=right)
|
// buttonMask uses standard VNC convention (bit 0=left, 1=middle, 2=right)
|
||||||
// which matches X11 button numbering directly — no remapping needed.
|
// which matches X11 button numbering directly, so no remapping is needed.
|
||||||
|
int cursorX, cursorY;
|
||||||
|
vncGetPointerPos(&cursorX, &cursorY);
|
||||||
|
|
||||||
if (scrollX == 0 && scrollY == 0) {
|
if (scrollX == 0 && scrollY == 0) {
|
||||||
vncPointerMoveRelative(dx, dy,
|
const int screenX = vncGetScreenX(screenIndex);
|
||||||
vncGetScreenX(screenIndex),
|
const int screenY = vncGetScreenY(screenIndex);
|
||||||
vncGetScreenY(screenIndex));
|
const int maxX = screenX + width() - 1;
|
||||||
|
const int maxY = screenY + height() - 1;
|
||||||
|
|
||||||
|
cursorX += dx;
|
||||||
|
cursorY += dy;
|
||||||
|
|
||||||
|
if (cursorX < screenX)
|
||||||
|
cursorX = screenX;
|
||||||
|
else if (cursorX > maxX)
|
||||||
|
cursorX = maxX;
|
||||||
|
|
||||||
|
if (cursorY < screenY)
|
||||||
|
cursorY = screenY;
|
||||||
|
else if (cursorY > maxY)
|
||||||
|
cursorY = maxY;
|
||||||
|
|
||||||
|
vncPointerMoveRelative(dx, dy, cursorX, cursorY);
|
||||||
vncPointerButtonAction(buttonMask, false, false);
|
vncPointerButtonAction(buttonMask, false, false);
|
||||||
} else {
|
} else {
|
||||||
vncScroll(scrollX, scrollY);
|
vncScroll(scrollX, scrollY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rfb::Point cursorPos(cursorX - vncGetScreenX(screenIndex),
|
||||||
|
cursorY - vncGetScreenY(screenIndex));
|
||||||
|
oldCursorPos = cursorPos;
|
||||||
|
server->setCursorPos(cursorPos, false);
|
||||||
|
return cursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ public:
|
||||||
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
|
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
|
||||||
const bool skipClick, const bool skipRelease, int scrollX = 0, int scrollY = 0);
|
const bool skipClick, const bool skipRelease, int scrollX = 0, int scrollY = 0);
|
||||||
virtual void directMouseEvent(int dx, int dy, int buttonMask, int scrollX, int scrollY);
|
virtual void directMouseEvent(int dx, int dy, int buttonMask, int scrollX, int scrollY);
|
||||||
|
virtual rfb::Point directMouseEventWithPosition(int dx, int dy, int buttonMask, int scrollX, int scrollY);
|
||||||
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
||||||
virtual unsigned int setScreenLayout(int fb_width, int fb_height,
|
virtual unsigned int setScreenLayout(int fb_width, int fb_height,
|
||||||
const rfb::ScreenSet& layout);
|
const rfb::ScreenSet& layout);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue