-
Notifications
You must be signed in to change notification settings - Fork 109
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
Make numlock state on boot configurable #1107
base: master
Are you sure you want to change the base?
Conversation
Would it maybe be better to always just use the state from last boot, rather than needing additional settings? |
Maybe to have the same (clean) state when booting. I don't think having an option for this is a bad thing as long as it configurable via config files |
Could this PR possible fix the bug when num-lock resets to default(or it just turns off?) when switching keyboard languages? |
@git-f0x I just based it off my own preference and by what's available in other systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. :)
src/shell/seats.rs
Outdated
@@ -172,7 +172,7 @@ pub fn create_seat( | |||
output: &Output, | |||
config: &Config, | |||
name: String, | |||
) -> Seat<State> { | |||
) -> (Seat<State>, KeyboardHandle<State>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not change this api. We can simply call initial_seat.get_keyboard()
afterwards to get the keyboard.
src/input/mod.rs
Outdated
@@ -1449,6 +1449,19 @@ impl State { | |||
event.time() as u64 * 1000, | |||
); | |||
|
|||
// If the numlock key is pressed ... | |||
if event.key_code() == Keycode::new(77) && event.state() == KeyState::Pressed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This completely ignores the fact, that we might filter out this event, which would cause the state to mismatch with the actual numlock state.
Instead we should check if the modifiers_state
has changed after processing keyboard input, e.g. after line 242.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hint: We also don't want to write the file on every potential keyboard event, so we need to compare the old value with the new one, without numlock_mut()
.
src/backend/mod.rs
Outdated
let time = state.common.clock.now().as_millis(); | ||
let _ = keyboard.input( | ||
state, | ||
smithay_input::Keycode::new(77), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike magic numbers, can you please add a const KEY_NUMLOCK = 69
to the beginning of this file and do KEY_NUMLOCK + 8
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, KEY_NUMLOCK + 8
is equally magical as 77
is. But maybe in this context 8
is somewhat standart offset. That is not for me to judge
This will expose 3 settings for numlock behavior: 1. Numlock is off on boot (this is the current default behavior) 2. Numlock is on on boot 3. Numlock will restore the state from the last boot Fixes pop-os#369
Get keyboard after create_seat called rather than returning from create_seat. Use constants rather than magic numbers for keypress. Only save updated modifier state after keypresses are handled/skipped.
10c9d5f
to
ae6f36a
Compare
This will expose 3 settings for numlock behavior:
Fixes #369