Skip to content

Commit

Permalink
VNC: modify mouse to add back button
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Feb 11, 2025
1 parent 0fdecfc commit d2e4eef
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
working-directory: ${{env.SOURCE_DIR}}
run: |
if [ ! -d ${{env.INSTALL_DIR}}/lib/cmake/FreeRDP3 ]; then
git clone -b 3.10.3 https://github.com/FreeRDP/FreeRDP.git
git clone -b 3.11.0 https://github.com/FreeRDP/FreeRDP.git
# git clone https://github.com/KangLin/FreeRDP.git
cd FreeRDP
git submodule update --init --recursive
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Change Log
### v0.0.33
- Remove donate bitcoin
- VNC: modify mouse. add back button

### v0.0.32
- Fix player menu bug
Expand Down
1 change: 1 addition & 0 deletions ChangeLog_zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 修改日志
### v0.0.33
- 移除捐赠比特币
- VNC: 修改鼠标,增加后退按钮

### v0.0.32
- 修复播放器菜单错误
Expand Down
25 changes: 20 additions & 5 deletions Plugins/LibVNCServer/Client/ConnectLibVNCServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

static Q_LOGGING_CATEGORY(log, "LibVNCServer.Connect")
static Q_LOGGING_CATEGORY(logger, "LibVNCServer.Connect.log")
static Q_LOGGING_CATEGORY(logKey, "LibVNCServer.Connect.Key")
static Q_LOGGING_CATEGORY(logMouse, "LibVNCServer.Connect.Mouse")

const char* gThis = "This pointer";
#define LOG_BUFFER_LENGTH 1024
Expand Down Expand Up @@ -572,16 +574,20 @@ void CConnectLibVNCServer::mousePressEvent(QMouseEvent *event)
{
if(!m_pClient) return;
if(m_pParameter && m_pParameter->GetOnlyView()) return;
//qDebug(log) << "CConnectLibVnc::slotMousePressEvent" << e->button() << e->buttons();

unsigned char mask = 0;
if(event->button() & Qt::MouseButton::LeftButton)
mask |= 0x1;
if(event->button() & Qt::MouseButton::MiddleButton)
mask |= 0x2;
if(event->button() & Qt::MouseButton::RightButton)
mask |= 0x4;

if(event->button() & Qt::MouseButton::BackButton)
mask |= 0x80;
QPoint pos = event->pos();

qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;

SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
}

Expand All @@ -591,12 +597,12 @@ void CConnectLibVNCServer::mouseReleaseEvent(QMouseEvent *event)
if(m_pParameter && m_pParameter->GetOnlyView()) return;
int mask = 0;
QPoint pos = event->pos();
qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;
SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
}

void CConnectLibVNCServer::mouseMoveEvent(QMouseEvent *event)
{
//qDebug(log) << "CConnectLibVnc::slotMouseMoveEvent" << buttons << pos;
if(!m_pClient) return;
if(m_pParameter && m_pParameter->GetOnlyView()) return;
int mask = 0;
Expand All @@ -606,13 +612,16 @@ void CConnectLibVNCServer::mouseMoveEvent(QMouseEvent *event)
mask |= 0x2;
if(event->buttons() & Qt::MouseButton::RightButton)
mask |= 0x4;
if(event->buttons() & Qt::MouseButton::BackButton)
mask |= 0x80;
QPoint pos = event->pos();
qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;
SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
}

// https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#pointerevent
void CConnectLibVNCServer::wheelEvent(QWheelEvent *event)
{
//qDebug(log) << "CConnectLibVnc::slotWheelEvent" << buttons << pos << angleDelta;
if(!m_pClient) return;
if(m_pParameter && m_pParameter->GetOnlyView()) return;
int mask = 0;
Expand All @@ -622,7 +631,9 @@ void CConnectLibVNCServer::wheelEvent(QWheelEvent *event)
mask |= 0x2;
if(event->buttons() & Qt::MouseButton::RightButton)
mask |= 0x4;

if(event->buttons() & Qt::MouseButton::BackButton)
mask |= 0x80;

QPoint d = event->angleDelta();
if(d.y() > 0)
mask |= 0x8;
Expand All @@ -640,6 +651,8 @@ void CConnectLibVNCServer::wheelEvent(QWheelEvent *event)
pos = event->pos();
#endif

qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->angleDelta() << pos;

SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
}

Expand Down Expand Up @@ -914,6 +927,7 @@ void CConnectLibVNCServer::keyPressEvent(QKeyEvent *event)
if (event->modifiers() & Qt::ShiftModifier)
modifier = true;
uint32_t k = TranslateRfbKey(event->key(), modifier);
qDebug(logKey) << Q_FUNC_INFO << event << k << modifier;
SendKeyEvent(m_pClient, k, TRUE);
}

Expand All @@ -925,6 +939,7 @@ void CConnectLibVNCServer::keyReleaseEvent(QKeyEvent *event)
if (event->modifiers() & Qt::ShiftModifier)
modifier = true;
uint32_t k = TranslateRfbKey(event->key(), modifier);
qDebug(logKey) << Q_FUNC_INFO << event << k << modifier;
SendKeyEvent(m_pClient, k, FALSE);
}

Expand Down
58 changes: 33 additions & 25 deletions Plugins/TigerVnc/Client/ConnectVnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@

static Q_LOGGING_CATEGORY(log, "VNC.Connect")
static Q_LOGGING_CATEGORY(logVNC, "VNC.Log")

static Q_LOGGING_CATEGORY(logKey, "VNC.Connect.Key")
static Q_LOGGING_CATEGORY(logMouse, "VNC.Connect.Mouse")

class VncLogger: public rfb::Logger
{
public:
Expand Down Expand Up @@ -799,20 +801,21 @@ void CConnectVnc::mousePressEvent(QMouseEvent *event)
if(!writer()) return;
if(m_pPara && m_pPara->GetOnlyView()) return;

unsigned char mask = 0;
uint8_t mask = 0;
if(event->button() & Qt::MouseButton::LeftButton)
mask |= 0x1;
if(event->button() & Qt::MouseButton::MiddleButton)
mask |= 0x2;
if(event->button() & Qt::MouseButton::RightButton)
mask |= 0x4;

if(event->button() & Qt::MouseButton::BackButton)
mask |= 0x80;

QPoint pos = event->pos();
rfb::Point p(pos.x(), pos.y());

/*
qDebug(log) << "CConnectVnc::slotMousePressEvent buttons:"
<< event->buttons() << event->button() << pos << mask;//*/
qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;

try{
writer()->writePointerEvent(p, mask);
} catch (rdr::Exception& e) {
Expand All @@ -824,12 +827,10 @@ void CConnectVnc::mouseReleaseEvent(QMouseEvent *event)
{
if(!writer()) return;
if(m_pPara && m_pPara->GetOnlyView()) return;
int mask = 0;
uint8_t mask = 0;
QPoint pos = event->pos();
rfb::Point p(pos.x(), pos.y());
/*
qDebug(log) << "CConnectVnc::slotMouseReleaseEvent buttons:"
<< event->buttons() << event->button() << pos << mask;//*/
qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;
try{
writer()->writePointerEvent(p, mask);
} catch (rdr::Exception& e) {
Expand All @@ -841,18 +842,21 @@ void CConnectVnc::mouseMoveEvent(QMouseEvent *event)
{
if(!writer()) return;
if(m_pPara && m_pPara->GetOnlyView()) return;
int mask = 0;

QPoint pos = event->pos();
rfb::Point p(pos.x(), pos.y());
uint8_t mask = 0;
if(event->buttons() & Qt::MouseButton::LeftButton)
mask |= 0x1;
if(event->buttons() & Qt::MouseButton::MiddleButton)
mask |= 0x2;
if(event->buttons() & Qt::MouseButton::RightButton)
mask |= 0x4;
/*
qDebug(log) << "CConnectVnc::slotMouseMoveEvent buttons:"
<< event->buttons() << event->button() << pos << mask;//*/
if(event->buttons() & Qt::MouseButton::BackButton)
mask |= 0x80;

qDebug(logMouse) << Q_FUNC_INFO << event->buttons() << event->button() << pos << mask;

try{
writer()->writePointerEvent(p, mask);
} catch (rdr::Exception& e) {
Expand All @@ -863,19 +867,17 @@ void CConnectVnc::mouseMoveEvent(QMouseEvent *event)
// https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#pointerevent
void CConnectVnc::wheelEvent(QWheelEvent *event)
{
/*
qDebug(log) << "CConnectVnc::slotWheelEvent buttons:"
<< event->buttons() << event->angleDelta() << pos;//*/
if(!writer()) return;
if(m_pPara && m_pPara->GetOnlyView()) return;
int mask = 0;

uint8_t mask = 0;
if(event->buttons() & Qt::MouseButton::LeftButton)
mask |= 0x1;
if(event->buttons() & Qt::MouseButton::MiddleButton)
mask |= 0x2;
if(event->buttons() & Qt::MouseButton::RightButton)
mask |= 0x4;
if(event->buttons() & Qt::MouseButton::BackButton)
mask |= 0x80;

QPoint d = event->angleDelta();
if(d.y() > 0)
Expand All @@ -895,6 +897,12 @@ void CConnectVnc::wheelEvent(QWheelEvent *event)
#endif

rfb::Point p(pos.x(), pos.y());
//*
qDebug(logMouse) << Q_FUNC_INFO << event->buttons()
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
<< event->button()
#endif
<< pos << mask; //*/

try{
writer()->writePointerEvent(p, mask);
Expand All @@ -910,15 +918,15 @@ void CConnectVnc::keyPressEvent(QKeyEvent *event)
bool modifier = false;
if (event->modifiers() & Qt::ShiftModifier)
modifier = true;
//qDebug(log) << "slotKeyPressEvent key:" << key << modifiers;

uint32_t k = TranslateRfbKey(event->key(), modifier);

qDebug(logKey) << Q_FUNC_INFO << event << k << modifier;

try{
writer()->writeKeyEvent(k, 0, true);
} catch (rdr::Exception& e) {
emit sigError(-1, e.str());
}

}

void CConnectVnc::keyReleaseEvent(QKeyEvent *event)
Expand All @@ -928,15 +936,15 @@ void CConnectVnc::keyReleaseEvent(QKeyEvent *event)
bool modifier = false;
if (event->modifiers() & Qt::ShiftModifier)
modifier = true;
//qDebug(log) << "slotKeyReleaseEvent key:" << key << modifiers;

uint32_t k = TranslateRfbKey(event->key(), modifier);

qDebug(logKey) << Q_FUNC_INFO << event << k << modifier;

try{
writer()->writeKeyEvent(k, 0, false);
} catch (rdr::Exception& e) {
emit sigError(-1, e.str());
}

}

QString CConnectVnc::ConnectInformation()
Expand Down
5 changes: 5 additions & 0 deletions etc/RabbitRemoteControl_logqt.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Client.Connect.Desktop.Mouse=false
Client.FrmViewer.Key=false
Client.FrmViewer.Mouse=false

VNC.Connect.Key=false
VNC.Connect.Mouse=false
LibVNCServer.Connect.Key=false
LibVNCServer.Connect.Mouse=false

;FreeRDP*=true
;FreeRDP.Log.*=false
;FreeRDP.Log.debug=true
Expand Down
5 changes: 5 additions & 0 deletions etc/RabbitRemoteControl_logqt_debug.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Client.Connect.Desktop.Mouse=false
Client.FrmViewer.Key=false
Client.FrmViewer.Mouse=false

VNC.Connect.Key=false
VNC.Connect.Mouse=false
LibVNCServer.Connect.Key=false
LibVNCServer.Connect.Mouse=false

;FreeRDP*=true
;FreeRDP.Log=true
;FreeRDP.Log.debug=true
Expand Down
2 changes: 1 addition & 1 deletion share/applications/org.Rabbit.RemoteControl.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Terminal=false
StartupNotify=true

# https://specifications.freedesktop.org/menu-spec/latest/apa.html
Categories=Network;Utility;P2P;Qt;RemoteAccess
Categories=Network;Utility;P2P;Qt;RemoteAccess;AudioVideo;Video;Audio;Player;Recorder

# https://www.freedesktop.org/wiki/Specifications/mime-apps-spec/
# https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ parts:
plugin: cmake
source: https://github.com/FreeRDP/FreeRDP.git
source-type: git
source-tag: 3.10.3
source-tag: 3.11.0
source-depth: 1
build-packages:
- libssl-dev
Expand Down

0 comments on commit d2e4eef

Please sign in to comment.