Skip to content

Commit 25079ae

Browse files
ids1024wash2
authored andcommitted
Add a raw_modifiers argument to update_modifiers
This can be used for things like nested compositors, that want to propagate the modifier state as expressed by the compositor.
1 parent 618a876 commit 25079ae

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

examples/data_device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use smithay_client_toolkit::{
3131
registry::{ProvidesRegistryState, RegistryState},
3232
registry_handlers,
3333
seat::{
34-
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
34+
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
3535
pointer::{PointerEvent, PointerEventKind, PointerHandler, BTN_LEFT},
3636
Capability, SeatHandler, SeatState,
3737
},
@@ -461,6 +461,7 @@ impl KeyboardHandler for DataDeviceWindow {
461461
_: &wl_keyboard::WlKeyboard,
462462
_serial: u32,
463463
modifiers: Modifiers,
464+
_raw_modifiers: RawModifiers,
464465
_layout: u32,
465466
) {
466467
self.modifiers = modifiers;

examples/generic_simple_window.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use smithay_client_toolkit::{
88
registry::{ProvidesRegistryState, RegistryState},
99
registry_handlers,
1010
seat::{
11-
keyboard::{KeyEvent, KeyboardHandler, Modifiers},
11+
keyboard::{KeyEvent, KeyboardHandler, Modifiers, RawModifiers},
1212
pointer::{PointerEvent, PointerEventKind, PointerHandler},
1313
Capability, SeatHandler, SeatState,
1414
},
@@ -349,6 +349,7 @@ impl<T: Test + 'static> KeyboardHandler for SimpleWindow<T> {
349349
_: &wl_keyboard::WlKeyboard,
350350
_serial: u32,
351351
modifiers: Modifiers,
352+
_raw_modifiers: RawModifiers,
352353
_layout: u32,
353354
) {
354355
println!("Update modifiers: {modifiers:?}");

examples/simple_layer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use smithay_client_toolkit::{
1010
registry::{ProvidesRegistryState, RegistryState},
1111
registry_handlers,
1212
seat::{
13-
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
13+
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
1414
pointer::{PointerEvent, PointerEventKind, PointerHandler},
1515
Capability, SeatHandler, SeatState,
1616
},
@@ -344,6 +344,7 @@ impl KeyboardHandler for SimpleLayer {
344344
_: &wl_keyboard::WlKeyboard,
345345
_serial: u32,
346346
modifiers: Modifiers,
347+
_raw_modifiers: RawModifiers,
347348
_layout: u32,
348349
) {
349350
println!("Update modifiers: {modifiers:?}");

examples/simple_window.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use smithay_client_toolkit::{
1212
registry::{ProvidesRegistryState, RegistryState},
1313
registry_handlers,
1414
seat::{
15-
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
15+
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
1616
pointer::{PointerEvent, PointerEventKind, PointerHandler},
1717
Capability, SeatHandler, SeatState,
1818
},
@@ -388,6 +388,7 @@ impl KeyboardHandler for SimpleWindow {
388388
_: &wl_keyboard::WlKeyboard,
389389
_serial: u32,
390390
modifiers: Modifiers,
391+
_raw_modifiers: RawModifiers,
391392
_layout: u32,
392393
) {
393394
println!("Update modifiers: {modifiers:?}");

examples/themed_window.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use smithay_client_toolkit::{
1919
registry::{ProvidesRegistryState, RegistryState},
2020
registry_handlers,
2121
seat::{
22-
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers},
22+
keyboard::{KeyEvent, KeyboardHandler, Keysym, Modifiers, RawModifiers},
2323
pointer::{
2424
CursorIcon, PointerData, PointerEvent, PointerEventKind, PointerHandler, ThemeSpec,
2525
ThemedPointer,
@@ -483,6 +483,7 @@ impl KeyboardHandler for SimpleWindow {
483483
_: &wl_keyboard::WlKeyboard,
484484
_serial: u32,
485485
_: Modifiers,
486+
_raw_modifiers: RawModifiers,
486487
_layout: u32,
487488
) {
488489
}

src/seat/keyboard/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,15 @@ pub trait KeyboardHandler: Sized {
181181
///
182182
/// This happens when one of the modifier keys, such as "Shift", "Control" or "Alt" is pressed or
183183
/// released.
184+
#[allow(clippy::too_many_arguments)]
184185
fn update_modifiers(
185186
&mut self,
186187
conn: &Connection,
187188
qh: &QueueHandle<Self>,
188189
keyboard: &wl_keyboard::WlKeyboard,
189190
serial: u32,
190191
modifiers: Modifiers,
192+
raw_modifiers: RawModifiers,
191193
layout: u32,
192194
);
193195

@@ -257,6 +259,14 @@ pub struct KeyEvent {
257259
pub utf8: Option<String>,
258260
}
259261

262+
/// State of keyboard modifiers, in raw form sent by compositor.
263+
#[derive(Debug, Clone, Copy, Default)]
264+
pub struct RawModifiers {
265+
pub depressed: u32,
266+
pub latched: u32,
267+
pub locked: u32,
268+
}
269+
260270
/// The state of keyboard modifiers
261271
///
262272
/// Each field of this indicates whether a specified modifier is active.
@@ -830,9 +840,15 @@ where
830840
// Drop guard before calling user code.
831841
drop(guard);
832842

843+
let raw_modifiers = RawModifiers {
844+
depressed: mods_depressed,
845+
latched: mods_latched,
846+
locked: mods_locked,
847+
};
848+
833849
// Always issue the modifiers update for the user.
834850
let modifiers = udata.update_modifiers();
835-
data.update_modifiers(conn, qh, keyboard, serial, modifiers, group);
851+
data.update_modifiers(conn, qh, keyboard, serial, modifiers, raw_modifiers, group);
836852
}
837853

838854
wl_keyboard::Event::RepeatInfo { rate, delay } => {

0 commit comments

Comments
 (0)