Skip to content

Commit

Permalink
bugfix(android): Allow Volume* keys to be passed to the user
Browse files Browse the repository at this point in the history
It seems that discussions around rust-windowing#2748 being a poor workaround that
should rather be implemented properly/differently drowned out the fact
that the workaround was implemented incorrectly to begin with.  By
having the `if` inside the match arm, rather than /on/ the match arm
the `keycode =>` path is /never/ used for `Volume*` keys and this
event is thus never passed on to the user, defeating the purpose
of calling `handle_volume_keys()`.  Only the `Handled`/`Unhandled`
state is affected by the `ignore_volume_keys` workaround, as set by
`EventLoopBuilderExtAndroid::handle_volume_keys()`.

Fix this by moving the `if` workaround on the match arm, so that
disabling it via `EventLoopBuilderExtAndroid::handle_volume_keys()`
causes `Volume*` events to be delivered to user code once again.
  • Loading branch information
MarijnS95 committed Apr 22, 2024
1 parent babbb71 commit 789063f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ changelog entry.
- On Windows, fix cursor not confined to center of window when grabbed and hidden.
- On macOS, fix sequence of mouse events being out of order when dragging on the trackpad.
- On Wayland, fix decoration glitch on close with some compositors.
- On Android, fix a regression introduced in https://github.com/rust-windowing/winit/pull/2748 to allow volume key events to be received again.
8 changes: 4 additions & 4 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ impl<T: 'static> EventLoop<T> {
// Flag keys related to volume as unhandled. While winit does not have a way for applications
// to configure what keys to flag as handled, this appears to be a good default until winit
// can be configured.
Keycode::VolumeUp | Keycode::VolumeDown | Keycode::VolumeMute => {
if self.ignore_volume_keys {
input_status = InputStatus::Unhandled
}
Keycode::VolumeUp | Keycode::VolumeDown | Keycode::VolumeMute
if self.ignore_volume_keys =>
{
input_status = InputStatus::Unhandled
}
keycode => {
let state = match key.action() {
Expand Down

0 comments on commit 789063f

Please sign in to comment.