mousepad: Support remote text input on Wayland
With fakeinput keysym support we can now send the text, somewhat.
This commit is contained in:
parent
30d7abbb76
commit
f38361b57d
2 changed files with 54 additions and 6 deletions
|
@ -14,8 +14,10 @@ if(UNIX AND NOT APPLE)
|
||||||
BASENAME fake-input
|
BASENAME fake-input
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pkg_check_modules(XkbCommon IMPORTED_TARGET xkbcommon)
|
||||||
|
|
||||||
target_sources(kdeconnect_mousepad PRIVATE ${wayland_SRCS})
|
target_sources(kdeconnect_mousepad PRIVATE ${wayland_SRCS})
|
||||||
target_link_libraries(kdeconnect_mousepad Wayland::Client Qt5::WaylandClient)
|
target_link_libraries(kdeconnect_mousepad Wayland::Client Qt5::WaylandClient PkgConfig::XkbCommon)
|
||||||
target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp)
|
target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp)
|
||||||
set(HAVE_WAYLAND TRUE)
|
set(HAVE_WAYLAND TRUE)
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,53 @@
|
||||||
#include "qwayland-fake-input.h"
|
#include "qwayland-fake-input.h"
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
//Translation table to keep in sync within all the implementations
|
||||||
|
int SpecialKeysMap[] = {
|
||||||
|
0, // Invalid
|
||||||
|
KEY_BACKSPACE, // 1
|
||||||
|
KEY_TAB, // 2
|
||||||
|
KEY_LINEFEED, // 3
|
||||||
|
KEY_LEFT, // 4
|
||||||
|
KEY_UP, // 5
|
||||||
|
KEY_RIGHT, // 6
|
||||||
|
KEY_DOWN, // 7
|
||||||
|
KEY_PAGEUP, // 8
|
||||||
|
KEY_PAGEDOWN, // 9
|
||||||
|
KEY_HOME, // 10
|
||||||
|
KEY_END, // 11
|
||||||
|
KEY_ENTER, // 12
|
||||||
|
KEY_DELETE, // 13
|
||||||
|
KEY_ESC, // 14
|
||||||
|
KEY_SYSRQ, // 15
|
||||||
|
KEY_SCROLLLOCK, // 16
|
||||||
|
0, // 17
|
||||||
|
0, // 18
|
||||||
|
0, // 19
|
||||||
|
0, // 20
|
||||||
|
KEY_F1, // 21
|
||||||
|
KEY_F2, // 22
|
||||||
|
KEY_F3, // 23
|
||||||
|
KEY_F4, // 24
|
||||||
|
KEY_F5, // 25
|
||||||
|
KEY_F6, // 26
|
||||||
|
KEY_F7, // 27
|
||||||
|
KEY_F8, // 28
|
||||||
|
KEY_F9, // 29
|
||||||
|
KEY_F10, // 30
|
||||||
|
KEY_F11, // 31
|
||||||
|
KEY_F12, // 32
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class FakeInput : public QWaylandClientExtensionTemplate<FakeInput>, public QtWayland::org_kde_kwin_fake_input
|
class FakeInput : public QWaylandClientExtensionTemplate<FakeInput>, public QtWayland::org_kde_kwin_fake_input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FakeInput()
|
FakeInput()
|
||||||
: QWaylandClientExtensionTemplate<FakeInput>(4)
|
: QWaylandClientExtensionTemplate<FakeInput>(5)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -88,11 +129,16 @@ bool WaylandRemoteInput::handlePacket(const NetworkPacket& np)
|
||||||
m_fakeInput->button(BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED);
|
m_fakeInput->button(BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED);
|
||||||
} else if (isScroll) {
|
} else if (isScroll) {
|
||||||
m_fakeInput->axis(WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_double(-dy));
|
m_fakeInput->axis(WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_double(-dy));
|
||||||
|
} else if (specialKey) {
|
||||||
} else if (!key.isEmpty() || specialKey) {
|
m_fakeInput->keyboard_key(SpecialKeysMap[specialKey], 1);
|
||||||
// TODO: implement key support
|
m_fakeInput->keyboard_key(SpecialKeysMap[specialKey], 0);
|
||||||
|
} else if (!key.isEmpty()) {
|
||||||
|
for (const QChar character : key) {
|
||||||
|
const auto keysym = xkb_utf32_to_keysym(character.unicode());
|
||||||
|
m_fakeInput->keyboard_keysym(keysym, 1);
|
||||||
|
m_fakeInput->keyboard_keysym(keysym, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { //Is a mouse move event
|
} else { //Is a mouse move event
|
||||||
m_fakeInput->pointer_motion(wl_fixed_from_double(dx), wl_fixed_from_double(dy));
|
m_fakeInput->pointer_motion(wl_fixed_from_double(dx), wl_fixed_from_double(dy));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue