Skip to content

Commit 4df5dd8

Browse files
authored
refactor: follow up to PR #906 (#908)
1 parent 5d8a487 commit 4df5dd8

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

  • crates/ironrdp-client/src

crates/ironrdp-client/src/app.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl ApplicationHandler<RdpOutputEvent> for App {
171171
send_fast_path_events(&self.input_event_sender, input_events);
172172
}
173173
}
174-
WindowEvent::ModifiersChanged(state) => {
174+
WindowEvent::ModifiersChanged(modifiers) => {
175175
const SHIFT_LEFT: ironrdp::input::Scancode = ironrdp::input::Scancode::from_u8(false, 0x2A);
176176
const CONTROL_LEFT: ironrdp::input::Scancode = ironrdp::input::Scancode::from_u8(false, 0x1D);
177177
const ALT_LEFT: ironrdp::input::Scancode = ironrdp::input::Scancode::from_u8(false, 0x38);
@@ -188,10 +188,19 @@ impl ApplicationHandler<RdpOutputEvent> for App {
188188
operations.push(operation);
189189
};
190190

191-
add_operation(state.state().shift_key(), SHIFT_LEFT);
192-
add_operation(state.state().control_key(), CONTROL_LEFT);
193-
add_operation(state.state().alt_key(), ALT_LEFT);
194-
add_operation(state.state().super_key(), LOGO_LEFT);
191+
// NOTE: https://docs.rs/winit/0.30.12/src/winit/keyboard.rs.html#1737-1744
192+
//
193+
// We can’t use state.lshift_state(), state.lcontrol_state(), etc, because on some platforms such as
194+
// Linux, the modifiers change is hidden.
195+
//
196+
// > The exact modifier key is not used to represent modifiers state in the
197+
// > first place due to a fact that modifiers state could be changed without any
198+
// > key being pressed and on some platforms like Wayland/X11 which key resulted
199+
// > in modifiers change is hidden, also, not that it really matters.
200+
add_operation(modifiers.state().shift_key(), SHIFT_LEFT);
201+
add_operation(modifiers.state().control_key(), CONTROL_LEFT);
202+
add_operation(modifiers.state().alt_key(), ALT_LEFT);
203+
add_operation(modifiers.state().super_key(), LOGO_LEFT);
195204

196205
let input_events = self.input_database.apply(operations);
197206

0 commit comments

Comments
 (0)