From e7e9753aacae7d6b4ee80824630057a9a30e9b7d Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Mon, 8 Apr 2024 16:21:39 +0200 Subject: [PATCH] display: Fix crash due to shortcut propagation phase For a managed GtkShortcutController, changing its propagation phase away from `GTK_PHASE_BUBBLE` currently results in a lingering reference due to a bug in GTK (gtk#6246). This means the Escape key shortcut remains active even after leaving the Display panel, resulting in a crash when pressing Escape in any panel after leaving the Display panel. This is now fixed in GTK (gtk!7115), but there seems to be no reason for changing the propagation phase at all anyways. Since the callback returns `GDK_EVENT_PROPAGATE` when it does not activate, the event should still make it to other handlers. So, to speed up the fix for gnome-control-center, we remove the propagation phase changes althogether. There is also no need to let the shortcut have global scope, managed is enough. Closes #2768 --- panels/display/cc-display-panel.c | 7 ------- panels/display/cc-display-panel.ui | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index c2eb37d41..193f22ee8 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -104,7 +104,6 @@ struct _CcDisplayPanel AdwComboRow *primary_display_row; AdwPreferencesGroup *single_display_settings_group; - GtkShortcutController *toplevel_shortcuts; GtkShortcut *escape_shortcut; GSettings *display_settings; @@ -406,8 +405,6 @@ dialog_toplevel_is_active_changed (CcDisplayPanel *self) static void reset_titlebar (CcDisplayPanel *self) { - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->toplevel_shortcuts), - GTK_PHASE_NONE); self->showing_apply_titlebar = FALSE; g_object_notify (G_OBJECT (self), "showing-apply-titlebar"); } @@ -618,7 +615,6 @@ cc_display_panel_class_init (CcDisplayPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, night_light_row); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, primary_display_row); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, single_display_settings_group); - gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, toplevel_shortcuts); gtk_widget_class_bind_template_callback (widget_class, apply_current_configuration); gtk_widget_class_bind_template_callback (widget_class, cancel_current_configuration); @@ -939,9 +935,6 @@ show_apply_titlebar (CcDisplayPanel *self, gboolean is_applicable) _("This could be due to hardware limitations.")); } - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->toplevel_shortcuts), - GTK_PHASE_BUBBLE); - self->showing_apply_titlebar = TRUE; g_object_notify (G_OBJECT (self), "showing-apply-titlebar"); } diff --git a/panels/display/cc-display-panel.ui b/panels/display/cc-display-panel.ui index ffda6a281..ba7e91407 100644 --- a/panels/display/cc-display-panel.ui +++ b/panels/display/cc-display-panel.ui @@ -3,8 +3,8 @@