From c08d864821e2a69251c4e40238fcdc4941761af1 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 15 Feb 2022 21:06:26 +0600 Subject: [PATCH 1/2] qt: Fix VNC keyboard input --- src/qt/qt_mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 05caf67e1..6a54bf200 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -808,7 +808,6 @@ std::array x11_to_xt_vnc 0, 0, 0, - 0, 0x1D, 0x11D, 0x2A, From 0b664b5a1221973feb2924aa8e1bd3a2a3551cd0 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 00:10:30 +0600 Subject: [PATCH 2/2] qt: Try fixing mouse support on VNC --- src/qt/xinput2_mouse.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/qt/xinput2_mouse.cpp b/src/qt/xinput2_mouse.cpp index 361917bfc..ff67b6a2c 100644 --- a/src/qt/xinput2_mouse.cpp +++ b/src/qt/xinput2_mouse.cpp @@ -34,6 +34,7 @@ extern MainWindow* main_window; extern "C" { #include +#include #include #include #include @@ -50,7 +51,7 @@ static QThread* procThread = nullptr; static bool xi2childinit = false; static XIEventMask ximask; static std::atomic exitfromthread = false; -static std::atomic xi2_mouse_x = 0, xi2_mouse_y = 0; +static std::atomic xi2_mouse_x = 0, xi2_mouse_y = 0, xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0; static int xi2opcode = 0; static double prev_rel_coords[2] = { 0., 0. }; static Time prev_time = 0; @@ -91,6 +92,7 @@ void xinput2_proc() XISetMask(ximask.mask, XI_RawButtonPress); XISetMask(ximask.mask, XI_RawButtonRelease); XISetMask(ximask.mask, XI_RawMotion); + if (XKeysymToKeycode(disp, XK_Home) == 69) XISetMask(ximask.mask, XI_Motion); XISelectEvents(disp, win, &ximask, 1); @@ -119,6 +121,18 @@ void xinput2_proc() prev_rel_coords[1] = relative_coords[1]; prev_time = rawev->time; } + case XI_Motion: { + if (XKeysymToKeycode(disp, XK_Home) == 69) { + // No chance we will get raw motion events on VNC. + const XIDeviceEvent *motionev = (const XIDeviceEvent*)cookie->data; + if (xi2_mouse_abs_x != 0 || xi2_mouse_abs_y != 0) { + xi2_mouse_x = xi2_mouse_x + (motionev->event_x - xi2_mouse_abs_x); + xi2_mouse_y = xi2_mouse_y + (motionev->event_y - xi2_mouse_abs_y); + } + xi2_mouse_abs_x = motionev->event_x; + xi2_mouse_abs_y = motionev->event_y; + } + } } }