[mutter/wip/carlosg/clutter-seat: 63/84] clutter: Move keymap direction from ClutterBackend to ClutterKeymap



commit c07562d16ab47a7823f4173a47945652236c1652
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Oct 1 13:51:12 2019 +0200

    clutter: Move keymap direction from ClutterBackend to ClutterKeymap
    
    This makes more sense to have in the ClutterKeymap, since we have it.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/852

 clutter/clutter/clutter-backend-private.h   |  4 ---
 clutter/clutter/clutter-backend.c           | 12 --------
 clutter/clutter/clutter-keymap.c            |  6 ++++
 clutter/clutter/clutter-keymap.h            |  4 +++
 clutter/clutter/clutter-text.c              |  7 ++++-
 src/backends/native/meta-keymap-native.c    |  7 +++++
 src/backends/x11/meta-clutter-backend-x11.c | 12 --------
 src/backends/x11/meta-keymap-x11.c          | 47 +++++++++++++++--------------
 src/backends/x11/meta-keymap-x11.h          |  2 --
 9 files changed, 48 insertions(+), 53 deletions(-)
---
diff --git a/clutter/clutter/clutter-backend-private.h b/clutter/clutter/clutter-backend-private.h
index f22ed13ed..05d62ee01 100644
--- a/clutter/clutter/clutter-backend-private.h
+++ b/clutter/clutter/clutter-backend-private.h
@@ -96,8 +96,6 @@ struct _ClutterBackendClass
                                                 gpointer            native,
                                                 ClutterEvent       *event);
 
-  PangoDirection        (* get_keymap_direction) (ClutterBackend   *backend);
-
   void                  (* bell_notify)          (ClutterBackend   *backend);
 
   ClutterKeymap *       (* get_keymap)           (ClutterBackend   *backend);
@@ -142,8 +140,6 @@ gfloat                  _clutter_backend_get_units_per_em               (Clutter
                                                                          PangoFontDescription   *font_desc);
 gint32                  _clutter_backend_get_units_serial               (ClutterBackend         *backend);
 
-PangoDirection          _clutter_backend_get_keymap_direction           (ClutterBackend         *backend);
-
 void                    clutter_set_allowed_drivers                     (const char             *drivers);
 
 CLUTTER_EXPORT
diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c
index 8740bb161..be4ca76cf 100644
--- a/clutter/clutter/clutter-backend.c
+++ b/clutter/clutter/clutter-backend.c
@@ -997,18 +997,6 @@ clutter_wayland_set_compositor_display (void *display)
 }
 #endif
 
-PangoDirection
-_clutter_backend_get_keymap_direction (ClutterBackend *backend)
-{
-  ClutterBackendClass *klass;
-
-  klass = CLUTTER_BACKEND_GET_CLASS (backend);
-  if (klass->get_keymap_direction != NULL)
-    return klass->get_keymap_direction (backend);
-
-  return PANGO_DIRECTION_NEUTRAL;
-}
-
 void
 clutter_set_allowed_drivers (const char *drivers)
 {
diff --git a/clutter/clutter/clutter-keymap.c b/clutter/clutter/clutter-keymap.c
index ebf99af28..cdeb8f257 100644
--- a/clutter/clutter/clutter-keymap.c
+++ b/clutter/clutter/clutter-keymap.c
@@ -62,3 +62,9 @@ clutter_keymap_get_caps_lock_state (ClutterKeymap *keymap)
 {
   return CLUTTER_KEYMAP_GET_CLASS (keymap)->get_caps_lock_state (keymap);
 }
+
+PangoDirection
+clutter_keymap_get_direction (ClutterKeymap *keymap)
+{
+  return CLUTTER_KEYMAP_GET_CLASS (keymap)->get_direction (keymap);
+}
diff --git a/clutter/clutter/clutter-keymap.h b/clutter/clutter/clutter-keymap.h
index 1c398fcab..40be12ea3 100644
--- a/clutter/clutter/clutter-keymap.h
+++ b/clutter/clutter/clutter-keymap.h
@@ -29,6 +29,7 @@
 #include <clutter/clutter-macros.h>
 
 #include <glib-object.h>
+#include <pango/pango.h>
 
 typedef struct _ClutterKeymap ClutterKeymap;
 typedef struct _ClutterKeymapClass ClutterKeymapClass;
@@ -39,6 +40,7 @@ struct _ClutterKeymapClass
 
   gboolean (* get_num_lock_state)  (ClutterKeymap *keymap);
   gboolean (* get_caps_lock_state) (ClutterKeymap *keymap);
+  PangoDirection (* get_direction) (ClutterKeymap *keymap);
 };
 
 #define CLUTTER_TYPE_KEYMAP (clutter_keymap_get_type ())
@@ -53,4 +55,6 @@ gboolean clutter_keymap_get_num_lock_state  (ClutterKeymap *keymap);
 CLUTTER_EXPORT
 gboolean clutter_keymap_get_caps_lock_state (ClutterKeymap *keymap);
 
+PangoDirection clutter_keymap_get_direction (ClutterKeymap *keymap);
+
 #endif /* CLUTTER_KEYMAP_H */
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index ef1fee27f..a7c09d47c 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -759,7 +759,12 @@ clutter_text_create_layout_no_cache (ClutterText       *text,
           ClutterTextDirection text_dir;
 
           if (clutter_actor_has_key_focus (CLUTTER_ACTOR (text)))
-            pango_dir = _clutter_backend_get_keymap_direction (backend);
+            {
+              ClutterKeymap *keymap;
+
+              keymap = clutter_backend_get_keymap (backend);
+              pango_dir = clutter_keymap_get_direction (keymap);
+            }
           else
             {
               text_dir = clutter_actor_get_text_direction (CLUTTER_ACTOR (text));
diff --git a/src/backends/native/meta-keymap-native.c b/src/backends/native/meta-keymap-native.c
index 683458f4e..77777b6d4 100644
--- a/src/backends/native/meta-keymap-native.c
+++ b/src/backends/native/meta-keymap-native.c
@@ -82,6 +82,12 @@ meta_keymap_native_get_caps_lock_state (ClutterKeymap *keymap)
                                        XKB_STATE_MODS_LOCKED);
 }
 
+static PangoDirection
+meta_keymap_native_get_direction (ClutterKeymap *keymap)
+{
+  return PANGO_DIRECTION_NEUTRAL;
+}
+
 static void
 meta_keymap_native_class_init (MetaKeymapNativeClass *klass)
 {
@@ -92,6 +98,7 @@ meta_keymap_native_class_init (MetaKeymapNativeClass *klass)
 
   keymap_class->get_num_lock_state = meta_keymap_native_get_num_lock_state;
   keymap_class->get_caps_lock_state = meta_keymap_native_get_caps_lock_state;
+  keymap_class->get_direction = meta_keymap_native_get_direction;
 }
 
 static void
diff --git a/src/backends/x11/meta-clutter-backend-x11.c b/src/backends/x11/meta-clutter-backend-x11.c
index d0654fa8a..33a9138a2 100644
--- a/src/backends/x11/meta-clutter-backend-x11.c
+++ b/src/backends/x11/meta-clutter-backend-x11.c
@@ -96,17 +96,6 @@ meta_clutter_backend_x11_get_device_manager (ClutterBackend *backend)
   return CLUTTER_DEVICE_MANAGER (backend_x11->device_manager);
 }
 
-static PangoDirection
-meta_clutter_backend_x11_get_keymap_direction (ClutterBackend *backend)
-{
-  ClutterKeymap *keymap = clutter_backend_get_keymap (backend);
-
-  if (G_UNLIKELY (keymap == NULL))
-    return PANGO_DIRECTION_NEUTRAL;
-
-  return meta_keymap_x11_get_direction (META_KEYMAP_X11 (keymap));
-}
-
 static ClutterKeymap *
 meta_clutter_backend_x11_get_keymap (ClutterBackend *backend)
 {
@@ -200,7 +189,6 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
   clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage;
   clutter_backend_class->bell_notify = meta_clutter_backend_x11_bell_notify;
   clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager;
-  clutter_backend_class->get_keymap_direction = meta_clutter_backend_x11_get_keymap_direction;
   clutter_backend_class->get_keymap = meta_clutter_backend_x11_get_keymap;
   clutter_backend_class->translate_event = meta_clutter_backend_x11_translate_event;
   clutter_backend_class->init_events = meta_clutter_backend_x11_init_events;
diff --git a/src/backends/x11/meta-keymap-x11.c b/src/backends/x11/meta-keymap-x11.c
index e0c1c2a55..acc6682ed 100644
--- a/src/backends/x11/meta-keymap-x11.c
+++ b/src/backends/x11/meta-keymap-x11.c
@@ -515,6 +515,30 @@ meta_keymap_x11_get_caps_lock_state (ClutterKeymap *keymap)
   return keymap_x11->caps_lock_state;
 }
 
+static PangoDirection
+meta_keymap_x11_get_direction (MetaKeymapX11 *keymap)
+{
+  g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL);
+
+  if (keymap->use_xkb)
+    {
+      if (!keymap->has_direction)
+        {
+          XkbStateRec state_rec;
+
+          XkbGetState (clutter_x11_get_default_display (),
+                       XkbUseCoreKbd, &state_rec);
+          update_direction (keymap, XkbStateGroup (&state_rec));
+        }
+
+      return keymap->current_direction;
+    }
+  else
+    {
+      return PANGO_DIRECTION_NEUTRAL;
+    }
+}
+
 static void
 meta_keymap_x11_class_init (MetaKeymapX11Class *klass)
 {
@@ -534,6 +558,7 @@ meta_keymap_x11_class_init (MetaKeymapX11Class *klass)
 
   keymap_class->get_num_lock_state = meta_keymap_x11_get_num_lock_state;
   keymap_class->get_caps_lock_state = meta_keymap_x11_get_caps_lock_state;
+  keymap_class->get_direction = meta_keymap_x11_get_direction;
 
   g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
 }
@@ -680,28 +705,6 @@ meta_keymap_x11_get_is_modifier (MetaKeymapX11 *keymap,
   return FALSE;
 }
 
-PangoDirection
-meta_keymap_x11_get_direction (MetaKeymapX11 *keymap)
-{
-  g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL);
-
-  if (keymap->use_xkb)
-    {
-      if (!keymap->has_direction)
-        {
-          XkbStateRec state_rec;
-
-          XkbGetState (clutter_x11_get_default_display (),
-                       XkbUseCoreKbd, &state_rec);
-          update_direction (keymap, XkbStateGroup (&state_rec));
-        }
-
-      return keymap->current_direction;
-    }
-  else
-    return PANGO_DIRECTION_NEUTRAL;
-}
-
 static gboolean
 meta_keymap_x11_get_entries_for_keyval (MetaKeymapX11     *keymap_x11,
                                         uint32_t           keyval,
diff --git a/src/backends/x11/meta-keymap-x11.h b/src/backends/x11/meta-keymap-x11.h
index e4e3a67e1..67a5f8eb9 100644
--- a/src/backends/x11/meta-keymap-x11.h
+++ b/src/backends/x11/meta-keymap-x11.h
@@ -40,8 +40,6 @@ int      meta_keymap_x11_translate_key_state (MetaKeymapX11       *keymap,
 gboolean meta_keymap_x11_get_is_modifier     (MetaKeymapX11       *keymap,
                                               int                  keycode);
 
-PangoDirection meta_keymap_x11_get_direction (MetaKeymapX11       *keymap);
-
 gboolean meta_keymap_x11_keycode_for_keyval       (MetaKeymapX11    *keymap_x11,
                                                    guint             keyval,
                                                    guint            *keycode_out,


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