Skip to content

Commit 24994e6

Browse files
committed
fix: duplication keyboard
resolve: #123 keyboard release only happened after v3, and v1 will always live. So in order to fix the problem under low version keyboard, we need to keep the keyboard as only one
1 parent 5555c3f commit 24994e6

File tree

5 files changed

+48
-34
lines changed

5 files changed

+48
-34
lines changed

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ authors = [
1919
"Aakash Sen Sharma <aakashsensharma@gmail.com>",
2020
]
2121
edition = "2024"
22-
version = "0.14.1"
22+
version = "0.14.2"
2323
license = "MIT"
2424
repository = "https://github.com/waycrate/exwlshelleventloop"
2525
description = "Wayland extra shell lib"
2626
keywords = ["wayland", "wlroots"]
2727
readme = "README.md"
2828

2929
[workspace.dependencies]
30-
layershellev = { version = "0.14.1", path = "./layershellev" }
31-
sessionlockev = { version = "0.14.1", path = "./sessionlockev" }
32-
33-
iced_layershell = { version = "0.14.1", path = "./iced_layershell" }
34-
iced_exdevtools = { version = "0.14.1", path = "./iced_exdevtools" }
35-
iced_layershell_macros = { version = "0.14.1", path = "./iced_layershell_macros" }
36-
iced_sessionlock = { version = "0.14.1", path = "./iced_sessionlock" }
37-
iced_sessionlock_macros = { version = "0.14.1", path = "./iced_sessionlock_macros" }
38-
waycrate_xkbkeycode = { version = "0.14.1", path = "./waycrate_xkbkeycode" }
30+
layershellev = { version = "0.14.2", path = "./layershellev" }
31+
sessionlockev = { version = "0.14.2", path = "./sessionlockev" }
32+
33+
iced_layershell = { version = "0.14.2", path = "./iced_layershell" }
34+
iced_exdevtools = { version = "0.14.2", path = "./iced_exdevtools" }
35+
iced_layershell_macros = { version = "0.14.2", path = "./iced_layershell_macros" }
36+
iced_sessionlock = { version = "0.14.2", path = "./iced_sessionlock" }
37+
iced_sessionlock_macros = { version = "0.14.2", path = "./iced_sessionlock_macros" }
38+
waycrate_xkbkeycode = { version = "0.14.2", path = "./waycrate_xkbkeycode" }
3939

4040
tempfile = "3.23.0"
4141
thiserror = "2.0.12"

layershellev/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ impl<T: 'static> Dispatch<wl_seat::WlSeat, ()> for WindowState<T> {
15591559
} else {
15601560
keyboard_installing = false;
15611561
let keyboard = state.keyboard_state.take().unwrap();
1562-
drop(keyboard);
1562+
state.keyboard_state = Some(keyboard.update(seat, qh, ()));
15631563
if let Some(surface_id) = state.current_surface_id() {
15641564
state
15651565
.message

sessionlockev/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,7 @@ impl<T: 'static> Dispatch<wl_seat::WlSeat, ()> for WindowState<T> {
792792
state.keyboard_state = Some(KeyboardState::new(seat.get_keyboard(qh, ())));
793793
} else {
794794
let keyboard = state.keyboard_state.take().unwrap();
795-
drop(keyboard);
796-
state.keyboard_state = Some(KeyboardState::new(seat.get_keyboard(qh, ())));
795+
state.keyboard_state = Some(keyboard.update(seat, qh, ()));
797796
}
798797
if let Some(surface_id) = state.current_surface_id() {
799798
state

waycrate_xkbkeycode/src/xkb_keyboard.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ use std::{
1010
ptr::{self, NonNull},
1111
time::Duration,
1212
};
13-
use wayland_client::{Proxy, protocol::wl_keyboard::WlKeyboard};
13+
use wayland_client::{Dispatch, QueueHandle};
14+
use wayland_client::{
15+
Proxy,
16+
protocol::{wl_keyboard::WlKeyboard, wl_seat::WlSeat},
17+
};
1418

1519
use crate::keymap;
1620

@@ -82,6 +86,17 @@ impl KeyboardState {
8286
repeat_token: None,
8387
}
8488
}
89+
pub fn update<U, D>(self, seat: &WlSeat, qh: &QueueHandle<D>, udata: U) -> Self
90+
where
91+
D: Dispatch<WlKeyboard, U> + 'static,
92+
U: Send + Sync + 'static,
93+
{
94+
if self.keyboard.version() >= 3 {
95+
drop(self);
96+
return Self::new(seat.get_keyboard(qh, udata));
97+
}
98+
self
99+
}
85100
}
86101

87102
impl Drop for KeyboardState {

0 commit comments

Comments
 (0)