From f73517761c9db3fbd9103c092cda4d82d5989d0b Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 18 Apr 2024 11:12:25 +0200 Subject: [PATCH] bugfix(android): Allow `Volume*` keys to be passed to the user It seems that discussions around #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. --- src/platform_impl/android/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index e080d0adbe..299a37e077 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -432,10 +432,10 @@ impl EventLoop { // 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() {