Skip to content
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

DeviceEvent should be optional, causes unneccessary CPU usage #1634

Closed
Ciantic opened this issue Jul 27, 2020 · 17 comments
Closed

DeviceEvent should be optional, causes unneccessary CPU usage #1634

Ciantic opened this issue Jul 27, 2020 · 17 comments
Labels
C - needs discussion Direction must be ironed out DS - windows S - enhancement Wouldn't this be the coolest?

Comments

@Ciantic
Copy link

Ciantic commented Jul 27, 2020

I use winit for background application for Windows 10.

Even though not a single window is visible or activated it eats CPU if I move the mouse: Process Explorer shows 0.33% of CPU usage when moving a mouse, but when I stop the mouse it goes to 0%.

This indicates that it just keeps on listening the device events, even though I don't even need them. It's not ideal for a background application to eat CPU when mouse is moved outside the application's own window.

I don't know is background applications (that occasionally show a Window) even a target for winit, but I surely would want it to be.

Thanks.


There is multiple ways to fix this, easiest but not so great is to make an emit_device_events(bool) for the EventLoop builder. Another way would be to make them toggleable at runtime, so one could toggle DeviceEvents on when necessary (e.g. when the window is activated).

@ryanisaacg ryanisaacg added DS - windows C - needs discussion Direction must be ironed out S - enhancement Wouldn't this be the coolest? labels Aug 9, 2020
@alvinhochun
Copy link
Contributor

Yeah, I don't quite understand why one would by default want to receive mouse movements and keyboard events when not in foreground.

Is this behaviour present on other platforms?

@chrisduerr
Copy link
Contributor

There's some more discussion in #1775, but it boils down to the same issue. Specifically the mouse events are the problem, not DeviceEvents in general.

@Ciantic
Copy link
Author

Ciantic commented Feb 17, 2021

To me the biggest issue is that it winit windows also acts as keylogger, they just keeps listening keyboard events they have no business to.

@chrisduerr
Copy link
Contributor

That should be irrelevant. Any application that wants to keylog on this application can, offering the ability to do so changes nothing. It's absolutely trivial to get access to. So the only thing that matters is if the application actually uses this information or not and that has nothing to do with winit providing it.

@Ciantic
Copy link
Author

Ciantic commented Feb 17, 2021

I'm pretty sure WM_KEYUP, WM_KEYDOWN, and WM_CHAR is not routed to all applications as I type right now? There is something else going on in winit than that. Each one of those messages says in Microsoft docs that:

Posted to the window with the keyboard focus

They are not globally posted by default.

Winit attaches to keyboard at lower level, and not sure why, in Windows if you use right messages you don't act as keylogger.

(To me it's odd that Windows even allows to attach to device level events without administrator powers, they just can't seem to get their act together. MacOS at least tries to handle this correctly, it should require sudo rights, and give prompts and what not.)

@garasubo
Copy link
Contributor

In Windows, DeviceEvents are abstraction of Raw Input. And the document said:

By default, no application receives raw input. To receive raw input from a device, an application must register the device.

So, technically, we can make them as optional.

In X11, DevicEvents are abstraction of XI_Raw.* events. To receive them, an application need to set the mask by calling XISelectEvents. So we can make them as optional as well.

As we discuss in #1775, I agree that the functionality to disable DeviceEvents based on window status will be useful for many application, but I think providing an option to disabling DeviceEvents at all is also useful because there are applications receiving device events through WindowEvent and ignoring all DeviceEvent (e.g. Alacritty).

I can help implementing this feature for X11 once we decide what API we want to implement

@chrisduerr
Copy link
Contributor

If there is a desire to disable device events completely, just having a with_device_events and set_device_events should help with both usecases. If I only want this without focus I can just call the set_device_events or whatever one wants to call it in the focus lost/gained event callbacks.

With X11's way changing this dynamically shouldn't be a problem I think, I'm not sure about changing this at runtime on Windows though.

@Ciantic
Copy link
Author

Ciantic commented Feb 19, 2021

I looked at that Raw Input WinAPI, it looks like winit registers to HID_USAGE_GENERIC_MOUSE and HID_USAGE_GENERIC_KEYBOARD.

@garasubo is there similar differentation in X11? Maybe we could have two different apis: mouse_device_events(bool) and keyboard_device_events(bool).

Btw, in Windows the winit should still listen to WM_CHAR, WM_KEYDOWN, WM_KEYUP unconditionally, they are efficient and does what they are supposed to do, they only trigger when the window is in focus etc. They need never be toggled off.

@garasubo
Copy link
Contributor

is there similar differentation in X11?

Yes, we can provide API to disable mouse or keyboard independently. Currently, we set all masks to get raw events like this:

            let mask = ffi::XI_RawMotionMask
                | ffi::XI_RawButtonPressMask
                | ffi::XI_RawButtonReleaseMask
                | ffi::XI_RawKeyPressMask
                | ffi::XI_RawKeyReleaseMask;
            // The request buffer is flushed when we poll for events
            wt.xconn
                .select_xinput_events(wt.root, info.deviceid, mask)
                .queue();

So, we just need to change mask based on the application request.

@chrisduerr
Copy link
Contributor

Could also just take a bitmask ourselves.

@Ciantic
Copy link
Author

Ciantic commented May 23, 2021

I'd like to have some discussion about this, since this is not decided yet. I think this is an issue, it depresses me slightly because it ruins the winit for me. Let me show why this is an issue:

The problem compounds really fast if you have multiple winit processes. My CPU usage goes from ~6% -> 30% just by moving mouse even though not a single winit window is visible.

I think we need someone who can decide what kind of API is wanted, the implementation would be simple if we can agree on the API.

@msiglreith
Copy link
Member

IMO starting with an EventLoop::with_device_events(&mut self, bool) would be fine, which de/registers all raw input devices.
For game applications it's ok to receive all events and for pure UI device events are less important. If the gamepad related parts get more traction I would see that we end up with more fine-grained control in this direction (adding devices to the eventloop similar to a window).

@Ciantic
Copy link
Author

Ciantic commented May 30, 2021

I'm expirimenting with this kind of signature:

pub struct EventLoop<T: 'static> {
    pub(crate) event_loop: platform_impl::EventLoop<T>,
    pub(crate) device_events: bool,
    pub(crate) _marker: ::std::marker::PhantomData<*mut ()>, // Not Send nor Sync
}

impl<T> EventLoop<T> {
    /// Enable or disable device events
    pub fn with_device_events(mut self, enabled: bool) -> Self {
        self.device_events = enabled;
        self
    }
    ...
}

Since the with implies chainability, and this pattern is used e.g. in WindowBuilder. I think it's more idiomatic for winit than &mut self. I try to implement this for Windows side, maybe someone can help with the other OS's.

mahkoh added a commit to mahkoh/winit that referenced this issue Nov 19, 2021
This patch completes the port of the X11 backend from core input handling to
XInput/XKB input handling. In this context the word 'core' refers to the core
X11 protocol in contrast to protocol extensions such as XInput and XKB.

XInput and XKB are very large protocols that extend X11 with features expected
from modern desktop environments such as

- Support for a rich set of input devices such as touchpads.
- Support for multiple attached keyboards, mice, touchpads, tablets, etc.
- Support for rich and interactive keyboard layouts.

# Breaking Changes

- This patch removes all processing of core input events in favor of XInput
  events. The legacy XIM input method protocol is based on filtering and
  injecting core input events. Therefore, this patch also removes support for
  XIM input methods. Applications are encouraged to switch to more modern IM
  protocols such as [IBus]. These protocols can be implemented in application
  space outside of winit. Note that modern toolskits such as QT5 and chromium
  do not support XIM.

  [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus

- This patch removes support for synthetic keyboard events. This feature
  cannot be implemented correctly:

  - XKB is a complex state machine where key presses and releases can perform
    a rich set of actions. For example:

    - Switching modifiers on and off.
    - Switching between keyboard layouts.
    - Moving the mouse cursor.

    These actions depend on the order the key are pressed and released.
    For example, if a key that switches layouts is released before a
    regular key, then the release of the regular key will produce
    different events than it would otherwise.

  - The winit API does not permit synthetic `ModifierChanged` events. As such,
    an application cannot distinguish between the user deliberately changing
    the active modifiers and synthetic changes. For example, consider an
    application that performs a drag-and-drop operation as long as the Shift
    modifier is active.

  Applications are encouraged to track the state of keys manually in a way
  that is suitable for their application.

# New and Changed Features

- Winit no longer tracks keyboard events if no winit window has the focus except
  that:

  - Raw keyboard events are still being tracked. A future patch might make this
    behavior optional. See rust-windowing#1634.
  - Changes to the keyboard layout are being tracked at all times.

- The backend now has complete support for multiple seats. For each seat it
  tracks the modifier state and the focused window. In the case of
  `KeyboardInput` events, applications can distinguish multiple seats by
  tracking the value of the `device_id` field. In the case of
  `ModifierChanged` events, applications cannot distinguish different seats. A
  future patch might add a `device_id` field to `ModifierChanged` events.

  The following sequence of events is possible:

  1. Key Press: Seat 1, Left Shift
  2. Modifiers Changed: Shift
  3. Key Press: Seat 2, Left Ctrl
  4. Modifiers Changed: Ctrl
  5. Key Press: Seat 1, KeyA, Text: "A" (due to active Shift)
  6. Key Release: Seat 1, Left Shift
  7. Modifiers Changed: None
  8. Key Release: Seat 2, Left Ctrl
  9. Modifiers Changed: None

- Keyboard state and window events are now completely independent of device
  events. Applications can disable device events by modifying the winit
  source code (or in the future with a supported toggle) without incurring
  regressions in other areas.

- Key release events no longer contain a value in the `text` and
  `text_with_all_modifiers` fields.

- Key presses that are part of a compose sequence no longer contain a value in
  the `text` and `text_with_all_modifiers`. Applications that simply want to
  handle text input can therefore listen for key events and append the values
  of the `text` field to the input buffer without having to track any state.

- The `logical_key` field of key events is no longer affected by compose
  sequences. This is in line with how browsers handle compose sequences.

- Aborted compose sequences no longer produce any `text`. An aborted compose
  sequence is a sequence that was not completed correctly. For example,
  consider the following sequence of keysyms:

  1. Multi_key
  2. (
  3. c
  4. (

  `(` is not a valid continuation of the compose sequence starting with
  `[Multi_key, (, c]`. Therefore it aborts the sequence and no `text` is
  produced (not even for the final `(`). This is in line with existing
  practice on linux.

- The `Dead` `Key` is now used exclusively for those keysyms that have
  `_dead_` in their name. This appears to be in line with how browsers handle
  dead keys.

- The value of a `Dead` `Key` is in one of three categories:

  - If the dead key does not correspond to any particular diacritical mark,
    the value is `None`. For example, `dead_greek` (used to input Greek
    characters on a Latin keyboard).
  - If the dead key has a freestanding variant in unicode, the value is
    `Some(c)` with `c` being the freestanding character. For example,
    `dead_circumflex` has the value `Some('^')`.
  - Otherwise the value is `None`. For example, `dead_belowdot`.

- `key_without_modifiers` now respects the effective XKB group. It only
  discards the state of modifiers. This is essential to correctly handle
  keyboard layouts in the GNOME desktop environment which uses XKB groups to
  switch between layouts.

# Implementation Details

- `EventProcessor` no longer uses any interior mutability. In cases where
  there were conflicting borrows, the code has been rewritten to use
  freestanding functions.

- Keyboard state is now tracked exclusively by xkbcommon. The code that
  manually tracked some of this state has been removed.

- The `xkb_state` module has been significantly simplified. The
  `process_key_event` function now computes all effects produced by a key
  press/release ahead of time.

- Almost all XInput events also carry the current XKB state of its seat. We
  use this to track the state of modifiers eagerly and independently of
  keyboard events.
mahkoh added a commit to mahkoh/winit that referenced this issue Nov 22, 2021
This patch completes the port of the X11 backend from core input handling to
XInput/XKB input handling. In this context the word 'core' refers to the core
X11 protocol in contrast to protocol extensions such as XInput and XKB.

XInput and XKB are very large protocols that extend X11 with features expected
from modern desktop environments such as

- Support for a rich set of input devices such as touchpads.
- Support for multiple attached keyboards, mice, touchpads, tablets, etc.
- Support for rich and interactive keyboard layouts.

# Breaking Changes

- This patch removes all processing of core input events in favor of XInput
  events. The legacy XIM input method protocol is based on filtering and
  injecting core input events. Therefore, this patch also removes support for
  XIM input methods. Applications are encouraged to switch to more modern IM
  protocols such as [IBus]. These protocols can be implemented in application
  space outside of winit. Note that modern toolskits such as QT5 and chromium
  do not support XIM.

  [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus

- This patch removes support for synthetic keyboard events. This feature
  cannot be implemented correctly:

  - XKB is a complex state machine where key presses and releases can perform
    a rich set of actions. For example:

    - Switching modifiers on and off.
    - Switching between keyboard layouts.
    - Moving the mouse cursor.

    These actions depend on the order the key are pressed and released.
    For example, if a key that switches layouts is released before a
    regular key, then the release of the regular key will produce
    different events than it would otherwise.

  - The winit API does not permit synthetic `ModifierChanged` events. As such,
    an application cannot distinguish between the user deliberately changing
    the active modifiers and synthetic changes. For example, consider an
    application that performs a drag-and-drop operation as long as the Shift
    modifier is active.

  Applications are encouraged to track the state of keys manually in a way
  that is suitable for their application.

# New and Changed Features

- Winit no longer tracks keyboard events if no winit window has the focus except
  that:

  - Raw keyboard events are still being tracked. A future patch might make this
    behavior optional. See rust-windowing#1634.
  - Changes to the keyboard layout are being tracked at all times.

- The backend now has complete support for multiple seats. For each seat it
  tracks the modifier state and the focused window. In the case of
  `KeyboardInput` events, applications can distinguish multiple seats by
  tracking the value of the `device_id` field. In the case of
  `ModifierChanged` events, applications cannot distinguish different seats. A
  future patch might add a `device_id` field to `ModifierChanged` events.

  The following sequence of events is possible:

  1. Key Press: Seat 1, Left Shift
  2. Modifiers Changed: Shift
  3. Key Press: Seat 2, Left Ctrl
  4. Modifiers Changed: Ctrl
  5. Key Press: Seat 1, KeyA, Text: "A" (due to active Shift)
  6. Key Release: Seat 1, Left Shift
  7. Modifiers Changed: None
  8. Key Release: Seat 2, Left Ctrl
  9. Modifiers Changed: None

- Keyboard state and window events are now completely independent of device
  events. Applications can disable device events by modifying the winit
  source code (or in the future with a supported toggle) without incurring
  regressions in other areas.

- Key release events no longer contain a value in the `text` and
  `text_with_all_modifiers` fields.

- Key presses that are part of a compose sequence no longer contain a value in
  the `text` and `text_with_all_modifiers`. Applications that simply want to
  handle text input can therefore listen for key events and append the values
  of the `text` field to the input buffer without having to track any state.

- The `logical_key` field of key events is no longer affected by compose
  sequences. This is in line with how browsers handle compose sequences.

- Aborted compose sequences no longer produce any `text`. An aborted compose
  sequence is a sequence that was not completed correctly. For example,
  consider the following sequence of keysyms:

  1. Multi_key
  2. (
  3. c
  4. (

  `(` is not a valid continuation of the compose sequence starting with
  `[Multi_key, (, c]`. Therefore it aborts the sequence and no `text` is
  produced (not even for the final `(`). This is in line with existing
  practice on linux.

- The `Dead` `Key` is now used exclusively for those keysyms that have
  `_dead_` in their name. This appears to be in line with how browsers handle
  dead keys.

- The value of a `Dead` `Key` is in one of three categories:

  - If the dead key does not correspond to any particular diacritical mark,
    the value is `None`. For example, `dead_greek` (used to input Greek
    characters on a Latin keyboard).
  - If the dead key has a freestanding variant in unicode, the value is
    `Some(c)` with `c` being the freestanding character. For example,
    `dead_circumflex` has the value `Some('^')`.
  - Otherwise the value is `None`. For example, `dead_belowdot`.

- `key_without_modifiers` now respects the effective XKB group. It only
  discards the state of modifiers. This is essential to correctly handle
  keyboard layouts in the GNOME desktop environment which uses XKB groups to
  switch between layouts.

# Implementation Details

- `EventProcessor` no longer uses any interior mutability. In cases where
  there were conflicting borrows, the code has been rewritten to use
  freestanding functions.

- Keyboard state is now tracked exclusively by xkbcommon. The code that
  manually tracked some of this state has been removed.

- The `xkb_state` module has been significantly simplified. The
  `process_key_event` function now computes all effects produced by a key
  press/release ahead of time.

- Almost all XInput events also carry the current XKB state of its seat. We
  use this to track the state of modifiers eagerly and independently of
  keyboard events.
mahkoh added a commit to mahkoh/winit that referenced this issue Nov 29, 2021
This patch completes the port of the X11 backend from core input handling to
XInput/XKB input handling. In this context the word 'core' refers to the core
X11 protocol in contrast to protocol extensions such as XInput and XKB.

XInput and XKB are very large protocols that extend X11 with features expected
from modern desktop environments such as

- Support for a rich set of input devices such as touchpads.
- Support for multiple attached keyboards, mice, touchpads, tablets, etc.
- Support for rich and interactive keyboard layouts.

# Breaking Changes

- This patch removes all processing of core input events in favor of XInput
  events. The legacy XIM input method protocol is based on filtering and
  injecting core input events. Therefore, this patch also removes support for
  XIM input methods. Applications are encouraged to switch to more modern IM
  protocols such as [IBus]. These protocols can be implemented in application
  space outside of winit. Note that modern toolskits such as QT5 and chromium
  do not support XIM.

  [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus

- This patch removes support for synthetic keyboard events. This feature
  cannot be implemented correctly:

  - XKB is a complex state machine where key presses and releases can perform
    a rich set of actions. For example:

    - Switching modifiers on and off.
    - Switching between keyboard layouts.
    - Moving the mouse cursor.

    These actions depend on the order the key are pressed and released.
    For example, if a key that switches layouts is released before a
    regular key, then the release of the regular key will produce
    different events than it would otherwise.

  - The winit API does not permit synthetic `ModifierChanged` events. As such,
    an application cannot distinguish between the user deliberately changing
    the active modifiers and synthetic changes. For example, consider an
    application that performs a drag-and-drop operation as long as the Shift
    modifier is active.

  Applications are encouraged to track the state of keys manually in a way
  that is suitable for their application.

# New and Changed Features

- Winit no longer tracks keyboard events if no winit window has the focus except
  that:

  - Raw keyboard events are still being tracked. A future patch might make this
    behavior optional. See rust-windowing#1634.
  - Changes to the keyboard layout are being tracked at all times.

- The backend now has complete support for multiple seats. For each seat it
  tracks the modifier state and the focused window. In the case of
  `KeyboardInput` events, applications can distinguish multiple seats by
  tracking the value of the `device_id` field. In the case of
  `ModifierChanged` events, applications cannot distinguish different seats. A
  future patch might add a `device_id` field to `ModifierChanged` events.

  The following sequence of events is possible:

  1. Key Press: Seat 1, Left Shift
  2. Modifiers Changed: Shift
  3. Key Press: Seat 2, Left Ctrl
  4. Modifiers Changed: Ctrl
  5. Key Press: Seat 1, KeyA, Text: "A" (due to active Shift)
  6. Key Release: Seat 1, Left Shift
  7. Modifiers Changed: None
  8. Key Release: Seat 2, Left Ctrl
  9. Modifiers Changed: None

- Keyboard state and window events are now completely independent of device
  events. Applications can disable device events by modifying the winit
  source code (or in the future with a supported toggle) without incurring
  regressions in other areas.

- Key release events no longer contain a value in the `text` and
  `text_with_all_modifiers` fields.

- Key presses that are part of a compose sequence no longer contain a value in
  the `text` and `text_with_all_modifiers`. Applications that simply want to
  handle text input can therefore listen for key events and append the values
  of the `text` field to the input buffer without having to track any state.

- The `logical_key` field of key events is no longer affected by compose
  sequences. This is in line with how browsers handle compose sequences.

- Aborted compose sequences no longer produce any `text`. An aborted compose
  sequence is a sequence that was not completed correctly. For example,
  consider the following sequence of keysyms:

  1. Multi_key
  2. (
  3. c
  4. (

  `(` is not a valid continuation of the compose sequence starting with
  `[Multi_key, (, c]`. Therefore it aborts the sequence and no `text` is
  produced (not even for the final `(`). This is in line with existing
  practice on linux.

- The `Dead` `Key` is now used exclusively for those keysyms that have
  `_dead_` in their name. This appears to be in line with how browsers handle
  dead keys.

- The value of a `Dead` `Key` is in one of three categories:

  - If the dead key does not correspond to any particular diacritical mark,
    the value is `None`. For example, `dead_greek` (used to input Greek
    characters on a Latin keyboard).
  - If the dead key has a freestanding variant in unicode, the value is
    `Some(c)` with `c` being the freestanding character. For example,
    `dead_circumflex` has the value `Some('^')`.
  - Otherwise the value is `None`. For example, `dead_belowdot`.

- `key_without_modifiers` now respects the effective XKB group. It only
  discards the state of modifiers. This is essential to correctly handle
  keyboard layouts in the GNOME desktop environment which uses XKB groups to
  switch between layouts.

# Implementation Details

- `EventProcessor` no longer uses any interior mutability. In cases where
  there were conflicting borrows, the code has been rewritten to use
  freestanding functions.

- Keyboard state is now tracked exclusively by xkbcommon. The code that
  manually tracked some of this state has been removed.

- The `xkb_state` module has been significantly simplified. The
  `process_key_event` function now computes all effects produced by a key
  press/release ahead of time.

- Almost all XInput events also carry the current XKB state of its seat. We
  use this to track the state of modifiers eagerly and independently of
  keyboard events.
mahkoh added a commit to mahkoh/winit that referenced this issue Nov 30, 2021
This patch completes the port of the X11 backend from core input handling to
XInput/XKB input handling. In this context the word 'core' refers to the core
X11 protocol in contrast to protocol extensions such as XInput and XKB.

XInput and XKB are very large protocols that extend X11 with features expected
from modern desktop environments such as

- Support for a rich set of input devices such as touchpads.
- Support for multiple attached keyboards, mice, touchpads, tablets, etc.
- Support for rich and interactive keyboard layouts.

# Breaking Changes

- This patch removes all processing of core input events in favor of XInput
  events. The legacy XIM input method protocol is based on filtering and
  injecting core input events. Therefore, this patch also removes support for
  XIM input methods. Applications are encouraged to switch to more modern IM
  protocols such as [IBus]. These protocols can be implemented in application
  space outside of winit. Note that modern toolskits such as QT5 and chromium
  do not support XIM.

  [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus

- This patch removes support for synthetic keyboard events. This feature
  cannot be implemented correctly:

  - XKB is a complex state machine where key presses and releases can perform
    a rich set of actions. For example:

    - Switching modifiers on and off.
    - Switching between keyboard layouts.
    - Moving the mouse cursor.

    These actions depend on the order the key are pressed and released.
    For example, if a key that switches layouts is released before a
    regular key, then the release of the regular key will produce
    different events than it would otherwise.

  - The winit API does not permit synthetic `ModifierChanged` events. As such,
    an application cannot distinguish between the user deliberately changing
    the active modifiers and synthetic changes. For example, consider an
    application that performs a drag-and-drop operation as long as the Shift
    modifier is active.

  Applications are encouraged to track the state of keys manually in a way
  that is suitable for their application.

# New and Changed Features

- Winit no longer tracks keyboard events if no winit window has the focus except
  that:

  - Raw keyboard events are still being tracked. A future patch might make this
    behavior optional. See rust-windowing#1634.
  - Changes to the keyboard layout are being tracked at all times.

- The backend now has complete support for multiple seats. For each seat it
  tracks the modifier state and the focused window. In the case of
  `KeyboardInput` events, applications can distinguish multiple seats by
  tracking the value of the `device_id` field. In the case of
  `ModifierChanged` events, applications cannot distinguish different seats. A
  future patch might add a `device_id` field to `ModifierChanged` events.

  The following sequence of events is possible:

  1. Key Press: Seat 1, Left Shift
  2. Modifiers Changed: Shift
  3. Key Press: Seat 2, Left Ctrl
  4. Modifiers Changed: Ctrl
  5. Key Press: Seat 1, KeyA, Text: "A" (due to active Shift)
  6. Key Release: Seat 1, Left Shift
  7. Modifiers Changed: None
  8. Key Release: Seat 2, Left Ctrl
  9. Modifiers Changed: None

- Keyboard state and window events are now completely independent of device
  events. Applications can disable device events by modifying the winit
  source code (or in the future with a supported toggle) without incurring
  regressions in other areas.

- Key release events no longer contain a value in the `text` and
  `text_with_all_modifiers` fields.

- Key presses that are part of a compose sequence no longer contain a value in
  the `text` and `text_with_all_modifiers`. Applications that simply want to
  handle text input can therefore listen for key events and append the values
  of the `text` field to the input buffer without having to track any state.

- The `logical_key` field of key events is no longer affected by compose
  sequences. This is in line with how browsers handle compose sequences.

- Aborted compose sequences no longer produce any `text`. An aborted compose
  sequence is a sequence that was not completed correctly. For example,
  consider the following sequence of keysyms:

  1. Multi_key
  2. (
  3. c
  4. (

  `(` is not a valid continuation of the compose sequence starting with
  `[Multi_key, (, c]`. Therefore it aborts the sequence and no `text` is
  produced (not even for the final `(`). This is in line with existing
  practice on linux.

- The `Dead` `Key` is now used exclusively for those keysyms that have
  `_dead_` in their name. This appears to be in line with how browsers handle
  dead keys.

- The value of a `Dead` `Key` is in one of three categories:

  - If the dead key does not correspond to any particular diacritical mark,
    the value is `None`. For example, `dead_greek` (used to input Greek
    characters on a Latin keyboard).
  - If the dead key has a freestanding variant in unicode, the value is
    `Some(c)` with `c` being the freestanding character. For example,
    `dead_circumflex` has the value `Some('^')`.
  - Otherwise the value is `None`. For example, `dead_belowdot`.

- `key_without_modifiers` now respects the effective XKB group. It only
  discards the state of modifiers. This is essential to correctly handle
  keyboard layouts in the GNOME desktop environment which uses XKB groups to
  switch between layouts.

# Implementation Details

- `EventProcessor` no longer uses any interior mutability. In cases where
  there were conflicting borrows, the code has been rewritten to use
  freestanding functions.

- Keyboard state is now tracked exclusively by xkbcommon. The code that
  manually tracked some of this state has been removed.

- The `xkb_state` module has been significantly simplified. The
  `process_key_event` function now computes all effects produced by a key
  press/release ahead of time.

- Almost all XInput events also carry the current XKB state of its seat. We
  use this to track the state of modifiers eagerly and independently of
  keyboard events.
mahkoh added a commit to mahkoh/winit that referenced this issue Dec 2, 2021
This patch completes the port of the X11 backend from core input handling to
XInput/XKB input handling. In this context the word 'core' refers to the core
X11 protocol in contrast to protocol extensions such as XInput and XKB.

XInput and XKB are very large protocols that extend X11 with features expected
from modern desktop environments such as

- Support for a rich set of input devices such as touchpads.
- Support for multiple attached keyboards, mice, touchpads, tablets, etc.
- Support for rich and interactive keyboard layouts.

# Breaking Changes

- This patch removes all processing of core input events in favor of XInput
  events. The legacy XIM input method protocol is based on filtering and
  injecting core input events. Therefore, this patch also removes support for
  XIM input methods. Applications are encouraged to switch to more modern IM
  protocols such as [IBus]. These protocols can be implemented in application
  space outside of winit. Note that modern toolskits such as QT5 and chromium
  do not support XIM.

  [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus

- This patch removes support for synthetic keyboard events. This feature
  cannot be implemented correctly:

  - XKB is a complex state machine where key presses and releases can perform
    a rich set of actions. For example:

    - Switching modifiers on and off.
    - Switching between keyboard layouts.
    - Moving the mouse cursor.

    These actions depend on the order the key are pressed and released.
    For example, if a key that switches layouts is released before a
    regular key, then the release of the regular key will produce
    different events than it would otherwise.

  - The winit API does not permit synthetic `ModifierChanged` events. As such,
    an application cannot distinguish between the user deliberately changing
    the active modifiers and synthetic changes. For example, consider an
    application that performs a drag-and-drop operation as long as the Shift
    modifier is active.

  Applications are encouraged to track the state of keys manually in a way
  that is suitable for their application.

# New and Changed Features

- Winit no longer tracks keyboard events if no winit window has the focus except
  that:

  - Raw keyboard events are still being tracked. A future patch might make this
    behavior optional. See rust-windowing#1634.
  - Changes to the keyboard layout are being tracked at all times.

- The backend now has complete support for multiple seats. For each seat it
  tracks the modifier state and the focused window. In the case of
  `KeyboardInput` events, applications can distinguish multiple seats by
  tracking the value of the `device_id` field. In the case of
  `ModifierChanged` events, applications cannot distinguish different seats. A
  future patch might add a `device_id` field to `ModifierChanged` events.

  The following sequence of events is possible:

  1. Key Press: Seat 1, Left Shift
  2. Modifiers Changed: Shift
  3. Key Press: Seat 2, Left Ctrl
  4. Modifiers Changed: Ctrl
  5. Key Press: Seat 1, KeyA, Text: "A" (due to active Shift)
  6. Key Release: Seat 1, Left Shift
  7. Modifiers Changed: None
  8. Key Release: Seat 2, Left Ctrl
  9. Modifiers Changed: None

- Keyboard state and window events are now completely independent of device
  events. Applications can disable device events by modifying the winit
  source code (or in the future with a supported toggle) without incurring
  regressions in other areas.

- Key release events no longer contain a value in the `text` and
  `text_with_all_modifiers` fields.

- Key presses that are part of a compose sequence no longer contain a value in
  the `text` and `text_with_all_modifiers`. Applications that simply want to
  handle text input can therefore listen for key events and append the values
  of the `text` field to the input buffer without having to track any state.

- The `logical_key` field of key events is no longer affected by compose
  sequences. This is in line with how browsers handle compose sequences.

- Aborted compose sequences no longer produce any `text`. An aborted compose
  sequence is a sequence that was not completed correctly. For example,
  consider the following sequence of keysyms:

  1. Multi_key
  2. (
  3. c
  4. (

  `(` is not a valid continuation of the compose sequence starting with
  `[Multi_key, (, c]`. Therefore it aborts the sequence and no `text` is
  produced (not even for the final `(`). This is in line with existing
  practice on linux.

- The `Dead` `Key` is now used exclusively for those keysyms that have
  `_dead_` in their name. This appears to be in line with how browsers handle
  dead keys.

- The value of a `Dead` `Key` is in one of three categories:

  - If the dead key does not correspond to any particular diacritical mark,
    the value is `None`. For example, `dead_greek` (used to input Greek
    characters on a Latin keyboard).
  - If the dead key has a freestanding variant in unicode, the value is
    `Some(c)` with `c` being the freestanding character. For example,
    `dead_circumflex` has the value `Some('^')`.
  - Otherwise the value is `None`. For example, `dead_belowdot`.

- `key_without_modifiers` now respects the effective XKB group. It only
  discards the state of modifiers. This is essential to correctly handle
  keyboard layouts in the GNOME desktop environment which uses XKB groups to
  switch between layouts.

# Implementation Details

- `EventProcessor` no longer uses any interior mutability. In cases where
  there were conflicting borrows, the code has been rewritten to use
  freestanding functions.

- Keyboard state is now tracked exclusively by xkbcommon. The code that
  manually tracked some of this state has been removed.

- The `xkb_state` module has been significantly simplified. The
  `process_key_event` function now computes all effects produced by a key
  press/release ahead of time.

- Almost all XInput events also carry the current XKB state of its seat. We
  use this to track the state of modifiers eagerly and independently of
  keyboard events.
@rornic
Copy link

rornic commented Dec 24, 2021

I noticed this in a project I'm working on, finding my window was was picking up keyboard events when it was in the background.

On Windows, the cause of this appears to be the RIDEV_INPUTSINK flag on this line of code. https://github.com/rust-windowing/winit/blob/v0.26.0/src/platform_impl/windows/raw_input.rs#L146.

The original PR for this code is here #482.

I'm using glutin which uses winit for windowing. I can confirm that recompiling winit with the above flag removed fixes the issue on Windows. I'm not too familiar with the Windows API though, so this change would be better made by someone who is.

chrisduerr added a commit to chrisduerr/winit that referenced this issue Feb 16, 2022
Previously on X11, by default all global events were broadcasted to
every Winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using `EventLoop::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.
chrisduerr added a commit to chrisduerr/winit that referenced this issue Apr 9, 2022
Previously on X11, by default all global events were broadcasted to
every Winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using `EventLoop::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.
kchibisov pushed a commit to chrisduerr/winit that referenced this issue Jun 7, 2022
Previously on X11, by default all global events were broadcasted to
every Winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using `EventLoop::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.
kchibisov pushed a commit to chrisduerr/winit that referenced this issue Jun 7, 2022
Previously on X11, by default all global events were broadcasted to
every Winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using
`EventLoopWindowTarget::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.
kchibisov pushed a commit that referenced this issue Jun 7, 2022
Previously on X11, by default all global events were broadcasted to
every winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using
`EventLoopWindowTarget::set_filter_device_events`.

Fixes (#1634) on Linux.
a-llie pushed a commit to a-llie/winit that referenced this issue Aug 24, 2022
Unify `with_app_id` and `with_class` methods

Both APIs are used to set application name. This commit unifies the API
between Wayland and X11, so downstream applications can remove platform
specific code when using `WindowBuilderExtUnix`.

Fixes rust-windowing#1739.

Unify behavior of `resizable` across platforms

This makes X11 and Wayland follow Windows and macOS, so the size of the
window could be set even though it has resizable attribute set to false.

Fixes rust-windowing#2242.

Fix assigning the wrong monitor when receiving Windows move events (rust-windowing#2266)

Fix embedded NULs in C wide strings returned from Windows API (rust-windowing#2264)

On Wayland, fix hiding cursors on GNOME

`wl_pointer::set_cursor` expects a serial number of the last
`wl_pointer::enter` event. However other calls expect latest
observed pointer serial, so this commit tracks both and
use them as required by specification.

Fixes rust-windowing#2273.

Bump windows-sys version to 0.36 (rust-windowing#2277)

Add new `Ime` event for desktop platforms

This commit brings new Ime event to account for preedit state of input
method, also adding `Window::set_ime_allowed` to toggle IME input on
the particular window.

This commit implements API as designed in rust-windowing#1497 for desktop platforms.

On Wayland, provide option for better CSD

While most compositors provide server side decorations, the GNOME
does not, and won't provide them. Also Wayland clients must render
client side decorations.

Winit was already drawing some decorations, however they were bad
looking and provided no text rendering, so the title was missing.
However this commit makes use of the SCTK external frame similar to
GTK's Adwaita theme supporting text rendering and looking similar to
other GTK applications.

Fixes rust-windowing#1967.

Fix warnings on nightly rust (rust-windowing#2295)

This was causing CI to fail: https://github.com/rust-windowing/winit/runs/6506026326

On macOS, emit resize event on `frame_did_change`

When the window switches mode from normal to tabbed one, it doesn't
get resized, however the frame gets resized. This commit makes
winit to track resizes when frame changes instead of window.

Fixes rust-windowing#2191.

Reorganize `EventLoopBuilder::build()` platform documentation

Since there's a "Platform-specific" header, it makes sense to put the
Linux-specific part under it. On the other hand, "Can only be called on
the main thread." is true for all platforms, not just iOS, so there is
no reason to call it out for iOS specifically.

[Windows] Avoid GetModuleHandle(NULL) (rust-windowing#2301)

Use get_instance_handle() over GetModuleHandle(NULL)

On Windows, fix reported cursor position. (rust-windowing#2311)

When clicking and moving the cursor out of the window negative coordinates were not handled correctly.

Revert "On Wayland, fix resize not propagating properly"

This reverts commit 78e5a39.

It was discovered that in some cases mesa will lock the back
buffer, e.g. when making context current, leading to resize
missing. Given that applications can restructure their rendering
to account for that, and that winit isn't limited to playing
nice with mesa reverting the original commit.

Set `WindowBuilder` to must_use

Add X11 opt-in function for device events

Previously on X11, by default all global events were broadcasted to
every winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using
`EventLoopWindowTarget::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.

Prevent null dereference on X11 with bad locale

Remove old dialog fix that is superseded by rust-windowing#2027 (rust-windowing#2292)

This fixes the run_return loop never returning on macos when using multiple windows

Migrate from lazy_static to once_cell

macOS: Emit LoopDestroyed on CMD+Q (rust-windowing#2073)

override applicationWillTerminate:

On Android, use `HasRawWindowHandle` directly from the `ndk` crate (rust-windowing#2318)

The `ndk` crate now implements [`HasRawWindowHandle` directly on
`NativeWindow`], relieving the burden to reimplement it on `winit`.

[`HasRawWindowHandle` directly on `NativeWindow`]: rust-mobile/ndk#274

Run clippy on CI

Fixes rust-windowing#1402.

Make `set_device_event_filter` non-mut

Commit f10a984 added `EventLoopWindowTarget::set_device_event_filter`
with for a mutable reference, however most winit APIs work with
immutable references, so altering API to play nicely with existing APIs.

This also disables device event filtering on debug example.

Make `WindowAttributes` private (rust-windowing#2134)

* Make `WindowAttributes` private, and move its documentation

* Reorder WindowAttributes title and fullscreen to match method order

Build docs on `docs.rs` for iOS and Android as well (rust-windowing#2324)

Remove core-video-sys dependency (rust-windowing#2326)

Hasn't been updated in over 2 years - many open PRs, seems abandoned. Is the cause of several duplicate dependencies in our dependency tree!

Fix macOS 32bit (rust-windowing#2327)

Documentation cleanup (rust-windowing#2328)

* Remove redundant documentation links

* Add note to README about windows not showing up on Wayland

* Fix documentation links

* Small documentation fixes

* Add note about doing stuff after StartCause::Init on macOS

Add `WindowBuilder::transparent`

This is required to help hardware accelerated libraries like glutin
that accept WindowBuilder instead of RawWindowHandle, since the api
to access builder properties directly was removed.

Follow up to 44288f6.

Refine `Window::set_cursor_grab` API

This commit renames `Window::set_cursor_grab` to
`Window::set_cursor_grab_mode`. The new API now accepts enumeration
to control the way cursor grab is performed. The value could be: `lock`,
`confine`, or `none`.

This commit also implements `Window::set_cursor_position` for Wayland,
since it's tied to locked cursor.

Implements API from rust-windowing#1677.

examples/window_run_return: Enable on Android (rust-windowing#2321)

Android also supports `EventLoopExtRunReturn`.  The user will still have
to follow the README to turn this example into a `cdylib` and add the
`ndk_glue::main()` initialization attribute, though.

Fix doubled device events on X11

Fixes rust-windowing#2332

macOS: disallow_highdpi will set explicity the value to avoid the SO value by default (rust-windowing#2339)

ci: Disallow warnings in rustdoc and test private items (rust-windowing#2341)

Make sure `cargo doc` runs cleanly without any warnings in the CI - some
recently introduced but still allowing a PR to get merged.

In case someone wishes to add docs on private items, make sure those
adhere to the same standards.

Bump smithay-client-toolkit to v0.16.0

Disallow multiple EventLoop creation

Fix conflict in `WindowFlags` on Windows

Map XK_Caps_Lock to VirtualKeyCode::Capital (rust-windowing#1864)

This allows applications to handle events for the caps lock key under X11

Less redundancy and improve fullscreen in examples

Remove examples/minimize which is redundant

Implement From<u64> for WindowId and vise-versa

This should help downstream applications to expose WindowId to the end
users via e.g. IPC to control particular windows in multi window
systems.

examples/multiwindow.rs: ignore synthetic key press events

Fix infinite recursion in `WindowId` conversion methods

Add 'WindowEvent::Occluded(bool)'

This commits and an event to track window occlusion state,
which could help optimize rendering downstream.

Add `refresh_rate_millihertz` for `MonitorHandle`

This also alters `VideoMode::refresh_rate` to
`VideoMode::refresh_rate_millihertz` which now returns monitor refresh rate in
mHz.

On Wayland send Focused(false) for new window

On Wayland winit will always get an explicit focused event from the
system and will transfer it downstream. So send focused false to enforce
it.

On Wayland, drop wl_surface on window close

web: Manually emit focused event on mouse click (rust-windowing#2202)

* Manually emit focused event on mouse click

* Update CHANGELOG.md

Co-authored-by: Markus Røyset <maroider@protonmail.com>

web: Add `EventLoop::spawn` (rust-windowing#2208)

* web: Add `EventLoop::spawn`

This is the same as `EventLoop::run`, but doesn't throw an exception in order to return `!`.

I decided to name it `spawn` rather than `run_web` because I think that's more descriptive, but I'm happy to change it to `run_web`.

Resolves rust-windowing#1714

* Update src/platform/web.rs

* Fix outdated names

Co-authored-by: Markus Røyset <maroider@protonmail.com>

Fix changelog entry for `EventLoopExtWebSys` (rust-windowing#2372)

android: Hold `NativeWindow` lock until after notifying the user with `Event::Suspended` (rust-windowing#2307)

This applies rust-mobile/ndk#117
on the `winit` side: Android destroys its window/surface as soon as the
user returns from [`onNativeWindowDestroyed`], and we "fixed" this on
the `ndk-glue` side by sending the `WindowDestroyed` event before
locking the window and removing it: this lock has to wait for any user
of `ndk-glue` - ie. `winit` - to give up its readlock on the window,
which is what we utilize here to give users of `winit` "time" to destroy
any resource created on top of a `RawWindowHandle`.

since we can't pass the user a `RawWindowHandle` through the
`HasRawWindowHandle` trait we have to document this case explicitly and
keep the lock alive on the `winit` side instead.

[`onNativeWindowDestroyed`]: https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowdestroyed

web: add `with_prevent_default`, `with_focusable` (rust-windowing#2365)

* web: add `with_prevent_default`, `with_focusable`

`with_prevent_default` controls whether `event.preventDefault` is called

`with_focusable` controls whether `tabindex` is added

Fixes rust-windowing#1768

* Remove extra space from CHANGELOG

windows: Use correct value for mouse wheel delta (rust-windowing#2374)

Make winit focus take activity into account on Windows (rust-windowing#2159)

winit's notion of "focus" is very simple; you're either focused or not.
However, Windows has both notions of focused window and active window
and paying attention only to WM_SETFOCUS/WM_KILLFOCUS can cause a window
to believe the user is interacting with it when they're not. (this
manifests when a user switches to another application between when a
winit application starts and it creates its first window)

Fix typos (rust-windowing#2375)

Bump sctk-adwaita to 0.4.1

This should force the use of system libraries for Fontconfig
and freetype instead of building them with cmake if missing.

This also fixes compilation failures on nightly.

Fixes rust-windowing#2373.

Tidy up "platform-specifc" doc sections (rust-windowing#2356)

* Tidy up "platform-specific" doc sections

* Unrelated grammatical fix

* Subjective improvements

Android: avoid deadlocks while handling UserEvent (rust-windowing#2343)

Replace `Arc<Mutex<VecDeque<T>>` by `mpsc`

Update raw-window-handle to v0.5.0

This updates raw-window-handle to v0.5.0.

On macOS, fix confirmed character inserted

When confirming input in e.g. Korean IME or using characters like
`+` winit was sending those twice, once via `Ime::Commit` and the
other one via `ReceivedCharacter`, since those events weren't generating
any `Ime::Preedit` and were forwarded due to `do_command_by_selector`.

Add method to hook xlib error handler

This should help glutin to handle errors coming from GLX
and offer multithreading support in a safe way.

Fixes rust-windowing#2378.

Windows: apply skip taskbar state when taskbar is restarted (rust-windowing#2380)

Fix hiding a maximized window On Windows (rust-windowing#2336)

Bump `ndk` and `ndk-glue` dependencies to stable `0.7.0` release (rust-windowing#2392)

Fix type hint reference for xlib hook

Consistently deliver a Resumed event on all platforms

To be more consistent with mobile platforms this updates the Windows,
macOS, Wayland, X11 and Web backends to all emit a Resumed event
immediately after the initial `NewEvents(StartCause::Init)` event.

The documentation for Suspended and Resumed has also been updated
to provide general recommendations for how to handle Suspended and
Resumed events in portable applications as well as providing
Android and iOS specific details.

This consistency makes it possible to write applications that lazily
initialize their graphics state when the application resumes without
any platform-specific knowledge. Previously, applications that wanted
to run on Android and other systems would have to maintain two,
mutually-exclusive, initialization paths.

Note: This patch does nothing to guarantee that Suspended events will
be delivered. It's still reasonable to say that most OSs without a
formal lifecycle for applications will simply never "suspend" your
application. There are currently no known portability issues caused
by not delivering `Suspended` events consistently and technically
it's not possible to guarantee the delivery of `Suspended` events if
the OS doesn't define an application lifecycle. (app can always be
terminated without any kind of clean up notification on most
non-mobile OSs)

Fixes rust-windowing#2185.

ci: manually point ANDROID_NDK_ROOT to latest supplied version

It seems the symlink to `ndk-bundle` and this environment variable
pointing to it have been removed to prevent the sdkmanager from failing,
when finding the SDK setup to be in an "indeterminate" state.  It is now
up to the users themselves to install an NDK through that tool or point
the right variables to a preinstalled "latest" NDK.

actions/runner-images#2689
actions/runner-images#5926

Fix changelog entry wrt scrolling

The breaking change was put into the wrong release section.

Release 0.27.0 version

Explicitly specify minimum supported rust version

This should help with distributing apps using winit.

Fixes rust-windowing#1075.

On X11, fix crash when can't disable IME

Fixes rust-windowing#2402.

Release 0.27.1 version

Windows: respect min/max sizes when creating the window (rust-windowing#2393)

On X11, fix window hints not persisting

This commit fixes the issue with min, max, and resize increments
not persisting across the dpi changes.

Fix tracking of phase changes for mousewheel on trackpad (rust-windowing#2158)

On Windows, add opt-in function for device events (rust-windowing#2409)

Add CODEOWNERS file (rust-windowing#2420)

* Add CODEOWNERS file

This makes it very clear when you're stepping down from the post as a maintainer, and makes it clear for users who is expected to review their PR

* Fix grammar

* Make @kchibisov receive pings for the X11 platform

* Fix typo

Implement version 0.4 of the HasRawWindowHandle trait

This makes Winit 0.27 compatible with crates like Wgpu 0.13 that are
using the raw_window_handle v0.4 crate and aren't able to upgrade to 0.5
until they do a new release (since it requires a semver change).

The change is intended to be self-contained (instead of pushing
the details into all the platform_impl backends) since this is only
intended to be a temporary trait implementation for backwards
compatibility that will likely be removed before the next Winit release.

Fixes rust-windowing#2415.

Fix missleading breaking change on Windows

The applications should not rely on not-implemented behavior and
should use the right functions for that.

Remove redundant steps from CI

Tests are already building the entire crate, so no need for a
separate builds slowing down the CI.

On Wayland, fix `Window::request_redraw` being delayed

On Waylnad when asking for redraw before `MainEventsCleared`
would result for redraw being send on the next event loop tick,
which is not expectable given that it must be delivered on the same
event loop tick.

Release 0.27.2 version

On Windows, improve support for undecorated windows (rust-windowing#2419)

Add touchpad magnify and rotate gestures support for macOS (rust-windowing#2157)

* Add touchpad magnify support for macOS

* Add touchpad rotate support for macOS

* Add macOS rotate and magnify gesture cancelled phases

* Correct docs for TouchpadRotate event

* Fix tracing macros

Document `WindowEvent::Moved` as unsupported on Wayland

Update `sctk-adwaita` to use `ab_glyph`

The crossfont will still be available under the option.

Mark new events as breaking change

Adding a new enum variant is a breaking change in winit.

Co-Authored-By: kas <exactly-one-kas@users.noreply.github.com>
Co-Authored-By: Artur Kovacs <kovacs.artur.barnabas@gmail.com>
Co-Authored-By: Markus Siglreithmaier <m.siglreith@gmail.com>
Co-Authored-By: Murarth <murarth@gmail.com>
Co-Authored-By: Yusuke Kominami <yukke.konan@gmail.com>
Co-Authored-By: moko256 <koutaro.mo@gmail.com>
Co-Authored-By: Mads Marquart <mads@marquart.dk>
Co-Authored-By: Markus Røyset <maroider@protonmail.com>
Co-Authored-By: Marijn Suijten <marijns95@gmail.com>
Co-Authored-By: Kirill Chibisov <contact@kchibisov.com>
@kchibisov
Copy link
Member

The windows and x11 part of these issue were solved. Wayland doesn't have device events and macOS in a similar situation from what I know.

@madsmtm Do you know anything about device events filtering on macOS, I don't think we need it there?

@madsmtm
Copy link
Member

madsmtm commented Dec 22, 2022

On macOS, device events are only received if the application is focused, and there shouldn't be (much) additional CPU from listening to them - though for consistency, it might make sense to disable them with the filter as well.

@kchibisov
Copy link
Member

I think this is all resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - needs discussion Direction must be ironed out DS - windows S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

9 participants