Skip to content

Keybindings don't work on Linux and maybe windows #21161

Closed

Description

@paulrouget

Maybe because of #21087

Activity

  1. added
    P-linux
    on Jul 11, 2018
  2. changed the title [-]Keybindings don't work on Linux (and maybe windows)[/-] [+]Keybindings don't work on Linux and maybe windows[/+] on Jul 25, 2018
  3. removed
    P-linux
    on Jul 25, 2018
  4. paulrouget commented on Jul 25, 2018

    @paulrouget
    ContributorAuthor

    I'm going to try to tackle that one, including #17146. We accumulated a lot of workarounds and winit has changed quite a bit (fixed some stuff, broke some other stuff).

    There are few bugs in winit on Mac where key down events for modifiers are not sent correctly.
    The behavior for control keys is different on Windows.
    And ReceivedCharacter is not always fired the same way depending on the platform.

    My goal is to achieve the same behavior across the 3 platforms for:

    • basic typing
    • typing with a different layout (testing with Azerty)
    • getting return, backspace and arrows to work
    • get Cmd-A and Ctrl-A to work in a textbox
    • make clipboard shortcut work
    • make sure Ctrl/Cmd-XXX shortcuts are caught and not repeated
  5. dorfsmay commented on Jul 25, 2018

    @dorfsmay

    I've had a look but made very little progress. I'm not sure how useful this will be, but just in case, here's what I have found on Linux:

    Everything happens in ports/servo/glutin_app/window.rs and components/servo/lib.rs

    • the run function in windows.rs does a callback to self.winit_event_to_servo_event on each window events.

    • printing out the event (e) in the events_loop, before the callback shows that all events are the same at this point, Key::KeyboardInput

    • the Window::handle_events interprets normal alphabet and Alt keys as [Key], but interprets the control key as a [MouseMove]!

    • I think the issue is that winit_event_to_servo_event (in ports/servo/glutin_app/window.rs) is matching for winit::WindowEvent::KeyboardInput but the Control key is still a winit::Key::KeyboardInput. I had some code that showed this, but removed it since, and haven't had time to dig there since then.

    • the control keys create a sticky state: If you press CTRL -X (x or any letter it doesn't matter) once, then all keys pressed after that show ctrl: true as a ModifiersState. The only way to change that state back to false is to again press CTRL with a key. Pressing CTRL on its own will not change the state.

    • This point above explains why CTRL-L in servo on Linux does not bring the URL menu. You can get the URL menu following this sequence:

      • start servo
      • press CTRL-L (not necessarily L, any letter at the same time as CTRL)
      • press the key 'L' on its own
      • press CTRL-L (any letter) again to switch away from the control modifier
  6. dorfsmay commented on Jul 25, 2018

    @dorfsmay

    This is a printout from adding a bunch of debugging println when pressing the following keys in this order:

    • a
    • b
    • c
    • ctrl
    • D
    • ctrl-z
    • e (check ModifiersState)
    • ctrl-x
    • f (check ModifiersState now!)
    • alt (shows as a key!)
    • g (`ModifierState is what you'd expect)
    • atl-c (again, `ModifierState is what you'd expect)
    • h (and yet again, `ModifierState is what you'd expect)
    • esc key

    I can push my branch that I used to generate this, but it is just a few println in the functions mentioned above

    key-press-printout.txt

  7. paulrouget commented on Jul 26, 2018

    @paulrouget
    ContributorAuthor

    @dorfsmay thank you. I think I might need help later with extensive testing.

  8. paulrouget commented on Jul 26, 2018

    @paulrouget
    ContributorAuthor

    PR: #21250

  9. added 3 commits that reference this issue on Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions