mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 13:45: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(
|
keeb->keyboardEvents.key.registerStaticListener(
|
||||||
[this](void* owner, std::any data) {
|
[this](void* owner, std::any data) {
|
||||||
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
||||||
|
|
||||||
onKeyboardKey(data, PKEEB);
|
onKeyboardKey(data, PKEEB);
|
||||||
},
|
},
|
||||||
keeb.get());
|
keeb.get());
|
||||||
|
@ -807,6 +808,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
||||||
keeb->keyboardEvents.modifiers.registerStaticListener(
|
keeb->keyboardEvents.modifiers.registerStaticListener(
|
||||||
[this](void* owner, std::any data) {
|
[this](void* owner, std::any data) {
|
||||||
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
auto PKEEB = ((IKeyboard*)owner)->self.lock();
|
||||||
|
|
||||||
onKeyboardMod(PKEEB);
|
onKeyboardMod(PKEEB);
|
||||||
},
|
},
|
||||||
keeb.get());
|
keeb.get());
|
||||||
|
|
|
@ -12,10 +12,12 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
resource->setDestroy([this](CZwpVirtualKeyboardV1* r) {
|
resource->setDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||||
|
releasePressed();
|
||||||
events.destroy.emit();
|
events.destroy.emit();
|
||||||
PROTO::virtualKeyboard->destroyResource(this);
|
PROTO::virtualKeyboard->destroyResource(this);
|
||||||
});
|
});
|
||||||
resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) {
|
resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||||
|
releasePressed();
|
||||||
events.destroy.emit();
|
events.destroy.emit();
|
||||||
PROTO::virtualKeyboard->destroyResource(this);
|
PROTO::virtualKeyboard->destroyResource(this);
|
||||||
});
|
});
|
||||||
|
@ -101,6 +103,22 @@ wl_client* CVirtualKeyboardV1Resource::client() {
|
||||||
return resource->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) {
|
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;
|
SP<CZwpVirtualKeyboardV1> resource;
|
||||||
wlr_keyboard keyboard;
|
wlr_keyboard keyboard;
|
||||||
|
|
||||||
|
void releasePressed();
|
||||||
|
|
||||||
bool hasKeymap = false;
|
bool hasKeymap = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue