[gtk/wip/matthiasc/shortcut: 44/102] combobox: Redo key event forwarding hack



commit 9a91cea5a6a33f6822e3abb2f2c0ca1c803c5748
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 04d135d7ff..cdf69804e9 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 "gtkbuiltiniconprivate.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"
 
@@ -845,6 +846,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
 {
   GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
   GtkEventController *controller;
+  GList *controllers, *list;
 
   priv->active = -1;
   priv->active_row = NULL;
@@ -879,6 +881,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
@@ -1808,18 +1823,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), event))
-    {
-      gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
-    }
-
-  gdk_event_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]