Skip to content

macos: modified key issues #625

Closed

Description

@sodiumjoe

Not totally sure these are all related, but:

alacritty/alacritty#1336
alacritty/alacritty#1358
alacritty/alacritty#1428
#623

I suspect these all started with #518

@francesca64 has given some direction here

Activity

  1. sodiumjoe commented on Aug 11, 2018

    @sodiumjoe
    ContributorAuthor

    just confirmed these all started with #518 by git bisecting.

  2. sodiumjoe commented on Aug 11, 2018

    @sodiumjoe
    ContributorAuthor

    One interesting thing to note is for alacritty/alacritty#1336, this might be working as intended? When I run the multiwindow example, <CMD-`> correctly cycles me through the open windows. I say "correctly," because this is normal macos app behavior.

    Apparently <CMD-.> is used for cancel (though I can't find official documentation for that anywhere), and <C-TAB> is Move to the next control when a text field is selected .

    Since <C-TAB> and <CMD-.> is sort of application dependent behavior, I guess winit should just pass these key events through to the consuming application.

    But for <CMD-`>, I'm not sure, since this is standard app/window behavior. Should winit just handle this? Should it be default behavior with an option to opt out from an application?

  3. added
    DS - appkit
    on Aug 11, 2018
  4. francesca64 commented on Aug 11, 2018

    @francesca64
    Member

    I'm generally in favor of winit conforming to the conventions of the platform, which would entail letting the OS handle <CMD-`>. The only reason winit could previously override it was because our keyboard handling was overtly non-standard.

  5. sodiumjoe commented on Aug 13, 2018

    @sodiumjoe
    ContributorAuthor

    @francesca64 So would you consider alacritty/alacritty#1336 a wontfix then? (I think that's a reasonable position.)

  6. francesca64 commented on Aug 13, 2018

    @francesca64
    Member

    Yes. Even if I weren't against it conceptually, the potential fix is unreasonably convoluted.

  7. sodiumjoe commented on Aug 14, 2018

    @sodiumjoe
    ContributorAuthor

    So I found this, which in my testing appears to fix the <C-Tab> issue:

    before:

    WindowEvent { window_id: WindowId(Id(140332214940576)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 59, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    WindowEvent { window_id: WindowId(Id(140332214940576)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 48, state: Released, virtual_keycode: Some(Tab), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    WindowEvent { window_id: WindowId(Id(140332214940576)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 59, state: Released, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
    

    after:

    WindowEvent { window_id: WindowId(Id(140623425336880)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 59, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    WindowEvent { window_id: WindowId(Id(140623425336880)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 48, state: Pressed, virtual_keycode: Some(Tab), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    WindowEvent { window_id: WindowId(Id(140623425336880)), event: ReceivedCharacter('\t') }
    WindowEvent { window_id: WindowId(Id(140623425336880)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 48, state: Released, virtual_keycode: Some(Tab), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    WindowEvent { window_id: WindowId(Id(140623425336880)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 59, state: Released, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
    

    But it doesn't fix the <Cmd-.> issue. But I did find this, which appears to be addressing the same issue. I haven't quite figured out how to port this over yet, but I'm working on it.

  8. sodiumjoe commented on Aug 14, 2018

    @sodiumjoe
    ContributorAuthor
  9. sodiumjoe commented on Aug 14, 2018

    @sodiumjoe
    ContributorAuthor

    that branch fixes <C-Tab> and <Cmd-{key}> release, but not <Cmd-.>.

  10. sodiumjoe commented on Aug 15, 2018

    @sodiumjoe
    ContributorAuthor

    Interestingly, with <Cmd-.>, it's the keydown that's suppressed and the keyup that fires. Unfortunately, the same trick doesn't seem to work:

                    if let Some(key_window) = maybe_key_window() {
                        if event_mods(ns_event).logo && ns_event.keyCode() == 47 {
                            println!("keycode: {}", ns_event.keyCode());
                            msg_send![*key_window.window, sendEvent:ns_event];
                        }
                    }
    

    the println fires, but the key event does not.

  11. sodiumjoe commented on Aug 15, 2018

    @sodiumjoe
    ContributorAuthor

    Ok, added special handling for <Cmd-.> that appears to work.

  12. added a commit that references this issue on May 19, 2023
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

    DS - appkit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions