mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 07:05:58 +01:00
virtual-keyboard: release keys before destroy
This commit is contained in:
parent
67a5377b41
commit
c98acaed62
3 changed files with 22 additions and 0 deletions
|
@ -800,6 +800,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
|||
keeb->keyboardEvents.key.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
||||
|
||||
onKeyboardKey(data, PKEEB);
|
||||
},
|
||||
keeb.get());
|
||||
|
@ -807,6 +808,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
|||
keeb->keyboardEvents.modifiers.registerStaticListener(
|
||||
[this](void* owner, std::any data) {
|
||||
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
||||
|
||||
onKeyboardMod(PKEEB);
|
||||
},
|
||||
keeb.get());
|
||||
|
|
|
@ -12,10 +12,12 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
|
|||
return;
|
||||
|
||||
resource->setDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
releasePressed();
|
||||
events.destroy.emit();
|
||||
PROTO::virtualKeyboard->destroyResource(this);
|
||||
});
|
||||
resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
releasePressed();
|
||||
events.destroy.emit();
|
||||
PROTO::virtualKeyboard->destroyResource(this);
|
||||
});
|
||||
|
@ -101,6 +103,22 @@ wl_client* CVirtualKeyboardV1Resource::client() {
|
|||
return resource->client();
|
||||
}
|
||||
|
||||
void CVirtualKeyboardV1Resource::releasePressed() {
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
size_t keycodesNum = keyboard.num_keycodes;
|
||||
|
||||
for (size_t i = 0; i < keycodesNum; ++i) {
|
||||
struct wlr_keyboard_key_event event = {
|
||||
.time_msec = (now.tv_sec * 1000 + now.tv_nsec / 1000000),
|
||||
.keycode = keyboard.keycodes[keycodesNum - i - 1],
|
||||
.update_state = false,
|
||||
.state = WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
};
|
||||
wlr_keyboard_notify_key(&keyboard, &event); // updates num_keycodes
|
||||
}
|
||||
}
|
||||
|
||||
CVirtualKeyboardProtocol::CVirtualKeyboardProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ class CVirtualKeyboardV1Resource {
|
|||
SP<CZwpVirtualKeyboardV1> resource;
|
||||
wlr_keyboard keyboard;
|
||||
|
||||
void releasePressed();
|
||||
|
||||
bool hasKeymap = false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue