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
This commit is contained in:
Marco Trevisan (Treviño) 2019-05-17 18:11:43 -05:00
parent 45244852ac
commit 7a6c755833
6 changed files with 54 additions and 2 deletions

View File

@ -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];

View File

@ -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)
{

View File

@ -32,6 +32,7 @@
#include "clutter-build-config.h"
#include <fribidi.h>
#include <math.h>
#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;
}

View File

@ -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)
{

View File

@ -38,6 +38,7 @@ clutter_pkg_deps = [
]
clutter_pkg_private_deps = [
fribidi_dep,
gdk_pixbuf_dep,
gthread_dep,
gmodule_no_export_dep,

View File

@ -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)