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
This commit is contained in:
Carlos Garnacho 2019-10-01 13:51:12 +02:00
parent 5bb3d86884
commit 9aba37f70f
9 changed files with 48 additions and 53 deletions

View File

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

View File

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

View File

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

View File

@ -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 */

View File

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

View File

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

View File

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

View File

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

View File

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