mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
backend: Add a keymap-changed signal
This commit is contained in:
parent
bda2d6d1ac
commit
39f65f9f86
@ -167,6 +167,13 @@ meta_backend_class_init (MetaBackendClass *klass)
|
||||
klass->ungrab_device = meta_backend_real_ungrab_device;
|
||||
klass->update_screen_size = meta_backend_real_update_screen_size;
|
||||
klass->select_stage_events = meta_backend_real_select_stage_events;
|
||||
|
||||
g_signal_new ("keymap-changed",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -211,7 +211,7 @@ meta_backend_native_set_keymap (MetaBackend *backend,
|
||||
|
||||
clutter_evdev_set_keyboard_map (manager, keymap);
|
||||
|
||||
/* FIXME: emit keymap changed signal */
|
||||
g_signal_emit_by_name (backend, "keymap-changed", 0);
|
||||
|
||||
xkb_keymap_unref (keymap);
|
||||
}
|
||||
|
@ -158,6 +158,21 @@ maybe_spoof_event_as_stage_event (MetaBackendX11 *x11,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keymap_changed (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
||||
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
|
||||
|
||||
if (priv->keymap)
|
||||
{
|
||||
xkb_keymap_unref (priv->keymap);
|
||||
priv->keymap = NULL;
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (backend, "keymap-changed", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_host_xevent (MetaBackend *backend,
|
||||
XEvent *event)
|
||||
@ -182,6 +197,23 @@ handle_host_xevent (MetaBackend *backend,
|
||||
if (event->type == (priv->xsync_event_base + XSyncAlarmNotify))
|
||||
handle_alarm_notify (backend, event);
|
||||
|
||||
if (event->type == priv->xkb_event_base)
|
||||
{
|
||||
XkbAnyEvent *xkb_ev = (XkbAnyEvent *) event;
|
||||
|
||||
if (xkb_ev->device == META_VIRTUAL_CORE_KEYBOARD_ID)
|
||||
{
|
||||
switch (xkb_ev->xkb_type)
|
||||
{
|
||||
case XkbNewKeyboardNotify:
|
||||
case XkbMapNotify:
|
||||
keymap_changed (backend);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
MetaMonitorManager *manager = meta_backend_get_monitor_manager (backend);
|
||||
if (META_IS_MONITOR_MANAGER_XRANDR (manager) &&
|
||||
|
@ -126,8 +126,6 @@ void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
gboolean meta_keybindings_process_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
const ClutterEvent *event);
|
||||
void meta_display_process_mapping_event (MetaDisplay *display,
|
||||
XEvent *event);
|
||||
|
||||
ClutterModifierType meta_display_get_window_grab_modifiers (MetaDisplay *display);
|
||||
|
||||
|
@ -937,10 +937,11 @@ meta_display_get_keybinding_action (MetaDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_process_mapping_event (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
static void
|
||||
on_keymap_changed (MetaBackend *backend,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaDisplay *display = user_data;
|
||||
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
||||
|
||||
ungrab_key_bindings (display);
|
||||
@ -4185,7 +4186,10 @@ meta_display_init_keys (MetaDisplay *display)
|
||||
|
||||
meta_prefs_add_listener (prefs_changed_callback, display);
|
||||
|
||||
XkbSelectEvents (keys->xdisplay, XkbUseCoreKbd,
|
||||
XkbNewKeyboardNotifyMask | XkbMapNotifyMask,
|
||||
XkbNewKeyboardNotifyMask | XkbMapNotifyMask);
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
|
||||
g_signal_connect (backend, "keymap-changed",
|
||||
G_CALLBACK (on_keymap_changed), display);
|
||||
}
|
||||
}
|
||||
|
@ -1579,7 +1579,6 @@ handle_other_xevent (MetaDisplay *display,
|
||||
/* Let XLib know that there is a new keyboard mapping.
|
||||
*/
|
||||
XRefreshKeyboardMapping (&event->xmapping);
|
||||
meta_display_process_mapping_event (display, event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1598,10 +1597,7 @@ handle_other_xevent (MetaDisplay *display,
|
||||
meta_bell_notify (display, xkb_ev);
|
||||
}
|
||||
break;
|
||||
case XkbNewKeyboardNotify:
|
||||
case XkbMapNotify:
|
||||
if (xkb_ev->device == META_VIRTUAL_CORE_KEYBOARD_ID)
|
||||
meta_display_process_mapping_event (display, event);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user