Skip to content

Commit be33110

Browse files
committed
input-capture: send modifiers (highly experimental)
1 parent 12a1622 commit be33110

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

src/core/PortalManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ SOutput::SOutput(SP<CCWlOutput> output_) : output(output_) {
2222
refreshRate = refresh;
2323
width = width_;
2424
height = height_;
25+
Debug::log(LOG, "??? {} {}", flags, refresh);
2526
});
2627
output->setGeometry(
2728
[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_) {

src/portals/InputCapture.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ CInputCapturePortal::CInputCapturePortal(SP<CCHyprlandInputCaptureManagerV1> mgr
2828
onKeymap(format == HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1 ? fd : 0, size);
2929
});
3030

31+
mgr->setModifiers([this](CCHyprlandInputCaptureManagerV1* r, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) {
32+
onModifiers(mods_depressed, mods_latched, mods_locked, group);
33+
});
34+
3135
mgr->setKey([this](CCHyprlandInputCaptureManagerV1* r, uint32_t key, hyprlandInputCaptureManagerV1KeyState state) { onKey(key, state); });
3236

3337
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) {
321325
value->key(id, pressed);
322326
}
323327

328+
void CInputCapturePortal::onModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
329+
for (const auto& [key, value] : sessions)
330+
value->modifiers(modsDepressed, modsLatched, modsLocked, group);
331+
}
332+
324333
void CInputCapturePortal::onKeymap(int32_t fd, uint32_t size) {
325334
keymap.fd = fd;
326335
keymap.size = size;
@@ -475,6 +484,13 @@ void CInputCapturePortal::SSession::key(uint32_t key, bool pressed) {
475484
eis->sendKey(key, pressed);
476485
}
477486

487+
void CInputCapturePortal::SSession::modifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
488+
if (status != ACTIVATED)
489+
return;
490+
491+
eis->sendModifiers(modsDepressed, modsLatched, modsLocked, group);
492+
}
493+
478494
void CInputCapturePortal::SSession::button(uint32_t button, bool pressed) {
479495
if (status != ACTIVATED)
480496
return;

src/portals/InputCapture.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CInputCapturePortal {
3636
void onMotion(double x, double y, double dx, double dy);
3737
void onKeymap(int32_t fd, uint32_t size);
3838
void onKey(uint32_t key, bool pressed);
39+
void onModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
3940
void onButton(uint32_t button, bool pressed);
4041
void onAxis(bool axis, double value);
4142
void onAxisValue120(bool axis, int32_t value120);
@@ -66,6 +67,7 @@ class CInputCapturePortal {
6667

6768
void motion(double dx, double dy);
6869
void key(uint32_t key, bool pressed);
70+
void modifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
6971
void keymap(Keymap keymap);
7072
void button(uint32_t button, bool pressed);
7173
void axis(bool axis, double value);

src/shared/Eis.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ void EmulatedInputServer::sendKey(uint32_t key, bool pressed) {
269269
eis_device_frame(client.keyboard, now);
270270
}
271271

272+
void EmulatedInputServer::sendModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) {
273+
if (!client.keyboard)
274+
return;
275+
uint64_t now = eis_now(eisCtx);
276+
eis_device_keyboard_send_xkb_modifiers(client.keyboard, modsDepressed, modsLatched, modsLocked, group);
277+
eis_device_frame(client.keyboard, now);
278+
}
279+
272280
void EmulatedInputServer::sendButton(uint32_t button, bool pressed) {
273281
if (!client.pointer)
274282
return;

src/shared/Eis.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class EmulatedInputServer {
2323

2424
void sendMotion(double x, double y);
2525
void sendKey(uint32_t key, bool pressed);
26+
void sendModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
2627
void sendButton(uint32_t button, bool pressed);
2728
void sendScrollDelta(double x, double y);
2829
void sendScrollDiscrete(int32_t x, int32_t y);

0 commit comments

Comments
 (0)