From 46316b29dc23bc291ecb3c77356ef4eb47f30b2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 1 May 2023 11:45:45 +1000 Subject: [PATCH] GHOST/Wayland: remove keyboard modifier mismatch warning suppression Detecting when to show warnings about GHOST/XKB modifier mismatches was rather involved, remove the check as it's unnecessary for Gnome-Shell >= v43. Older versions of Gnome-Shell will show warnings on window activation with modifier keys held. --- intern/ghost/intern/GHOST_SystemWayland.cc | 76 +++------------------- 1 file changed, 8 insertions(+), 68 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index 2ffb0ea353e..3a8786dd716 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -161,22 +161,6 @@ constexpr size_t events_pending_default_size = 4096 / sizeof(void *); static bool use_gnome_confine_hack = false; #endif -/** - * GNOME (mutter 42.5) doesn't follow the WAYLAND spec regarding keyboard handling, - * unlike (other compositors: KDE-plasma, River & Sway which work without problems). - * - * This means GNOME can't know which modifiers are held when activating windows, - * so we guess the left modifiers are held. - * - * This define could be removed without changing any functionality, - * it just means GNOME users will see verbose warning messages that alert them about - * a known problem that needs to be fixed up-stream. - * - * This has been fixed for GNOME 43. Keep the workaround until support for gnome 42 is dropped. - * See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2457 - */ -#define USE_GNOME_KEYBOARD_SUPPRESS_WARNING - /** * KDE (plasma 5.26.1) has a bug where the cursor surface needs to be committed * (via `wl_surface_commit`) when it was hidden and is being set to visible again, see: #102048. @@ -766,13 +750,6 @@ struct GWL_Seat { /** Keys held matching `xkb_state`. */ struct GWL_KeyboardDepressedState key_depressed; -#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING - struct { - bool any_mod_held = false; - bool any_keys_held_on_enter = false; - } key_depressed_suppress_warning; -#endif - /** * Cache result of `xkb_keymap_mod_get_index` * so every time a modifier is accessed a string lookup isn't required. @@ -844,21 +821,6 @@ static GWL_SeatStatePointer *gwl_seat_state_pointer_from_cursor_surface( return nullptr; } -static bool gwl_seat_key_depressed_suppress_warning(const GWL_Seat *seat) -{ - bool suppress_warning = false; - -#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING - if ((seat->key_depressed_suppress_warning.any_mod_held == true) && - (seat->key_depressed_suppress_warning.any_keys_held_on_enter == false)) { - /* The compositor gave us invalid information, don't show a warning. */ - suppress_warning = true; - } -#endif - - return suppress_warning; -} - /** * \note Caller must lock `timer_mutex`. */ @@ -1867,17 +1829,13 @@ static void keyboard_depressed_state_key_event(GWL_Seat *seat, const GHOST_TKey gkey, const GHOST_TEventType etype) { - const bool show_warning = !gwl_seat_key_depressed_suppress_warning(seat); - if (GHOST_KEY_MODIFIER_CHECK(gkey)) { const int index = GHOST_KEY_MODIFIER_TO_INDEX(gkey); int16_t &value = seat->key_depressed.mods[index]; if (etype == GHOST_kEventKeyUp) { value -= 1; if (UNLIKELY(value < 0)) { - if (show_warning) { - CLOG_WARN(LOG, "modifier (%d) has negative keys held (%d)!", index, value); - } + CLOG_WARN(LOG, "modifier (%d) has negative keys held (%d)!", index, value); value = 0; } } @@ -3793,10 +3751,6 @@ static void keyboard_handle_enter(void *data, } keyboard_depressed_state_push_events_from_change(seat, key_depressed_prev); - -#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING - seat->key_depressed_suppress_warning.any_keys_held_on_enter = keys->size != 0; -#endif } /** @@ -3827,11 +3781,6 @@ static void keyboard_handle_leave(void *data, keyboard_handle_key_repeat_cancel(seat); } } - -#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING - seat->key_depressed_suppress_warning.any_mod_held = false; - seat->key_depressed_suppress_warning.any_keys_held_on_enter = false; -#endif } /** @@ -4088,10 +4037,6 @@ static void keyboard_handle_modifiers(void *data, } } -#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING - seat->key_depressed_suppress_warning.any_mod_held = mods_depressed != 0; -#endif - seat->data_source_serial = serial; } @@ -5792,8 +5737,6 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co XKB_STATE_MODS_DEPRESSED) : 0; - const bool show_warning = !gwl_seat_key_depressed_suppress_warning(seat); - /* Use local #GWL_KeyboardDepressedState to check which key is pressed. * Use XKB as the source of truth, if there is any discrepancy. */ for (int i = 0; i < MOD_INDEX_NUM; i++) { @@ -5817,11 +5760,10 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co * Warn so if this happens it can be investigated. */ if (val) { if (UNLIKELY(!(val_l || val_r))) { - if (show_warning) { - CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, - "modifier (%s) state is inconsistent (GHOST held keys do not match XKB)", - mod_info.display_name); - } + CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, + "modifier (%s) state is inconsistent (GHOST held keys do not match XKB)", + mod_info.display_name); + /* Picking the left is arbitrary. */ val_l = true; depressed_l = 1; @@ -5829,11 +5771,9 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co } else { if (UNLIKELY(val_l || val_r)) { - if (show_warning) { - CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, - "modifier (%s) state is inconsistent (GHOST released keys do not match XKB)", - mod_info.display_name); - } + CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE, + "modifier (%s) state is inconsistent (GHOST released keys do not match XKB)", + mod_info.display_name); val_l = false; val_r = false; depressed_l = 0;