[mutter/wip/carlosg/text-input: 8/8] wayland: Bolt MetaWaylandTextInput in.



commit b488f2ee69082b96f9d3b4c31bfeaecd4bd09993
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 6 12:55:25 2017 +0100

    wayland: Bolt MetaWaylandTextInput in.
    
    Offer the text-input interface global, so it can be used by clients. The
    MetaWaylandSeat will also let MetaWaylandTextInput intercept key events
    before the keyboard interface handles those.

 src/wayland/meta-wayland-seat.c |   10 ++++++++++
 src/wayland/meta-wayland-seat.h |    3 +++
 src/wayland/meta-wayland.c      |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index a574594..cedb3e3 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -225,6 +225,8 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
                               "seat", seat,
                               NULL);
 
+  seat->text_input = meta_wayland_text_input_new (seat);
+
   meta_wayland_data_device_init (&seat->data_device);
 
   device_manager = clutter_device_manager_get_default ();
@@ -260,6 +262,7 @@ meta_wayland_seat_free (MetaWaylandSeat *seat)
   g_object_unref (seat->pointer);
   g_object_unref (seat->keyboard);
   g_object_unref (seat->touch);
+  g_object_unref (seat->text_input);
 
   g_slice_free (MetaWaylandSeat, seat);
 }
@@ -376,6 +379,11 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
 
     case CLUTTER_KEY_PRESS:
     case CLUTTER_KEY_RELEASE:
+      if (seat->text_input &&
+          clutter_input_focus_filter_key_event (CLUTTER_INPUT_FOCUS (seat->text_input),
+                                                (const ClutterKeyEvent *) event))
+        return TRUE;
+
       if (meta_wayland_seat_has_keyboard (seat))
         return meta_wayland_keyboard_handle_event (seat->keyboard,
                                                    (const ClutterKeyEvent *) event);
@@ -416,6 +424,8 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat    *seat,
 
   tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
   meta_wayland_tablet_seat_set_pad_focus (tablet_seat, surface);
+
+  meta_wayland_text_input_set_focus (seat->text_input, surface);
 }
 
 gboolean
diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h
index 78abb15..2f3df5f 100644
--- a/src/wayland/meta-wayland-seat.h
+++ b/src/wayland/meta-wayland-seat.h
@@ -32,6 +32,7 @@
 #include "meta-wayland-touch.h"
 #include "meta-wayland-data-device.h"
 #include "meta-wayland-tablet-tool.h"
+#include "meta-wayland-text-input.h"
 
 struct _MetaWaylandSeat
 {
@@ -42,6 +43,8 @@ struct _MetaWaylandSeat
   MetaWaylandKeyboard *keyboard;
   MetaWaylandTouch *touch;
 
+  MetaWaylandTextInput *text_input;
+
   MetaWaylandDataDevice data_device;
 
   guint capabilities;
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 799613c..b5d3c78 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -366,6 +366,7 @@ meta_wayland_init (void)
   meta_wayland_dma_buf_init (compositor);
   meta_wayland_keyboard_shortcuts_inhibit_init (compositor);
   meta_wayland_surface_inhibit_shortcuts_dialog_init ();
+  meta_wayland_text_input_init_global (compositor);
 
   if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display))
     g_error ("Failed to start X Wayland");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]