Skip to content

DeviceEventFilter works differently on X11 and Windows #2591

Closed

Description

@maroider

This is likely owed to none of us catching that the initial implementation (#2195) had the documentation be different from the actual behavior of the X11 backend. Specifically, the behavior of DeviceEventFilter::Always and DeviceEventFilter::Never is flipped WRT the documentation. Due to this, the subsequent Windows implementation (#2409) followed the documentation, thus leading to further inconsistency.

I'm personally of the opinion that the way it works on X11 is the most intuitive, and that the documentation and the Windows backend should be adjusted accordingly. However, I'd like to get the opinion of others before doing anything.

Activity

  1. added
    DS - win32
    DS - x11
    S - docs
    S - platform parity
    on Dec 15, 2022
  2. kchibisov commented on Dec 15, 2022

    @kchibisov
    Member

    I read the docs, and they tell the correct thing? Always should always filter, no? Never means never filter.

    I think that's how it works.

  3. ArturKovacs commented on Dec 15, 2022

    @ArturKovacs
    Contributor

    Oh boys... one of them classic double negative logics. We should probably rename the enum, since changing an implementation will be a breaking-change anyways.

    I propose the new name to be DeviceEventsAllowed.
    And change the Unfocused variant to Focused

  4. madsmtm commented on Dec 15, 2022

    @madsmtm
    Member

    Agree with @ArturKovacs, perhaps even:

    enum DeviceEvents {
        All,
        WhenFocused,
        Never,
    }
    
    impl Window {
        fn listen_device_events(...);
    }
    
    // Usage is pretty clear as
    window.listen_device_events(DeviceEvents::All);
    window.listen_device_events(DeviceEvents::WhenFocused);
    window.listen_device_events(DeviceEvents::Never);
  5. kchibisov commented on Dec 15, 2022

    @kchibisov
    Member

    Up to you, I don't really mind that change.

  6. daxpedda commented on Feb 26, 2023

    @daxpedda
    Member

    Would a PR be acceptable to at least fix it without a breaking change for a potential Winit v0.28.2?
    So meaning it should be properly flipped for X11 to follow the documentation.

    Happy to do the PR for what @madsmtm suggested too.

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 - win32DS - x11S - docsS - platform parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions