input-capture: simplify sendKeymap

This commit is contained in:
Gwilherm Folliot 2025-03-06 17:02:19 +01:00
parent 7206966a45
commit cde6ee81d1
No known key found for this signature in database
GPG key ID: 90236D3623DCD660

View file

@ -45,28 +45,7 @@ void CInputCaptureProtocol::sendMotion(const Vector2D& absolutePosition, const V
void CInputCaptureProtocol::sendKeymap(SP<IKeyboard> keyboard, const UP<CHyprlandInputCaptureManagerV1>& manager) {
if (!keyboard)
return;
hyprlandInputCaptureManagerV1KeymapFormat format;
int fd;
uint32_t size;
if (keyboard) {
format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1;
fd = keyboard->xkbKeymapFD.get();
size = keyboard->xkbKeymapString.length() + 1;
} else {
format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_NO_KEYMAP;
fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
LOGM(ERR, "Failed to open /dev/null");
return;
}
size = 0;
}
manager->sendKeymap(format, fd, size);
if (!keyboard)
close(fd);
manager->sendKeymap(HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1, keyboard->xkbKeymapFD.get(), keyboard->xkbKeymapString.length() + 1);
}
void CInputCaptureProtocol::forceRelease() {