Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a raw_modifiers argument to update_modifiers #474

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler, BTN_LEFT},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -461,6 +461,7 @@ impl KeyboardHandler for DataDeviceWindow {
_: &wl_keyboard::WlKeyboard,
_serial: u32,
modifiers: Modifiers,
_raw_modifiers: RawModifiers,
_layout: u32,
) {
self.modifiers = modifiers;
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 @@ -8,7 +8,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Modifiers, RawModifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -349,6 +349,7 @@ impl<T: Test + 'static> KeyboardHandler for SimpleWindow<T> {
_: &wl_keyboard::WlKeyboard,
_serial: u32,
modifiers: Modifiers,
_raw_modifiers: RawModifiers,
_layout: u32,
) {
println!("Update modifiers: {modifiers:?}");
Expand Down
3 changes: 2 additions & 1 deletion 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, Keysym, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -344,6 +344,7 @@ impl KeyboardHandler for SimpleLayer {
_: &wl_keyboard::WlKeyboard,
_serial: u32,
modifiers: Modifiers,
_raw_modifiers: RawModifiers,
_layout: u32,
) {
println!("Update modifiers: {modifiers:?}");
Expand Down
3 changes: 2 additions & 1 deletion examples/simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
pointer::{PointerEvent, PointerEventKind, PointerHandler},
Capability, SeatHandler, SeatState,
},
Expand Down Expand Up @@ -388,6 +388,7 @@ impl KeyboardHandler for SimpleWindow {
_: &wl_keyboard::WlKeyboard,
_serial: u32,
modifiers: Modifiers,
_raw_modifiers: RawModifiers,
_layout: u32,
) {
println!("Update modifiers: {modifiers:?}");
Expand Down
3 changes: 2 additions & 1 deletion examples/themed_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use smithay_client_toolkit::{
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
pointer::{
CursorIcon, PointerData, PointerEvent, PointerEventKind, PointerHandler, ThemeSpec,
ThemedPointer,
Expand Down Expand Up @@ -483,6 +483,7 @@ impl KeyboardHandler for SimpleWindow {
_: &wl_keyboard::WlKeyboard,
_serial: u32,
_: Modifiers,
_raw_modifiers: RawModifiers,
_layout: u32,
) {
}
Expand Down
18 changes: 17 additions & 1 deletion src/seat/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ pub trait KeyboardHandler: Sized {
///
/// This happens when one of the modifier keys, such as "Shift", "Control" or "Alt" is pressed or
/// released.
#[allow(clippy::too_many_arguments)]
fn update_modifiers(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &wl_keyboard::WlKeyboard,
serial: u32,
modifiers: Modifiers,
raw_modifiers: RawModifiers,
layout: u32,
);

Expand Down Expand Up @@ -257,6 +259,14 @@ pub struct KeyEvent {
pub utf8: Option<String>,
}

/// State of keyboard modifiers, in raw form sent by compositor.
#[derive(Debug, Clone, Copy, Default)]
pub struct RawModifiers {
pub depressed: u32,
pub latched: u32,
pub locked: u32,
}

/// The state of keyboard modifiers
///
/// Each field of this indicates whether a specified modifier is active.
Expand Down Expand Up @@ -830,9 +840,15 @@ where
// Drop guard before calling user code.
drop(guard);

let raw_modifiers = RawModifiers {
depressed: mods_depressed,
latched: mods_latched,
locked: mods_locked,
};

// Always issue the modifiers update for the user.
let modifiers = udata.update_modifiers();
data.update_modifiers(conn, qh, keyboard, serial, modifiers, group);
data.update_modifiers(conn, qh, keyboard, serial, modifiers, raw_modifiers, group);
}

wl_keyboard::Event::RepeatInfo { rate, delay } => {
Expand Down
Loading