[gtk/wip/ebassi/shortcut: 146/203] combobox: Redo key event forwarding hack



commit 625ae435afb174069e6654da0f3ea6fc04a360a0
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 f8f777a73d..ef1ac5ce0a 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), (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]