imcontextwayland: Set up OSK activation gesture on non text widgets
authorCarlos Garnacho <carlosg@gnome.org>
Sun, 27 Nov 2022 19:22:33 +0000 (20:22 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 28 Nov 2022 14:46:41 +0000 (15:46 +0100)
With GtkText and GtkTextView (and in extension, all their subclasses)
handling OSK activation activation, this gesture is only useful for
all text input widgets that are not subclasses of these 2 widgets,
e.g. the VTEs and crosswords of the world.

These still do need a hand in handling OSK activation, so only
set up the gesture for such cases.

gtk/gtkimcontextwayland.c

index f6c037313eec329a49ab5482b2c9e0bdd94f457c..439c64bd3b29604446f664721a2c2ffe5c3dc18c 100644 (file)
@@ -70,7 +70,6 @@ struct _GtkIMContextWayland
 {
   GtkIMContextSimple parent_instance;
   GtkWidget *widget;
-  GtkWidget *controller_widget;
 
   GtkGesture *gesture;
   double press_x;
@@ -576,19 +575,19 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
   if (context_wayland->widget)
     gtk_im_context_wayland_focus_out (context);
 
-  if (context_wayland->controller_widget)
+  if (context_wayland->widget && context_wayland->gesture)
     {
-      gtk_widget_remove_controller (context_wayland->controller_widget,
+      gtk_widget_remove_controller (context_wayland->widget,
                                     GTK_EVENT_CONTROLLER (context_wayland->gesture));
       context_wayland->gesture = NULL;
-      g_clear_object (&context_wayland->controller_widget);
     }
 
   g_set_object (&context_wayland->widget, widget);
 
-  if (widget)
+  if (widget &&
+      !GTK_IS_TEXT (widget) &&
+      !GTK_IS_TEXT_VIEW (widget))
     {
-      GtkWidget *parent;
       GtkGesture *gesture;
 
       gesture = gtk_gesture_click_new ();
@@ -600,16 +599,7 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
       g_signal_connect (gesture, "released",
                         G_CALLBACK (released_cb), context);
 
-      parent = gtk_widget_get_parent (widget);
-
-      if (parent &&
-          GTK_IS_EDITABLE (widget) &&
-          GTK_IS_EDITABLE (parent))
-        g_set_object (&context_wayland->controller_widget, parent);
-      else
-        g_set_object (&context_wayland->controller_widget, widget);
-
-      gtk_widget_add_controller (context_wayland->controller_widget,
+      gtk_widget_add_controller (context_wayland->widget,
                                  GTK_EVENT_CONTROLLER (gesture));
       context_wayland->gesture = gesture;
     }