mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-12-27 03:49:48 +01:00
input-capture: send modifiers (highly experimental)
This commit is contained in:
parent
12a162245f
commit
7c381c7cab
6 changed files with 29 additions and 1 deletions
|
@ -22,6 +22,7 @@ SOutput::SOutput(SP<CCWlOutput> output_) : output(output_) {
|
|||
refreshRate = refresh;
|
||||
width = width_;
|
||||
height = height_;
|
||||
Debug::log(LOG, "??? {} {}", flags, refresh);
|
||||
});
|
||||
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_) {
|
||||
|
|
|
@ -28,6 +28,10 @@ CInputCapturePortal::CInputCapturePortal(SP<CCHyprlandInputCaptureManagerV1> mgr
|
|||
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->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);
|
||||
}
|
||||
|
||||
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) {
|
||||
keymap.fd = fd;
|
||||
keymap.size = size;
|
||||
|
@ -475,6 +484,13 @@ void CInputCapturePortal::SSession::key(uint32_t key, bool 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) {
|
||||
if (status != ACTIVATED)
|
||||
return;
|
||||
|
|
|
@ -36,6 +36,7 @@ class CInputCapturePortal {
|
|||
void onMotion(double x, double y, double dx, double dy);
|
||||
void onKeymap(int32_t fd, uint32_t size);
|
||||
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 onAxis(bool axis, double value);
|
||||
void onAxisValue120(bool axis, int32_t value120);
|
||||
|
@ -66,6 +67,7 @@ class CInputCapturePortal {
|
|||
|
||||
void motion(double dx, double dy);
|
||||
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 button(uint32_t button, bool pressed);
|
||||
void axis(bool axis, double value);
|
||||
|
|
|
@ -269,6 +269,14 @@ void EmulatedInputServer::sendKey(uint32_t key, bool pressed) {
|
|||
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) {
|
||||
if (!client.pointer)
|
||||
return;
|
||||
|
|
|
@ -23,6 +23,7 @@ class EmulatedInputServer {
|
|||
|
||||
void sendMotion(double x, double y);
|
||||
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 sendScrollDelta(double x, double y);
|
||||
void sendScrollDiscrete(int32_t x, int32_t y);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0c7cf263faeae9429942c6ffbc1e9b5dfd709bf4
|
||||
Subproject commit cb1b99ca037311417f9fde600732f21dc9ed983e
|
Loading…
Reference in a new issue