input-capture: send modifiers (highly experimental)

This commit is contained in:
Gwilherm Folliot 2024-12-17 19:21:42 +01:00
parent 3112a41cd7
commit a1d88df0e3
No known key found for this signature in database
GPG key ID: 90236D3623DCD660
6 changed files with 29 additions and 1 deletions

View file

@ -22,6 +22,7 @@ SOutput::SOutput(SP<CCWlOutput> output_) : output(output_) {
refreshRate = refresh; refreshRate = refresh;
width = width_; width = width_;
height = height_; height = height_;
Debug::log(LOG, "??? {} {}", flags, refresh);
}); });
output->setGeometry( output->setGeometry(
[this](CCWlOutput* r, int32_t x_, int32_t y_, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make, const char* model, int32_t transform_) { [this](CCWlOutput* r, int32_t x_, int32_t y_, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char* make, const char* model, int32_t transform_) {

View file

@ -28,6 +28,10 @@ CInputCapturePortal::CInputCapturePortal(SP<CCHyprlandInputCaptureManagerV1> mgr
onKeymap(format == HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1 ? fd : 0, size); onKeymap(format == HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1 ? fd : 0, size);
}); });
mgr->setModifiers([this](CCHyprlandInputCaptureManagerV1* r, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {
onModifiers(mods_depressed, mods_latched, mods_locked, group);
});
mgr->setKey([this](CCHyprlandInputCaptureManagerV1* r, uint32_t key, hyprlandInputCaptureManagerV1KeyState state) { onKey(key, state); }); mgr->setKey([this](CCHyprlandInputCaptureManagerV1* r, uint32_t key, hyprlandInputCaptureManagerV1KeyState state) { onKey(key, state); });
mgr->setButton([this](CCHyprlandInputCaptureManagerV1* r, uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { onButton(button, state); }); mgr->setButton([this](CCHyprlandInputCaptureManagerV1* r, uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { onButton(button, state); });
@ -321,6 +325,11 @@ void CInputCapturePortal::onKey(uint32_t id, bool pressed) {
value->key(id, pressed); value->key(id, pressed);
} }
void CInputCapturePortal::onModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
for (const auto& [key, value] : sessions)
value->modifiers(modsDepressed, modsLatched, modsLocked, group);
}
void CInputCapturePortal::onKeymap(int32_t fd, uint32_t size) { void CInputCapturePortal::onKeymap(int32_t fd, uint32_t size) {
keymap.fd = fd; keymap.fd = fd;
keymap.size = size; keymap.size = size;
@ -475,6 +484,13 @@ void CInputCapturePortal::SSession::key(uint32_t key, bool pressed) {
eis->sendKey(key, pressed); eis->sendKey(key, pressed);
} }
void CInputCapturePortal::SSession::modifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
if (status != ACTIVATED)
return;
eis->sendModifiers(modsDepressed, modsLatched, modsLocked, group);
}
void CInputCapturePortal::SSession::button(uint32_t button, bool pressed) { void CInputCapturePortal::SSession::button(uint32_t button, bool pressed) {
if (status != ACTIVATED) if (status != ACTIVATED)
return; return;

View file

@ -36,6 +36,7 @@ class CInputCapturePortal {
void onMotion(double x, double y, double dx, double dy); void onMotion(double x, double y, double dx, double dy);
void onKeymap(int32_t fd, uint32_t size); void onKeymap(int32_t fd, uint32_t size);
void onKey(uint32_t key, bool pressed); void onKey(uint32_t key, bool pressed);
void onModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
void onButton(uint32_t button, bool pressed); void onButton(uint32_t button, bool pressed);
void onAxis(bool axis, double value); void onAxis(bool axis, double value);
void onAxisValue120(bool axis, int32_t value120); void onAxisValue120(bool axis, int32_t value120);
@ -66,6 +67,7 @@ class CInputCapturePortal {
void motion(double dx, double dy); void motion(double dx, double dy);
void key(uint32_t key, bool pressed); void key(uint32_t key, bool pressed);
void modifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
void keymap(Keymap keymap); void keymap(Keymap keymap);
void button(uint32_t button, bool pressed); void button(uint32_t button, bool pressed);
void axis(bool axis, double value); void axis(bool axis, double value);

View file

@ -269,6 +269,14 @@ void EmulatedInputServer::sendKey(uint32_t key, bool pressed) {
eis_device_frame(client.keyboard, now); eis_device_frame(client.keyboard, now);
} }
void EmulatedInputServer::sendModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
if (!client.keyboard)
return;
uint64_t now = eis_now(eisCtx);
eis_device_keyboard_send_xkb_modifiers(client.keyboard, modsDepressed, modsLatched, modsLocked, group);
eis_device_frame(client.keyboard, now);
}
void EmulatedInputServer::sendButton(uint32_t button, bool pressed) { void EmulatedInputServer::sendButton(uint32_t button, bool pressed) {
if (!client.pointer) if (!client.pointer)
return; return;

View file

@ -23,6 +23,7 @@ class EmulatedInputServer {
void sendMotion(double x, double y); void sendMotion(double x, double y);
void sendKey(uint32_t key, bool pressed); void sendKey(uint32_t key, bool pressed);
void sendModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
void sendButton(uint32_t button, bool pressed); void sendButton(uint32_t button, bool pressed);
void sendScrollDelta(double x, double y); void sendScrollDelta(double x, double y);
void sendScrollDiscrete(int32_t x, int32_t y); void sendScrollDiscrete(int32_t x, int32_t y);

@ -1 +1 @@
Subproject commit 0c7cf263faeae9429942c6ffbc1e9b5dfd709bf4 Subproject commit cb1b99ca037311417f9fde600732f21dc9ed983e