Properly forward mouse events to the VNC client

Change-Id: I3cee27bab4cd81079adedf3968ac4dfebf43aa11
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Lars Knoll 2015-12-16 22:14:36 +01:00 committed by Andy Nichols
parent 6d70e543aa
commit 1955da90a0
2 changed files with 6 additions and 8 deletions

View File

@ -40,6 +40,8 @@
#include "qvncscreen.h"
#include "QtNetwork/qtcpserver.h"
#include "QtNetwork/qtcpsocket.h"
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/qguiapplication.h>
#include <qthread.h>
#ifdef Q_OS_WIN
@ -410,7 +412,7 @@ bool QRfbPointerEvent::read(QTcpSocket *s)
char buttonMask;
s->read(&buttonMask, 1);
buttons = 0;
buttons = Qt::NoButton;
if (buttonMask & 1)
buttons |= Qt::LeftButton;
if (buttonMask & 2)
@ -481,10 +483,6 @@ void QRfbRawEncoder::write()
return;
const QImage screenImage = server->screenImage();
static int frame = 0;
++frame;
QString filename = QString("screen.%1.png").arg(frame);
screenImage.save(filename);
for (const QRect &tileRect: rects) {
const QRfbRect rect(tileRect.x(), tileRect.y(),
@ -1070,8 +1068,8 @@ void QVncServer::pointerEvent()
{
QRfbPointerEvent ev;
if (ev.read(client)) {
//const QPoint offset = qvnc_screen->geometry().topLeft();
// ### QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons);
const QPoint pos = qvnc_screen->geometry().topLeft() + QPoint(ev.x, ev.y);
QWindowSystemInterface::handleMouseEvent(0, pos, pos, ev.buttons, QGuiApplication::keyboardModifiers());
handleMsg = false;
}
}

View File

@ -188,7 +188,7 @@ class QRfbPointerEvent
public:
bool read(QTcpSocket *s);
uint buttons;
Qt::MouseButtons buttons;
quint16 x;
quint16 y;
};