[gtk/wip/ebassi/shortcut: 40/85] combobox: Redo key event forwarding hack
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/shortcut: 40/85] combobox: Redo key event forwarding hack
- Date: Fri, 31 Jan 2020 16:03:12 +0000 (UTC)
commit 9f46cff098ad00fab57e993e5e61b887fc6dd80b
Author: Benjamin Otte <otte redhat com>
Date: Sun Aug 12 21:15:37 2018 +0200
combobox: Redo key event forwarding hack
Instead of manualling invoking bindings, we now reorder event
controllers inside the treemenu, so that shortcuts run before the event
forwarding.
gtk/gtkcombobox.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index d71cc02705..bd7a019393 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -19,12 +19,12 @@
#include "gtkcomboboxprivate.h"
-#include "gtkbindings.h"
#include "gtkbox.h"
#include "gtkcellareabox.h"
#include "gtkcelllayout.h"
#include "gtkcellrenderertext.h"
#include "gtkcellview.h"
+#include "gtkeventcontrollerkey.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkframe.h"
#include "gtkiconprivate.h"
@@ -33,10 +33,11 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
+#include "gtkshortcutcontroller.h"
#include "gtktogglebutton.h"
#include "gtktreepopoverprivate.h"
#include "gtktypebuiltins.h"
-#include "gtkeventcontrollerkey.h"
+#include "gtkwidgetprivate.h"
#include "a11y/gtkcomboboxaccessible.h"
@@ -846,6 +847,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
GtkStyleContext *context;
GtkEventController *controller;
+ GList *controllers, *list;
priv->active = -1;
priv->active_row = NULL;
@@ -881,6 +883,19 @@ gtk_combo_box_init (GtkComboBox *combo_box)
G_CALLBACK (gtk_combo_box_scroll_controller_scroll),
combo_box);
gtk_widget_add_controller (GTK_WIDGET (combo_box), controller);
+
+ controllers = _gtk_widget_list_controllers (priv->popup_widget, GTK_PHASE_BUBBLE);
+ for (list = controllers; list; list = list->next)
+ {
+ if (GTK_IS_SHORTCUT_CONTROLLER (list->data))
+ {
+ g_object_ref (list->data);
+ gtk_widget_remove_controller (priv->popup_widget, list->data);
+ gtk_widget_add_controller (priv->popup_widget, list->data);
+ break;
+ }
+ }
+ g_list_free (controllers);
}
static void
@@ -1812,18 +1827,7 @@ gtk_combo_box_menu_key (GtkEventControllerKey *key,
GdkModifierType modifiers,
GtkComboBox *combo_box)
{
- GtkWidget *widget;
- GdkEvent *event;
-
- widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
- event = gtk_get_current_event ();
-
- if (!gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *)event))
- {
- gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
- }
-
- g_object_unref (event);
+ gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]