Skip to content

New feature to distinguish whether the Windows, Control, Alt, and Shift keys are the left or right keys#1985

Open
jilliss wants to merge 2 commits intoSmithay:masterfrom
jilliss:master
Open

New feature to distinguish whether the Windows, Control, Alt, and Shift keys are the left or right keys#1985
jilliss wants to merge 2 commits intoSmithay:masterfrom
jilliss:master

Conversation

@jilliss
Copy link
Copy Markdown

@jilliss jilliss commented Apr 5, 2026

For use by downstream NIRI

Description

I noticed that niri was developed based on this project.
Furthermore, niri has an outstanding issue: it does not support advanced keyboard modifiers
such as Super_L. This commit adds support for them.

Specifically, it adds a keycode parameter to keyboard input to identify the specific key
and introduces some boolean values to track key presses for use by downstream components.

see niri issues Do not support Shift_R key.

Checklist

…nd `Shift` keys are the left or right keys

For use by downstream NIRI
@jilliss
Copy link
Copy Markdown
Author

jilliss commented Apr 6, 2026

@PolyMeilex @YaLTeR could you review this?

Copy link
Copy Markdown
Member

@PolyMeilex PolyMeilex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
Could you explain when and how are those new fields cleared? At a first glance at the diff I only see them being set to true

/// This method checks if standard modifier names (e.g., Ctrl, Alt, Shift, Caps Lock)
/// are currently active in the "effective" state and updates the corresponding
/// boolean fields of the struct.
pub fn init_key_val(&mut self, state: &xkb::State) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reasons for this being part of the public API?
Going of the vibe it seems to be an internal helper function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimized the assignment logic as suggested. Thanks!

Comment on lines 102 to 119
// 1. Initialize modifier values based on current state
self.init_key_val(state);
// 2. Identify the specific physical key pressed
let keysym = state.key_get_one_sym(keycode);
// 3. Match specific modifier keys and update their respective flags
match keysym.into() {
xkb::keysyms::KEY_Super_L => self.logo_left = true,
xkb::keysyms::KEY_Super_R => self.logo_right = true,
xkb::keysyms::KEY_Control_L => self.ctrl_left = true,
xkb::keysyms::KEY_Control_R => self.ctrl_right = true,
xkb::keysyms::KEY_Alt_L => self.alt_left = true,
xkb::keysyms::KEY_Alt_R => self.alt_right = true,
xkb::keysyms::KEY_Shift_L => self.shift_left = true,
xkb::keysyms::KEY_Shift_R => self.shift_right = true,
_ => {} // Ignore non-modifier keys
}
// 4. Synchronize the serialized string representation of active modifiers
self.serialized = serialize_modifiers(state);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the meaningless LLM-style comments, and keep only the // Ignore non-modifier keys one

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jilliss jilliss requested a review from PolyMeilex April 11, 2026 06:16
@jilliss
Copy link
Copy Markdown
Author

jilliss commented Apr 15, 2026

Could you please review my code again? @PolyMeilex @Drakulix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants