-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Wayland: improve keyboard handling #7970
Conversation
|
||
// Need to implement state.repeat_delay and state.repeat_rate | ||
// todo!(linux) | ||
state.repeat_current_keysym = Some(key_sym); |
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.
Key repeat must be handled by the wayland client.
I'd do it myself but I don't understand async rust and the executor well enough. IIUC, to schedule a task to run after a timeout I should do something like this? Or should I cancel the task in the key-release event? If so, how do I cancel a task?
state.platform_inner.foreground_executor.spawn(async move {
Timer::after(state.repeat_delay).await;
if let Some(key_sym) = state.repeat_current_keysym {
trigger_keypress_repeat();
}
})
xkb::Keysym::BackSpace | ||
| xkb::Keysym::Escape | ||
| xkb::Keysym::Home | ||
| xkb::Keysym::End | ||
| xkb::Keysym::Delete | ||
| xkb::Keysym::Insert | ||
| xkb::Keysym::Menu | ||
| xkb::Keysym::Left | ||
| xkb::Keysym::Right | ||
| xkb::Keysym::Down | ||
| xkb::Keysym::Up | ||
| xkb::Keysym::Page_Down | ||
| xkb::Keysym::Page_Up | ||
| xkb::Keysym::Super_L | ||
| xkb::Keysym::Super_R |
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.
tab
and space
are inputed as \t
and \s
, should they be in this list? What we really want is a is_keysym_printable()
function, but it always ends up as a list.
There's missing keysyms here. We might want to use a list from somewhere that has already done this more thouroughly, e.g. from chromium.
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'm also looking into translating control characters into the key pressed, so that we could use ctrl-(key) keymaps. (https://www.geeksforgeeks.org/control-characters/) #7975
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.
Isn't the code below doing the work that you're trying to do there?
See line 407-408 of this file post patch, right below.
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.
Yep, it does... My bad, and thank you, i'll close my PR
} else if key_sym == xkb::Keysym::Super_L | ||
|| key_sym == xkb::Keysym::Super_R | ||
{ | ||
state.modifiers.command = true; |
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 the time being, this allows to test keyboard shortcuts (and features) by using super
instead of cmd
as there isn't a linux keymap yet.
Not sure what behavior we want, but we could use the same convention as the web: both the super and command keys map to the "meta" modifier.
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.
It doesn't seem like a good desicion because it doesn't work on all platforms (e.g. Gnome)
Found this PR just as I was adding the else if for super to command modifier 😄 . I agree that super, cmd and windows key should map to a meta key. Also, I would add a comment to gpui/src/platform/keystroke.rs, right above the pub struct Modifiers {
....
/// The command key, on macos
/// the windows key, on windows
/// the super key, on linux
pub command: bool,
....
} |
I've just opened #7989, which I think might solve the same problems as this issue without having to maintain a list of keycodes here. |
That works for me, avoiding storing the modifiers is a better approach as it will make |
Makes keyboard somewhat more usable under wayland.