Skip to content

Commit

Permalink
Use xkeysym for keyboard handling
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Aug 11, 2023
1 parent 2854623 commit 7f47be7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 3,031 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#### Breaking Changes

- `wayland-rs` dependencies are updated to 0.30 and all APIs have changed significantly as a result
- `xkeysym::Keysym` is used as a keyboard key representation instead of `u32`

#### Additions

Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ wayland-protocols-wlr = { version = "0.1.0", features = ["client"] }
wayland-scanner = "0.30.0"
wayland-csd-frame = { version = "0.2.2", default-features = false, features = ["wayland-backend_0_1"] }

xkbcommon = { version = "0.5", optional = true, features = ["wayland"] }
xkbcommon = { version = "0.5.0", optional = true, features = ["wayland"], git = "https://github.com/notgull/xkbcommon-rs.git", branch = "xkeysym" }
calloop = { version = "0.10.5", optional = true }
xkeysym = { git = "https://github.com/notgull/xkeysym.git", version = "0.1.1" }

[features]
default = ["calloop", "xkbcommon"]
Expand Down
4 changes: 2 additions & 2 deletions examples/data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler, BTN_LEFT},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -351,7 +351,7 @@ impl KeyboardHandler for DataDeviceWindow {
surface: &wl_surface::WlSurface,
_: u32,
_: &[u32],
_keysyms: &[u32],
_keysyms: &[Keysym],
) {
if self.window.wl_surface() == surface {
self.keyboard_focus = true;
Expand Down
3 changes: 2 additions & 1 deletion examples/generic_simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use wayland_client::{
protocol::{wl_keyboard, wl_output, wl_pointer, wl_seat, wl_shm, wl_surface},
Connection, QueueHandle,
};
use xkeysym::Keysym;

fn main() {
env_logger::init();
Expand Down Expand Up @@ -277,7 +278,7 @@ impl<T: Test + 'static> KeyboardHandler for SimpleWindow<T> {
surface: &wl_surface::WlSurface,
_: u32,
_: &[u32],
keysyms: &[u32],
keysyms: &[Keysym],
) {
if self.window.wl_surface() == surface {
println!("Keyboard focus on window with pressed syms: {keysyms:?}");
Expand Down
7 changes: 3 additions & 4 deletions examples/simple_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler},
Capability, SeatHandler, SeatState,
},
Expand All @@ -28,7 +28,6 @@ use wayland_client::{
protocol::{wl_keyboard, wl_output, wl_pointer, wl_seat, wl_shm, wl_surface},
Connection, QueueHandle,
};
use xkbcommon::xkb::keysyms;

fn main() {
env_logger::init();
Expand Down Expand Up @@ -270,7 +269,7 @@ impl KeyboardHandler for SimpleLayer {
surface: &wl_surface::WlSurface,
_: u32,
_: &[u32],
keysyms: &[u32],
keysyms: &[Keysym],
) {
if self.layer.wl_surface() == surface {
println!("Keyboard focus on window with pressed syms: {keysyms:?}");
Expand Down Expand Up @@ -302,7 +301,7 @@ impl KeyboardHandler for SimpleLayer {
) {
println!("Key press: {event:?}");
// press 'esc' to exit
if event.keysym == keysyms::KEY_Escape {
if event.keysym == Keysym::Escape {
self.exit = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -287,7 +287,7 @@ impl KeyboardHandler for SimpleWindow {
surface: &wl_surface::WlSurface,
_: u32,
_: &[u32],
keysyms: &[u32],
keysyms: &[Keysym],
) {
if self.window.wl_surface() == surface {
println!("Keyboard focus on window with pressed syms: {keysyms:?}");
Expand Down
4 changes: 2 additions & 2 deletions examples/themed_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
pointer::{
CursorIcon, PointerData, PointerEvent, PointerEventKind, PointerHandler, ThemeSpec,
ThemedPointer,
Expand Down Expand Up @@ -410,7 +410,7 @@ impl KeyboardHandler for SimpleWindow {
surface: &wl_surface::WlSurface,
_: u32,
_: &[u32],
keysyms: &[u32],
keysyms: &[Keysym],
) {
if self.window.wl_surface() == surface {
println!("Keyboard focus on window with pressed syms: {keysyms:?}");
Expand Down
Loading

0 comments on commit 7f47be7

Please sign in to comment.