diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index d6729085e..e87fcfa9f 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -12891,17 +12891,16 @@ update_pango_context (ClutterBackend *backend, ClutterSettings *settings; PangoFontDescription *font_desc; const cairo_font_options_t *font_options; - gchar *font_name; + ClutterTextDirection dir; PangoDirection pango_dir; + gchar *font_name; gdouble resolution; settings = clutter_settings_get_default (); /* update the text direction */ - if (clutter_get_default_text_direction () == CLUTTER_TEXT_DIRECTION_RTL) - pango_dir = PANGO_DIRECTION_RTL; - else - pango_dir = PANGO_DIRECTION_LTR; + dir = clutter_get_default_text_direction (); + pango_dir = clutter_text_direction_to_pango_direction (dir); pango_context_set_base_dir (context, pango_dir); diff --git a/clutter/clutter/clutter-backend.h b/clutter/clutter/clutter-backend.h index cf25693f1..f04bf456a 100644 --- a/clutter/clutter/clutter-backend.h +++ b/clutter/clutter/clutter-backend.h @@ -28,7 +28,6 @@ #endif #include -#include #include "cogl/cogl.h" diff --git a/clutter/clutter/clutter-keymap.c b/clutter/clutter/clutter-keymap.c index 6c7b74274..a18571a00 100644 --- a/clutter/clutter/clutter-keymap.c +++ b/clutter/clutter/clutter-keymap.c @@ -147,7 +147,7 @@ clutter_keymap_get_caps_lock_state (ClutterKeymap *keymap) return priv->caps_lock_state; } -PangoDirection +ClutterTextDirection 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 4008fcf0a..3601e6f42 100644 --- a/clutter/clutter/clutter-keymap.h +++ b/clutter/clutter/clutter-keymap.h @@ -23,10 +23,11 @@ #error "Only can be included directly." #endif +#include + +#include "clutter/clutter-enums.h" #include "clutter/clutter-macros.h" -#include -#include typedef struct _ClutterKeymap ClutterKeymap; typedef struct _ClutterKeymapClass ClutterKeymapClass; @@ -35,7 +36,7 @@ struct _ClutterKeymapClass { GObjectClass parent_class; - PangoDirection (* get_direction) (ClutterKeymap *keymap); + ClutterTextDirection (* get_direction) (ClutterKeymap *keymap); }; #define CLUTTER_TYPE_KEYMAP (clutter_keymap_get_type ()) @@ -50,4 +51,4 @@ 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); +ClutterTextDirection clutter_keymap_get_direction (ClutterKeymap *keymap); diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c index 114c09252..94b20756b 100644 --- a/clutter/clutter/clutter-paint-node.c +++ b/clutter/clutter/clutter-paint-node.c @@ -50,7 +50,6 @@ #include "config.h" #include -#include #include "cogl/cogl.h" #include "clutter/clutter-paint-node-private.h" diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index 1db1fed6a..bd0dcac69 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -27,6 +27,7 @@ #include #include +#include #include "cogl-pango/cogl-pango.h" @@ -145,10 +146,13 @@ void _clutter_util_fully_transform_vertices (const graphene_matrix_t *modelvie int n_vertices); CLUTTER_EXPORT -PangoDirection _clutter_pango_unichar_direction (gunichar ch); +ClutterTextDirection clutter_unichar_direction (gunichar ch); -PangoDirection _clutter_pango_find_base_dir (const gchar *text, - gint length); +ClutterTextDirection _clutter_find_base_dir (const gchar *text, + gint length); + +PangoDirection +clutter_text_direction_to_pango_direction (ClutterTextDirection dir); typedef enum _ClutterCullResult { diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index 77484a681..9f2b3544b 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -732,17 +732,18 @@ clutter_text_create_layout_no_cache (ClutterText *text, } else { + ClutterTextDirection dir; PangoDirection pango_dir; + PangoContext *context; if (priv->password_char != 0) - pango_dir = PANGO_DIRECTION_NEUTRAL; + dir = CLUTTER_TEXT_DIRECTION_DEFAULT; else - pango_dir = _clutter_pango_find_base_dir (contents, contents_len); + dir = _clutter_find_base_dir (contents, contents_len); - if (pango_dir == PANGO_DIRECTION_NEUTRAL) + if (dir == CLUTTER_TEXT_DIRECTION_DEFAULT) { ClutterBackend *backend = clutter_get_default_backend (); - ClutterTextDirection text_dir; if (clutter_actor_has_key_focus (CLUTTER_ACTOR (text))) { @@ -751,22 +752,20 @@ clutter_text_create_layout_no_cache (ClutterText *text, seat = clutter_backend_get_default_seat (backend); keymap = clutter_seat_get_keymap (seat); - pango_dir = clutter_keymap_get_direction (keymap); + dir = clutter_keymap_get_direction (keymap); } else { - text_dir = clutter_actor_get_text_direction (CLUTTER_ACTOR (text)); - - if (text_dir == CLUTTER_TEXT_DIRECTION_RTL) - pango_dir = PANGO_DIRECTION_RTL; - else - pango_dir = PANGO_DIRECTION_LTR; - } + dir = clutter_actor_get_text_direction (CLUTTER_ACTOR (text)); + } } - pango_context_set_base_dir (clutter_actor_get_pango_context (CLUTTER_ACTOR (text)), pango_dir); + pango_dir = clutter_text_direction_to_pango_direction (dir); + context = clutter_actor_get_pango_context (CLUTTER_ACTOR (text)); - priv->resolved_direction = pango_dir; + pango_context_set_base_dir (context, pango_dir); + + priv->resolved_direction = dir; pango_layout_set_text (layout, contents, contents_len); } @@ -2686,7 +2685,7 @@ clutter_text_paint (ClutterActor *self, actor_width = alloc_width - 2 * TEXT_PADDING; text_width = pango_to_pixels (logical_rect.width); - rtl = priv->resolved_direction == PANGO_DIRECTION_RTL; + rtl = priv->resolved_direction == CLUTTER_TEXT_DIRECTION_RTL; if (actor_width < text_width) { diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c index 973a9f29d..26f38f083 100644 --- a/clutter/clutter/clutter-util.c +++ b/clutter/clutter/clutter-util.c @@ -256,8 +256,8 @@ clutter_interval_register_progress_func (GType value_type, G_UNLOCK (progress_funcs); } -PangoDirection -_clutter_pango_unichar_direction (gunichar ch) +ClutterTextDirection +clutter_unichar_direction (gunichar ch) { FriBidiCharType fribidi_ch_type; @@ -266,30 +266,30 @@ _clutter_pango_unichar_direction (gunichar ch) fribidi_ch_type = fribidi_get_bidi_type (ch); if (!FRIBIDI_IS_STRONG (fribidi_ch_type)) - return PANGO_DIRECTION_NEUTRAL; + return CLUTTER_TEXT_DIRECTION_DEFAULT; else if (FRIBIDI_IS_RTL (fribidi_ch_type)) - return PANGO_DIRECTION_RTL; + return CLUTTER_TEXT_DIRECTION_RTL; else - return PANGO_DIRECTION_LTR; + return CLUTTER_TEXT_DIRECTION_LTR; } -PangoDirection -_clutter_pango_find_base_dir (const gchar *text, - gint length) +ClutterTextDirection +_clutter_find_base_dir (const gchar *text, + gint length) { - PangoDirection dir = PANGO_DIRECTION_NEUTRAL; + ClutterTextDirection dir = CLUTTER_TEXT_DIRECTION_DEFAULT; const gchar *p; - g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL); + g_return_val_if_fail (text != NULL || length == 0, CLUTTER_TEXT_DIRECTION_DEFAULT); p = text; while ((length < 0 || p < text + length) && *p) { gunichar wc = g_utf8_get_char (p); - dir = _clutter_pango_unichar_direction (wc); + dir = clutter_unichar_direction (wc); - if (dir != PANGO_DIRECTION_NEUTRAL) + if (dir != CLUTTER_TEXT_DIRECTION_DEFAULT) break; p = g_utf8_next_char (p); @@ -297,3 +297,18 @@ _clutter_pango_find_base_dir (const gchar *text, return dir; } + +PangoDirection +clutter_text_direction_to_pango_direction (ClutterTextDirection dir) +{ + switch (dir) + { + case CLUTTER_TEXT_DIRECTION_RTL: + return PANGO_DIRECTION_RTL; + case CLUTTER_TEXT_DIRECTION_LTR: + return PANGO_DIRECTION_LTR; + default: + case CLUTTER_TEXT_DIRECTION_DEFAULT: + return PANGO_DIRECTION_NEUTRAL; + } +} diff --git a/src/backends/native/meta-keymap-native.c b/src/backends/native/meta-keymap-native.c index df87571fa..42eb99c43 100644 --- a/src/backends/native/meta-keymap-native.c +++ b/src/backends/native/meta-keymap-native.c @@ -53,10 +53,10 @@ meta_keymap_native_finalize (GObject *object) G_OBJECT_CLASS (meta_keymap_native_parent_class)->finalize (object); } -static PangoDirection +static ClutterTextDirection meta_keymap_native_get_direction (ClutterKeymap *keymap) { - return PANGO_DIRECTION_NEUTRAL; + return CLUTTER_TEXT_DIRECTION_DEFAULT; } static void diff --git a/src/backends/x11/meta-keymap-x11.c b/src/backends/x11/meta-keymap-x11.c index dbb07723b..b546b6a7c 100644 --- a/src/backends/x11/meta-keymap-x11.c +++ b/src/backends/x11/meta-keymap-x11.c @@ -49,7 +49,7 @@ struct _DirectionCacheEntry { uint32_t serial; Atom group_atom; - PangoDirection direction; + ClutterTextDirection direction; }; struct _MetaKeymapX11 @@ -67,7 +67,7 @@ struct _MetaKeymapX11 ClutterModifierType scroll_lock_mask; ClutterModifierType level3_shift_mask; - PangoDirection current_direction; + ClutterTextDirection current_direction; XkbDescPtr xkb_desc; int xkb_event_base; @@ -244,7 +244,7 @@ update_locked_mods (MetaKeymapX11 *keymap_x11, * is taken from GDK: * gdk/x11/gdkkeys-x11.c */ -static PangoDirection +static ClutterTextDirection get_direction (XkbDescPtr xkb, int group) { @@ -257,16 +257,16 @@ get_direction (XkbDescPtr xkb, { int level = 0; KeySym sym = XkbKeySymEntry (xkb, code, level, group); - PangoDirection dir = - _clutter_pango_unichar_direction (clutter_keysym_to_unicode (sym)); + ClutterTextDirection dir = + clutter_unichar_direction (clutter_keysym_to_unicode (sym)); switch (dir) { - case PANGO_DIRECTION_RTL: + case CLUTTER_TEXT_DIRECTION_RTL: rtl_minus_ltr++; break; - case PANGO_DIRECTION_LTR: + case CLUTTER_TEXT_DIRECTION_LTR: rtl_minus_ltr--; break; @@ -276,12 +276,12 @@ get_direction (XkbDescPtr xkb, } if (rtl_minus_ltr > 0) - return PANGO_DIRECTION_RTL; + return CLUTTER_TEXT_DIRECTION_RTL; - return PANGO_DIRECTION_LTR; + return CLUTTER_TEXT_DIRECTION_LTR; } -static PangoDirection +static ClutterTextDirection get_direction_from_cache (MetaKeymapX11 *keymap_x11, XkbDescPtr xkb, int group) @@ -289,7 +289,7 @@ get_direction_from_cache (MetaKeymapX11 *keymap_x11, Atom group_atom = xkb->names->groups[group]; gboolean cache_hit = FALSE; DirectionCacheEntry *cache = keymap_x11->group_direction_cache; - PangoDirection direction = PANGO_DIRECTION_NEUTRAL; + ClutterTextDirection direction = CLUTTER_TEXT_DIRECTION_DEFAULT; int i; if (keymap_x11->has_direction) @@ -313,7 +313,7 @@ get_direction_from_cache (MetaKeymapX11 *keymap_x11, for (i = 0; i < G_N_ELEMENTS (keymap_x11->group_direction_cache); i++) { cache[i].group_atom = 0; - cache[i].direction = PANGO_DIRECTION_NEUTRAL; + cache[i].direction = CLUTTER_TEXT_DIRECTION_DEFAULT; cache[i].serial = keymap_x11->current_cache_serial; } @@ -514,12 +514,12 @@ meta_keymap_x11_finalize (GObject *object) G_OBJECT_CLASS (meta_keymap_x11_parent_class)->finalize (object); } -static PangoDirection +static ClutterTextDirection meta_keymap_x11_get_direction (ClutterKeymap *keymap) { MetaKeymapX11 *keymap_x11; - g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL); + g_return_val_if_fail (META_IS_KEYMAP_X11 (keymap), CLUTTER_TEXT_DIRECTION_DEFAULT); keymap_x11 = META_KEYMAP_X11 (keymap); @@ -538,7 +538,7 @@ meta_keymap_x11_get_direction (ClutterKeymap *keymap) } else { - return PANGO_DIRECTION_NEUTRAL; + return CLUTTER_TEXT_DIRECTION_DEFAULT; } } @@ -565,7 +565,7 @@ meta_keymap_x11_class_init (MetaKeymapX11Class *klass) static void meta_keymap_x11_init (MetaKeymapX11 *keymap) { - keymap->current_direction = PANGO_DIRECTION_NEUTRAL; + keymap->current_direction = CLUTTER_TEXT_DIRECTION_DEFAULT; keymap->current_group = -1; keymap->reserved_keycodes = g_hash_table_new (NULL, NULL); keymap->available_keycodes = g_queue_new (); diff --git a/src/backends/x11/meta-keymap-x11.h b/src/backends/x11/meta-keymap-x11.h index 537618778..e3534cbe7 100644 --- a/src/backends/x11/meta-keymap-x11.h +++ b/src/backends/x11/meta-keymap-x11.h @@ -20,7 +20,6 @@ #pragma once #include -#include #include "clutter/clutter.h" diff --git a/src/meson.build b/src/meson.build index 06255bf84..8f8a6571d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,7 +17,6 @@ mutter_pkg_deps = [ gio_unix_dep, glib_dep, gsettings_desktop_schemas_dep, - pango_dep, ] mutter_pkg_private_deps = [ diff --git a/src/meta/prefs.h b/src/meta/prefs.h index b692d5a0b..1afc3dc2e 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -22,7 +22,6 @@ #pragma once -#include #include #include