From 5685449e15ffa401485547cbdcf58e96d3b045f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 17 Aug 2017 16:17:45 +0800 Subject: [PATCH] clutter/evdev: Add API to get current layout index We set the layout index when changing keyboard layout, but have no way to get it back would so be needed. Add that. https://bugzilla.gnome.org/show_bug.cgi?id=786408 --- .../clutter/evdev/clutter-device-manager-evdev.c | 15 +++++++++++++++ clutter/clutter/evdev/clutter-evdev.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c b/clutter/clutter/evdev/clutter-device-manager-evdev.c index c3fdc90aa..479f86937 100644 --- a/clutter/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c @@ -2602,6 +2602,21 @@ clutter_evdev_set_keyboard_layout_index (ClutterDeviceManager *evdev, xkb_state_update_mask (state, depressed_mods, latched_mods, locked_mods, 0, 0, idx); } +/** + * clutter_evdev_get_keyboard_layout_index: (skip) + */ +xkb_layout_index_t +clutter_evdev_get_keyboard_layout_index (ClutterDeviceManager *evdev) +{ + ClutterDeviceManagerEvdev *manager_evdev; + struct xkb_state *state; + + manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (evdev); + state = manager_evdev->priv->main_seat->xkb; + + return xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_LOCKED); +} + /** * clutter_evdev_set_keyboard_numlock: (skip) * @evdev: the #ClutterDeviceManager created by the evdev backend diff --git a/clutter/clutter/evdev/clutter-evdev.h b/clutter/clutter/evdev/clutter-evdev.h index b64b1364b..be7f09c44 100644 --- a/clutter/clutter/evdev/clutter-evdev.h +++ b/clutter/clutter/evdev/clutter-evdev.h @@ -120,6 +120,9 @@ CLUTTER_AVAILABLE_IN_1_20 void clutter_evdev_set_keyboard_layout_index (ClutterDeviceManager *evdev, xkb_layout_index_t idx); +CLUTTER_AVAILABLE_IN_MUTTER +xkb_layout_index_t clutter_evdev_get_keyboard_layout_index (ClutterDeviceManager *evdev); + CLUTTER_AVAILABLE_IN_1_26 void clutter_evdev_set_keyboard_numlock (ClutterDeviceManager *evdev, gboolean numlock_state);