From 7a6c7558337c3e24b09bfb3b93a3a7d314c3748b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 17 May 2019 18:11:43 -0500 Subject: [PATCH] clutter: Add fribidi dependency and copy deprecated pango functions Pango functions pango_unichar_direction() and pango_find_base_dir() have been deprecated in pango 1.44, since these are used mostly clutter and gtk, copy the code from pango and use fribidi dependency explicitly. This is the same strategy used by Gtk. https://gitlab.gnome.org/GNOME/mutter/merge_requests/583 --- clutter/clutter/clutter-private.h | 5 +++ clutter/clutter/clutter-text.c | 2 +- clutter/clutter/clutter-util.c | 43 ++++++++++++++++++++++++ clutter/clutter/x11/clutter-keymap-x11.c | 3 +- clutter/meson.build | 1 + meson.build | 2 ++ 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index a5cd1fa19..d4706808e 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -303,6 +303,11 @@ gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src, ClutterVertex *translate_p, ClutterVertex4 *perspective_p); +PangoDirection _clutter_pango_unichar_direction (gunichar ch); + +PangoDirection _clutter_pango_find_base_dir (const gchar *text, + gint length); + typedef struct _ClutterPlane { float v0[3]; diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index fb9d926df..9222cedfc 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -751,7 +751,7 @@ clutter_text_create_layout_no_cache (ClutterText *text, if (priv->password_char != 0) pango_dir = PANGO_DIRECTION_NEUTRAL; else - pango_dir = pango_find_base_dir (contents, contents_len); + pango_dir = _clutter_pango_find_base_dir (contents, contents_len); if (pango_dir == PANGO_DIRECTION_NEUTRAL) { diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c index ed52b6977..05d5d0e4c 100644 --- a/clutter/clutter/clutter-util.c +++ b/clutter/clutter/clutter-util.c @@ -32,6 +32,7 @@ #include "clutter-build-config.h" +#include #include #include "clutter-debug.h" @@ -696,3 +697,45 @@ clutter_interval_register_progress_func (GType value_type, G_UNLOCK (progress_funcs); } + +PangoDirection +_clutter_pango_unichar_direction (gunichar ch) +{ + FriBidiCharType fribidi_ch_type; + + G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar)); + + fribidi_ch_type = fribidi_get_bidi_type (ch); + + if (!FRIBIDI_IS_STRONG (fribidi_ch_type)) + return PANGO_DIRECTION_NEUTRAL; + else if (FRIBIDI_IS_RTL (fribidi_ch_type)) + return PANGO_DIRECTION_RTL; + else + return PANGO_DIRECTION_LTR; +} + +PangoDirection +_clutter_pango_find_base_dir (const gchar *text, + gint length) +{ + PangoDirection dir = PANGO_DIRECTION_NEUTRAL; + const gchar *p; + + g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL); + + p = text; + while ((length < 0 || p < text + length) && *p) + { + gunichar wc = g_utf8_get_char (p); + + dir = _clutter_pango_unichar_direction (wc); + + if (dir != PANGO_DIRECTION_NEUTRAL) + break; + + p = g_utf8_next_char (p); + } + + return dir; +} diff --git a/clutter/clutter/x11/clutter-keymap-x11.c b/clutter/clutter/x11/clutter-keymap-x11.c index f0c57d2cd..b92ba70bc 100644 --- a/clutter/clutter/x11/clutter-keymap-x11.c +++ b/clutter/clutter/x11/clutter-keymap-x11.c @@ -250,7 +250,8 @@ get_direction (XkbDescPtr xkb, { int level = 0; KeySym sym = XkbKeySymEntry (xkb, code, level, group); - PangoDirection dir = pango_unichar_direction (clutter_keysym_to_unicode (sym)); + PangoDirection dir = + _clutter_pango_unichar_direction (clutter_keysym_to_unicode (sym)); switch (dir) { diff --git a/clutter/meson.build b/clutter/meson.build index 0db934209..ab34c74c4 100644 --- a/clutter/meson.build +++ b/clutter/meson.build @@ -38,6 +38,7 @@ clutter_pkg_deps = [ ] clutter_pkg_private_deps = [ + fribidi_dep, gdk_pixbuf_dep, gthread_dep, gmodule_no_export_dep, diff --git a/meson.build b/meson.build index 01e843d41..9d600377f 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,7 @@ mutter_plugin_api_version = '3' libmutter_api_version = '4' # generic version requirements +fribidi_req = '>= 1.0.0' glib_req = '>= 2.53.2' gi_req = '>= 0.9.5' gtk3_req = '>= 3.19.8' @@ -86,6 +87,7 @@ pango_dep = dependency('pango', version: pango_req) cairo_dep = dependency('cairo', version: cairo_req) cairo_gobject_dep = dependency('cairo-gobject', version: cairo_req) pangocairo_dep = dependency('pangocairo', version: pangocairo_req) +fribidi_dep = dependency('fribidi', version: fribidi_req) gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', version: gsettings_desktop_schemas_req) glib_dep = dependency('glib-2.0', version: glib_req)