clutter: Move keymap from ClutterBackend to ClutterSeat

Keymaps are a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
Carlos Garnacho 2019-10-01 17:27:23 +02:00
parent 1fc021c3c6
commit 9be4f98c73
21 changed files with 123 additions and 102 deletions

View File

@ -24,7 +24,6 @@
#include <clutter/clutter-backend.h> #include <clutter/clutter-backend.h>
#include <clutter/clutter-device-manager.h> #include <clutter/clutter-device-manager.h>
#include <clutter/clutter-keymap.h>
#include <clutter/clutter-seat.h> #include <clutter/clutter-seat.h>
#include <clutter/clutter-stage-window.h> #include <clutter/clutter-stage-window.h>
@ -60,8 +59,6 @@ struct _ClutterBackend
ClutterStageWindow *stage_window; ClutterStageWindow *stage_window;
ClutterInputMethod *input_method; ClutterInputMethod *input_method;
ClutterKeymap *keymap;
}; };
struct _ClutterBackendClass struct _ClutterBackendClass
@ -96,8 +93,6 @@ struct _ClutterBackendClass
gpointer native, gpointer native,
ClutterEvent *event); ClutterEvent *event);
ClutterKeymap * (* get_keymap) (ClutterBackend *backend);
ClutterSeat * (* get_default_seat) (ClutterBackend *backend); ClutterSeat * (* get_default_seat) (ClutterBackend *backend);
/* signals */ /* signals */

View File

@ -540,18 +540,6 @@ clutter_backend_real_get_device_manager (ClutterBackend *backend)
return backend->device_manager; return backend->device_manager;
} }
static ClutterKeymap *
clutter_backend_real_get_keymap (ClutterBackend *backend)
{
if (G_UNLIKELY (backend->keymap == NULL))
{
g_critical ("No keymap available, expect broken keyboard input");
return NULL;
}
return backend->keymap;
}
static void static void
clutter_backend_class_init (ClutterBackendClass *klass) clutter_backend_class_init (ClutterBackendClass *klass)
{ {
@ -618,7 +606,6 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->get_device_manager = clutter_backend_real_get_device_manager; klass->get_device_manager = clutter_backend_real_get_device_manager;
klass->create_context = clutter_backend_real_create_context; klass->create_context = clutter_backend_real_create_context;
klass->get_features = clutter_backend_real_get_features; klass->get_features = clutter_backend_real_get_features;
klass->get_keymap = clutter_backend_real_get_keymap;
} }
static void static void
@ -1037,20 +1024,6 @@ clutter_backend_set_input_method (ClutterBackend *backend,
g_set_object (&backend->input_method, method); g_set_object (&backend->input_method, method);
} }
/**
* clutter_backend_get_keymap:
* @backend: the #ClutterBackend
*
* Gets the keymap used by Clutter
*
* Returns: (transfer none): the keymap
**/
ClutterKeymap *
clutter_backend_get_keymap (ClutterBackend *backend)
{
return CLUTTER_BACKEND_GET_CLASS (backend)->get_keymap (backend);
}
ClutterStageWindow * ClutterStageWindow *
clutter_backend_get_stage_window (ClutterBackend *backend) clutter_backend_get_stage_window (ClutterBackend *backend)
{ {

View File

@ -79,9 +79,6 @@ ClutterInputMethod * clutter_backend_get_input_method (Clutter
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_backend_set_input_method (ClutterBackend *backend, void clutter_backend_set_input_method (ClutterBackend *backend,
ClutterInputMethod *method); ClutterInputMethod *method);
CLUTTER_EXPORT
ClutterKeymap * clutter_backend_get_keymap (ClutterBackend *backend);
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterSeat * clutter_backend_get_default_seat (ClutterBackend *backend); ClutterSeat * clutter_backend_get_default_seat (ClutterBackend *backend);

View File

@ -214,3 +214,17 @@ clutter_seat_bell_notify (ClutterSeat *seat)
{ {
CLUTTER_SEAT_GET_CLASS (seat)->bell_notify (seat); CLUTTER_SEAT_GET_CLASS (seat)->bell_notify (seat);
} }
/**
* clutter_seat_get_keymap:
* @seat: a #ClutterSeat
*
* Returns the seat keymap
*
* Returns: (transfer none): the seat keymap
**/
ClutterKeymap *
clutter_seat_get_keymap (ClutterSeat *seat)
{
return CLUTTER_SEAT_GET_CLASS (seat)->get_keymap (seat);
}

View File

@ -28,6 +28,7 @@
#endif #endif
#include "clutter/clutter-types.h" #include "clutter/clutter-types.h"
#include "clutter/clutter-keymap.h"
#define CLUTTER_TYPE_SEAT (clutter_seat_get_type ()) #define CLUTTER_TYPE_SEAT (clutter_seat_get_type ())
@ -47,6 +48,8 @@ struct _ClutterSeatClass
GList * (* list_devices) (ClutterSeat *seat); GList * (* list_devices) (ClutterSeat *seat);
void (* bell_notify) (ClutterSeat *seat); void (* bell_notify) (ClutterSeat *seat);
ClutterKeymap * (* get_keymap) (ClutterSeat *seat);
}; };
CLUTTER_EXPORT CLUTTER_EXPORT
@ -58,4 +61,7 @@ GList * clutter_seat_list_devices (ClutterSeat *seat);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_seat_bell_notify (ClutterSeat *seat); void clutter_seat_bell_notify (ClutterSeat *seat);
CLUTTER_EXPORT
ClutterKeymap * clutter_seat_get_keymap (ClutterSeat *seat);
#endif /* CLUTTER_SEAT_H */ #endif /* CLUTTER_SEAT_H */

View File

@ -760,9 +760,11 @@ clutter_text_create_layout_no_cache (ClutterText *text,
if (clutter_actor_has_key_focus (CLUTTER_ACTOR (text))) if (clutter_actor_has_key_focus (CLUTTER_ACTOR (text)))
{ {
ClutterSeat *seat;
ClutterKeymap *keymap; ClutterKeymap *keymap;
keymap = clutter_backend_get_keymap (backend); seat = clutter_backend_get_default_seat (backend);
keymap = clutter_seat_get_keymap (seat);
pango_dir = clutter_keymap_get_direction (keymap); pango_dir = clutter_keymap_get_direction (keymap);
} }
else else

View File

@ -181,9 +181,11 @@ meta_backend_finalize (GObject *object)
if (priv->keymap_state_changed_id) if (priv->keymap_state_changed_id)
{ {
ClutterSeat *seat;
ClutterKeymap *keymap; ClutterKeymap *keymap;
keymap = clutter_backend_get_keymap (priv->clutter_backend); seat = clutter_backend_get_default_seat (priv->clutter_backend);
keymap = clutter_seat_get_keymap (seat);
g_clear_signal_handler (&priv->keymap_state_changed_id, keymap); g_clear_signal_handler (&priv->keymap_state_changed_id, keymap);
} }
@ -499,7 +501,8 @@ meta_backend_real_post_init (MetaBackend *backend)
{ {
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
ClutterDeviceManager *device_manager = clutter_device_manager_get_default (); ClutterDeviceManager *device_manager = clutter_device_manager_get_default ();
ClutterKeymap *keymap = clutter_backend_get_keymap (priv->clutter_backend); ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
ClutterKeymap *keymap = clutter_seat_get_keymap (seat);
priv->stage = meta_stage_new (backend); priv->stage = meta_stage_new (backend);
clutter_actor_realize (priv->stage); clutter_actor_realize (priv->stage);

View File

@ -2642,6 +2642,7 @@ void
meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings) meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings)
{ {
MetaInputSettingsPrivate *priv; MetaInputSettingsPrivate *priv;
ClutterSeat *seat;
ClutterKeymap *keymap; ClutterKeymap *keymap;
gboolean numlock_state; gboolean numlock_state;
@ -2650,7 +2651,8 @@ meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings)
if (!g_settings_get_boolean (priv->keyboard_settings, "remember-numlock-state")) if (!g_settings_get_boolean (priv->keyboard_settings, "remember-numlock-state"))
return; return;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
keymap = clutter_seat_get_keymap (seat);
numlock_state = clutter_keymap_get_num_lock_state (keymap); numlock_state = clutter_keymap_get_num_lock_state (keymap);
if (numlock_state == g_settings_get_boolean (priv->keyboard_settings, "numlock-state")) if (numlock_state == g_settings_get_boolean (priv->keyboard_settings, "numlock-state"))

View File

@ -45,7 +45,6 @@
#include "backends/meta-backend-private.h" #include "backends/meta-backend-private.h"
#include "backends/meta-renderer.h" #include "backends/meta-renderer.h"
#include "backends/native/meta-device-manager-native.h" #include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-seat-native.h" #include "backends/native/meta-seat-native.h"
#include "backends/native/meta-stage-native.h" #include "backends/native/meta-stage-native.h"
#include "clutter/clutter.h" #include "clutter/clutter.h"
@ -58,7 +57,6 @@ struct _MetaClutterBackendNative
MetaSeatNative *main_seat; MetaSeatNative *main_seat;
MetaStageNative *stage_native; MetaStageNative *stage_native;
MetaKeymapNative *keymap;
MetaDeviceManagerNative *device_manager; MetaDeviceManagerNative *device_manager;
}; };
@ -111,21 +109,12 @@ meta_clutter_backend_native_get_device_manager (ClutterBackend *backend)
return CLUTTER_DEVICE_MANAGER (backend_native->device_manager); return CLUTTER_DEVICE_MANAGER (backend_native->device_manager);
} }
static ClutterKeymap *
meta_clutter_backend_native_get_keymap (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_KEYMAP (backend_native->keymap);
}
static void static void
meta_clutter_backend_native_init_events (ClutterBackend *backend) meta_clutter_backend_native_init_events (ClutterBackend *backend)
{ {
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend); MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
const gchar *seat_id = evdev_seat_id ? evdev_seat_id : "seat0"; const gchar *seat_id = evdev_seat_id ? evdev_seat_id : "seat0";
backend_native->keymap = g_object_new (META_TYPE_KEYMAP_NATIVE, NULL);
backend_native->main_seat = g_object_new (META_TYPE_SEAT_NATIVE, backend_native->main_seat = g_object_new (META_TYPE_SEAT_NATIVE,
"backend", backend, "backend", backend,
"seat-id", seat_id, "seat-id", seat_id,
@ -155,7 +144,6 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer; clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage; clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage;
clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager; clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager;
clutter_backend_class->get_keymap = meta_clutter_backend_native_get_keymap;
clutter_backend_class->init_events = meta_clutter_backend_native_init_events; clutter_backend_class->init_events = meta_clutter_backend_native_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat; clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat;
} }

View File

@ -320,11 +320,11 @@ meta_device_manager_native_set_keyboard_map (ClutterDeviceManager *evdev,
g_return_if_fail (META_IS_DEVICE_MANAGER_NATIVE (evdev)); g_return_if_fail (META_IS_DEVICE_MANAGER_NATIVE (evdev));
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); manager_evdev = META_DEVICE_MANAGER_NATIVE (evdev);
keymap = clutter_seat_get_keymap (CLUTTER_SEAT (manager_evdev->priv->main_seat));
meta_keymap_native_set_keyboard_map (META_KEYMAP_NATIVE (keymap), meta_keymap_native_set_keyboard_map (META_KEYMAP_NATIVE (keymap),
xkb_keymap); xkb_keymap);
manager_evdev = META_DEVICE_MANAGER_NATIVE (evdev);
meta_seat_native_update_xkb_state (manager_evdev->priv->main_seat); meta_seat_native_update_xkb_state (manager_evdev->priv->main_seat);
} }
@ -428,7 +428,7 @@ meta_device_manager_native_set_keyboard_numlock (ClutterDeviceManager *evdev,
manager_evdev = META_DEVICE_MANAGER_NATIVE (evdev); manager_evdev = META_DEVICE_MANAGER_NATIVE (evdev);
priv = manager_evdev->priv; priv = manager_evdev->priv;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); keymap = clutter_seat_get_keymap (CLUTTER_SEAT (priv->main_seat));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap)); xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
numlock = (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod2")); numlock = (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod2"));

View File

@ -28,6 +28,7 @@
#include "backends/meta-logical-monitor.h" #include "backends/meta-logical-monitor.h"
#include "backends/native/meta-backend-native.h" #include "backends/native/meta-backend-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-input-device-native.h" #include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h" #include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-input-settings-native.h" #include "backends/native/meta-input-settings-native.h"

View File

@ -18,6 +18,8 @@
* *
* Author: Carlos Garnacho <carlosg@gnome.org> * Author: Carlos Garnacho <carlosg@gnome.org>
*/ */
#ifndef META_KEYMAP_NATIVE_H
#define META_KEYMAP_NATIVE_H
#include "backends/native/meta-xkb-utils.h" #include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h" #include "clutter/clutter.h"
@ -30,3 +32,5 @@ G_DECLARE_FINAL_TYPE (MetaKeymapNative, meta_keymap_native,
void meta_keymap_native_set_keyboard_map (MetaKeymapNative *keymap, void meta_keymap_native_set_keyboard_map (MetaKeymapNative *keymap,
struct xkb_keymap *xkb_keymap); struct xkb_keymap *xkb_keymap);
struct xkb_keymap * meta_keymap_native_get_keyboard_map (MetaKeymapNative *keymap); struct xkb_keymap * meta_keymap_native_get_keyboard_map (MetaKeymapNative *keymap);
#endif /* META_KEYMAP_NATIVE_H */

View File

@ -333,10 +333,7 @@ meta_seat_native_notify_key (MetaSeatNative *seat,
if (update_keys && (changed_state & XKB_STATE_LEDS)) if (update_keys && (changed_state & XKB_STATE_LEDS))
{ {
ClutterBackend *backend; g_signal_emit_by_name (seat->keymap, "state-changed");
backend = clutter_get_default_backend ();
g_signal_emit_by_name (clutter_backend_get_keymap (backend), "state-changed");
meta_seat_native_sync_leds (seat); meta_seat_native_sync_leds (seat);
meta_input_device_native_a11y_maybe_notify_toggle_keys (META_INPUT_DEVICE_NATIVE (seat->core_keyboard)); meta_input_device_native_a11y_maybe_notify_toggle_keys (META_INPUT_DEVICE_NATIVE (seat->core_keyboard));
} }
@ -2329,6 +2326,7 @@ meta_seat_native_constructed (GObject *object)
ClutterStage *stage; ClutterStage *stage;
MetaEventSource *source; MetaEventSource *source;
struct udev *udev; struct udev *udev;
struct xkb_keymap *xkb_keymap;
device = meta_input_device_native_new_virtual ( device = meta_input_device_native_new_virtual (
seat, CLUTTER_POINTER_DEVICE, seat, CLUTTER_POINTER_DEVICE,
@ -2378,6 +2376,21 @@ meta_seat_native_constructed (GObject *object)
source = meta_event_source_new (seat); source = meta_event_source_new (seat);
seat->event_source = source; seat->event_source = source;
seat->keymap = g_object_new (META_TYPE_KEYMAP_NATIVE, NULL);
xkb_keymap = meta_keymap_native_get_keyboard_map (seat->keymap);
if (xkb_keymap)
{
seat->xkb = xkb_state_new (xkb_keymap);
seat->caps_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_CAPS);
seat->num_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_NUM);
seat->scroll_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_SCROLL);
}
if (G_OBJECT_CLASS (meta_seat_native_parent_class)->constructed) if (G_OBJECT_CLASS (meta_seat_native_parent_class)->constructed)
G_OBJECT_CLASS (meta_seat_native_parent_class)->constructed (object); G_OBJECT_CLASS (meta_seat_native_parent_class)->constructed (object);
} }
@ -2512,6 +2525,14 @@ meta_seat_native_bell_notify (ClutterSeat *seat)
meta_bell_notify (display, NULL); meta_bell_notify (display, NULL);
} }
static ClutterKeymap *
meta_seat_native_get_keymap (ClutterSeat *seat)
{
MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
return CLUTTER_KEYMAP (seat_native->keymap);
}
static void static void
meta_seat_native_class_init (MetaSeatNativeClass *klass) meta_seat_native_class_init (MetaSeatNativeClass *klass)
{ {
@ -2528,6 +2549,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
seat_class->get_keyboard = meta_seat_native_get_keyboard; seat_class->get_keyboard = meta_seat_native_get_keyboard;
seat_class->list_devices = meta_seat_native_list_devices; seat_class->list_devices = meta_seat_native_list_devices;
seat_class->bell_notify = meta_seat_native_bell_notify; seat_class->bell_notify = meta_seat_native_bell_notify;
seat_class->get_keymap = meta_seat_native_get_keymap;
props[PROP_SEAT_ID] = props[PROP_SEAT_ID] =
g_param_spec_string ("seat-id", g_param_spec_string ("seat-id",
@ -2571,9 +2593,6 @@ meta_seat_native_stage_removed_cb (ClutterStageManager *manager,
static void static void
meta_seat_native_init (MetaSeatNative *seat) meta_seat_native_init (MetaSeatNative *seat)
{ {
ClutterKeymap *keymap;
struct xkb_keymap *xkb_keymap;
seat->stage_manager = clutter_stage_manager_get_default (); seat->stage_manager = clutter_stage_manager_get_default ();
g_object_ref (seat->stage_manager); g_object_ref (seat->stage_manager);
@ -2600,21 +2619,6 @@ meta_seat_native_init (MetaSeatNative *seat)
seat->repeat = TRUE; seat->repeat = TRUE;
seat->repeat_delay = 250; /* ms */ seat->repeat_delay = 250; /* ms */
seat->repeat_interval = 33; /* ms */ seat->repeat_interval = 33; /* ms */
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
if (xkb_keymap)
{
seat->xkb = xkb_state_new (xkb_keymap);
seat->caps_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_CAPS);
seat->num_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_NUM);
seat->scroll_lock_led =
xkb_keymap_led_get_index (xkb_keymap, XKB_LED_NAME_SCROLL);
}
} }
ClutterInputDevice * ClutterInputDevice *
@ -2794,10 +2798,8 @@ meta_seat_native_update_xkb_state (MetaSeatNative *seat)
xkb_mod_mask_t latched_mods; xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods; xkb_mod_mask_t locked_mods;
struct xkb_keymap *xkb_keymap; struct xkb_keymap *xkb_keymap;
ClutterKeymap *keymap;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); xkb_keymap = meta_keymap_native_get_keyboard_map (seat->keymap);
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
latched_mods = xkb_state_serialize_mods (seat->xkb, latched_mods = xkb_state_serialize_mods (seat->xkb,
XKB_STATE_MODS_LATCHED); XKB_STATE_MODS_LATCHED);

View File

@ -26,6 +26,7 @@
#include <libinput.h> #include <libinput.h>
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-xkb-utils.h" #include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h" #include "clutter/clutter.h"
@ -114,6 +115,8 @@ struct _MetaSeatNative
GSList *event_filters; GSList *event_filters;
MetaKeymapNative *keymap;
/* keyboard repeat */ /* keyboard repeat */
gboolean repeat; gboolean repeat;
uint32_t repeat_delay; uint32_t repeat_delay;

View File

@ -282,13 +282,15 @@ pick_keycode_for_keyval_in_current_group (ClutterVirtualInputDevice *virtual_dev
{ {
MetaVirtualInputDeviceNative *virtual_evdev = MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device); META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
ClutterBackend *backend;
ClutterKeymap *keymap; ClutterKeymap *keymap;
struct xkb_keymap *xkb_keymap; struct xkb_keymap *xkb_keymap;
struct xkb_state *state; struct xkb_state *state;
guint keycode, layout; guint keycode, layout;
xkb_keycode_t min_keycode, max_keycode; xkb_keycode_t min_keycode, max_keycode;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); backend = clutter_get_default_backend ();
keymap = clutter_seat_get_keymap (clutter_backend_get_default_seat (backend));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap)); xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
state = virtual_evdev->seat->xkb; state = virtual_evdev->seat->xkb;

View File

@ -42,7 +42,6 @@
struct _MetaClutterBackendX11 struct _MetaClutterBackendX11
{ {
ClutterBackendX11 parent; ClutterBackendX11 parent;
MetaKeymapX11 *keymap;
MetaDeviceManagerX11 *device_manager; MetaDeviceManagerX11 *device_manager;
MetaSeatX11 *core_seat; MetaSeatX11 *core_seat;
}; };
@ -88,14 +87,6 @@ meta_clutter_backend_x11_get_device_manager (ClutterBackend *backend)
return CLUTTER_DEVICE_MANAGER (backend_x11->device_manager); return CLUTTER_DEVICE_MANAGER (backend_x11->device_manager);
} }
static ClutterKeymap *
meta_clutter_backend_x11_get_keymap (ClutterBackend *backend)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
return CLUTTER_KEYMAP (backend_x11->keymap);
}
static gboolean static gboolean
meta_clutter_backend_x11_translate_event (ClutterBackend *backend, meta_clutter_backend_x11_translate_event (ClutterBackend *backend,
gpointer native, gpointer native,
@ -110,9 +101,6 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *backend,
if (clutter_backend_class->translate_event (backend, native, event)) if (clutter_backend_class->translate_event (backend, native, event))
return TRUE; return TRUE;
if (meta_keymap_x11_handle_event (backend_x11->keymap, native))
return FALSE;
stage_x11 = META_STAGE_X11 (clutter_backend_get_stage_window (backend)); stage_x11 = META_STAGE_X11 (clutter_backend_get_stage_window (backend));
if (meta_stage_x11_translate_event (stage_x11, native, event)) if (meta_stage_x11_translate_event (stage_x11, native, event))
return TRUE; return TRUE;
@ -180,7 +168,6 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer; clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage; clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage;
clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager; clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager;
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->translate_event = meta_clutter_backend_x11_translate_event;
clutter_backend_class->init_events = meta_clutter_backend_x11_init_events; clutter_backend_class->init_events = meta_clutter_backend_x11_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_x11_get_default_seat; clutter_backend_class->get_default_seat = meta_clutter_backend_x11_get_default_seat;

View File

@ -516,22 +516,26 @@ meta_keymap_x11_get_caps_lock_state (ClutterKeymap *keymap)
} }
static PangoDirection static PangoDirection
meta_keymap_x11_get_direction (MetaKeymapX11 *keymap) 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), PANGO_DIRECTION_NEUTRAL);
if (keymap->use_xkb) keymap_x11 = META_KEYMAP_X11 (keymap);
if (keymap_x11->use_xkb)
{ {
if (!keymap->has_direction) if (!keymap_x11->has_direction)
{ {
XkbStateRec state_rec; XkbStateRec state_rec;
XkbGetState (clutter_x11_get_default_display (), XkbGetState (clutter_x11_get_default_display (),
XkbUseCoreKbd, &state_rec); XkbUseCoreKbd, &state_rec);
update_direction (keymap, XkbStateGroup (&state_rec)); update_direction (keymap_x11, XkbStateGroup (&state_rec));
} }
return keymap->current_direction; return keymap_x11->current_direction;
} }
else else
{ {

View File

@ -47,6 +47,7 @@ struct _MetaSeatX11
GList *devices; GList *devices;
GHashTable *devices_by_id; GHashTable *devices_by_id;
GHashTable *tools_by_serial; GHashTable *tools_by_serial;
MetaKeymapX11 *keymap;
int pointer_id; int pointer_id;
int keyboard_id; int keyboard_id;
@ -1246,6 +1247,20 @@ translate_coords (MetaStageX11 *stage_x11,
*y_out = CLAMP (event_y, 0, stage_height); *y_out = CLAMP (event_y, 0, stage_height);
} }
static void
on_keymap_state_change (MetaKeymapX11 *keymap_x11,
gpointer data)
{
ClutterSeat *seat = CLUTTER_SEAT (data);
ClutterKbdA11ySettings kbd_a11y_settings;
/* On keymaps state change, just reapply the current settings, it'll
* take care of enabling/disabling mousekeys based on NumLock state.
*/
clutter_seat_get_kbd_a11y_settings (seat, &kbd_a11y_settings);
meta_seat_x11_apply_kbd_a11y_settings (seat, &kbd_a11y_settings);
}
static void static void
meta_seat_x11_set_property (GObject *object, meta_seat_x11_set_property (GObject *object,
guint prop_id, guint prop_id,
@ -1371,6 +1386,14 @@ meta_seat_x11_constructed (GObject *object)
XSync (xdisplay, False); XSync (xdisplay, False);
seat_x11->keymap = g_object_new (META_TYPE_KEYMAP_X11,
"backend", backend,
NULL);
g_signal_connect (seat_x11->keymap,
"state-changed",
G_CALLBACK (on_keymap_state_change),
seat_x11);
if (G_OBJECT_CLASS (meta_seat_x11_parent_class)->constructed) if (G_OBJECT_CLASS (meta_seat_x11_parent_class)->constructed)
G_OBJECT_CLASS (meta_seat_x11_parent_class)->constructed (object); G_OBJECT_CLASS (meta_seat_x11_parent_class)->constructed (object);
} }
@ -1427,6 +1450,12 @@ meta_seat_x11_bell_notify (ClutterSeat *seat)
meta_bell_notify (display, NULL); meta_bell_notify (display, NULL);
} }
static ClutterKeymap *
meta_seat_x11_get_keymap (ClutterSeat *seat)
{
return CLUTTER_KEYMAP (META_SEAT_X11 (seat)->keymap);
}
static void static void
meta_seat_x11_class_init (MetaSeatX11Class *klass) meta_seat_x11_class_init (MetaSeatX11Class *klass)
{ {
@ -1442,6 +1471,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
seat_class->get_keyboard = meta_seat_x11_get_keyboard; seat_class->get_keyboard = meta_seat_x11_get_keyboard;
seat_class->list_devices = meta_seat_x11_list_devices; seat_class->list_devices = meta_seat_x11_list_devices;
seat_class->bell_notify = meta_seat_x11_bell_notify; seat_class->bell_notify = meta_seat_x11_bell_notify;
seat_class->get_keymap = meta_seat_x11_get_keymap;
props[PROP_OPCODE] = props[PROP_OPCODE] =
g_param_spec_int ("opcode", g_param_spec_int ("opcode",
@ -1523,6 +1553,9 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
XGenericEventCookie *cookie; XGenericEventCookie *cookie;
XIEvent *xi_event; XIEvent *xi_event;
if (meta_keymap_x11_handle_event (seat->keymap, xevent))
return FALSE;
cookie = &xevent->xcookie; cookie = &xevent->xcookie;
if (cookie->type != GenericEvent || if (cookie->type != GenericEvent ||
@ -1592,7 +1625,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
case XI_KeyRelease: case XI_KeyRelease:
{ {
XIDeviceEvent *xev = (XIDeviceEvent *) xi_event; XIDeviceEvent *xev = (XIDeviceEvent *) xi_event;
MetaKeymapX11 *keymap_x11 = META_KEYMAP_X11 (clutter_backend_get_keymap (backend)); MetaKeymapX11 *keymap_x11 = seat->keymap;
MetaEventX11 *event_x11; MetaEventX11 *event_x11;
char buffer[7] = { 0, }; char buffer[7] = { 0, };
gunichar n; gunichar n;

View File

@ -131,7 +131,8 @@ meta_virtual_input_device_x11_notify_keyval (ClutterVirtualInputDevice *virtual_
ClutterKeyState key_state) ClutterKeyState key_state)
{ {
ClutterBackend *backend = clutter_get_default_backend (); ClutterBackend *backend = clutter_get_default_backend ();
MetaKeymapX11 *keymap = META_KEYMAP_X11 (clutter_backend_get_keymap (backend)); ClutterSeat *seat = clutter_backend_get_default_seat (backend);
MetaKeymapX11 *keymap = META_KEYMAP_X11 (clutter_seat_get_keymap (seat));
uint32_t keycode, level; uint32_t keycode, level;
if (!meta_keymap_x11_keycode_for_keyval (keymap, keyval, &keycode, &level)) if (!meta_keymap_x11_keycode_for_keyval (keymap, keyval, &keycode, &level))

View File

@ -198,6 +198,7 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
ClutterKbdA11ySettings *kbd_a11y_settings) ClutterKbdA11ySettings *kbd_a11y_settings)
{ {
ClutterBackend *backend; ClutterBackend *backend;
ClutterSeat *seat;
Display *xdisplay = clutter_x11_get_default_display (); Display *xdisplay = clutter_x11_get_default_display ();
XkbDescRec *desc; XkbDescRec *desc;
gboolean enable_accessX; gboolean enable_accessX;
@ -207,6 +208,7 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
return; return;
backend = clutter_get_default_backend (); backend = clutter_get_default_backend ();
seat = clutter_backend_get_default_seat (backend);
/* general */ /* general */
enable_accessX = kbd_a11y_settings->controls & CLUTTER_A11Y_KEYBOARD_ENABLED; enable_accessX = kbd_a11y_settings->controls & CLUTTER_A11Y_KEYBOARD_ENABLED;
@ -245,7 +247,7 @@ meta_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *device_
} }
/* mouse keys */ /* mouse keys */
if (clutter_keymap_get_num_lock_state (clutter_backend_get_keymap (backend))) if (clutter_keymap_get_num_lock_state (clutter_seat_get_keymap (seat)))
{ {
/* Disable mousekeys when NumLock is ON */ /* Disable mousekeys when NumLock is ON */
desc->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | XkbMouseKeysAccelMask); desc->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | XkbMouseKeysAccelMask);

View File

@ -404,6 +404,7 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
xkb_layout_index_t layout_idx; xkb_layout_index_t layout_idx;
ClutterKeymap *keymap; ClutterKeymap *keymap;
ClutterSeat *seat;
/* Preserve latched/locked modifiers state */ /* Preserve latched/locked modifiers state */
if (xkb_info->state) if (xkb_info->state)
@ -417,7 +418,8 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
latched = locked = 0; latched = locked = 0;
} }
keymap = clutter_backend_get_keymap (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
keymap = clutter_seat_get_keymap (seat);
numlock = (1 << xkb_keymap_mod_get_index (xkb_info->keymap, "Mod2")); numlock = (1 << xkb_keymap_mod_get_index (xkb_info->keymap, "Mod2"));
if (clutter_keymap_get_num_lock_state (keymap)) if (clutter_keymap_get_num_lock_state (keymap))