wayland-keyboard: Use the backend's keymap

Instead of getting it from xwayland, let's just keep a reference to
the backend's keymap.

https://bugzilla.gnome.org/show_bug.cgi?id=734301
This commit is contained in:
Rui Matos 2014-08-04 16:50:04 +02:00
parent 101b215d6b
commit 513628e4ad
3 changed files with 8 additions and 113 deletions

View File

@ -56,8 +56,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <clutter/evdev/clutter-evdev.h>
#include "backends/meta-backend.h"
#include "meta-wayland-private.h"
static void meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard);
@ -110,22 +110,12 @@ create_anonymous_file (off_t size,
}
static void
inform_clients_of_new_keymap (MetaWaylandKeyboard *keyboard,
int flags)
inform_clients_of_new_keymap (MetaWaylandKeyboard *keyboard)
{
MetaWaylandCompositor *compositor;
struct wl_client *xclient;
struct wl_resource *keyboard_resource;
compositor = meta_wayland_compositor_get_default ();
xclient = compositor->xwayland_manager.client;
wl_resource_for_each (keyboard_resource, &keyboard->resource_list)
{
if ((flags & META_WAYLAND_KEYBOARD_SKIP_XCLIENTS) &&
wl_resource_get_client (keyboard_resource) == xclient)
continue;
wl_keyboard_send_keymap (keyboard_resource,
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
keyboard->xkb_info.keymap_fd,
@ -142,8 +132,7 @@ inform_clients_of_new_keymap (MetaWaylandKeyboard *keyboard,
static void
meta_wayland_keyboard_take_keymap (MetaWaylandKeyboard *keyboard,
struct xkb_keymap *keymap,
int flags)
struct xkb_keymap *keymap)
{
MetaWaylandXkbInfo *xkb_info = &keyboard->xkb_info;
GError *error = NULL;
@ -157,7 +146,7 @@ meta_wayland_keyboard_take_keymap (MetaWaylandKeyboard *keyboard,
}
xkb_keymap_unref (xkb_info->keymap);
xkb_info->keymap = keymap;
xkb_info->keymap = xkb_keymap_ref (keymap);
meta_wayland_keyboard_update_xkb_state (keyboard);
@ -198,19 +187,7 @@ meta_wayland_keyboard_take_keymap (MetaWaylandKeyboard *keyboard,
strcpy (xkb_info->keymap_area, keymap_str);
free (keymap_str);
#if defined(CLUTTER_WINDOWING_EGL)
/* XXX -- the evdev backend can be used regardless of the
* windowing backend. To do this properly we need a Clutter
* API to check the input backend. */
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL))
{
ClutterDeviceManager *manager;
manager = clutter_device_manager_get_default ();
clutter_evdev_set_keyboard_map (manager, xkb_info->keymap);
}
#endif
inform_clients_of_new_keymap (keyboard, flags);
inform_clients_of_new_keymap (keyboard);
notify_modifiers (keyboard,
wl_display_next_serial (keyboard->display),
@ -370,20 +347,14 @@ meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
wl_array_init (&keyboard->pressed_keys);
keyboard->xkb_context = xkb_context_new (0 /* flags */);
keyboard->xkb_info.keymap_fd = -1;
/* Compute a default until gnome-settings-daemon starts and sets
the appropriate values
*/
meta_wayland_keyboard_set_keymap_names (keyboard,
"evdev",
"pc105",
"us", "", "", 0);
keyboard->settings = g_settings_new ("org.gnome.settings-daemon.peripherals.keyboard");
g_signal_connect (keyboard->settings, "changed",
G_CALLBACK (settings_changed), keyboard);
meta_wayland_keyboard_take_keymap (keyboard,
meta_backend_get_keymap (meta_get_backend ()));
}
static void
@ -403,7 +374,6 @@ meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard)
{
meta_wayland_keyboard_set_focus (keyboard, NULL);
meta_wayland_xkb_info_destroy (&keyboard->xkb_info);
xkb_context_unref (keyboard->xkb_context);
/* XXX: What about keyboard->resource_list? */
wl_array_release (&keyboard->pressed_keys);
@ -593,30 +563,6 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
}
}
void
meta_wayland_keyboard_set_keymap_names (MetaWaylandKeyboard *keyboard,
const char *rules,
const char *model,
const char *layout,
const char *variant,
const char *options,
int flags)
{
struct xkb_rule_names xkb_names;
xkb_names.rules = rules;
xkb_names.model = model;
xkb_names.layout = layout;
xkb_names.variant = variant;
xkb_names.options = options;
meta_wayland_keyboard_take_keymap (keyboard,
xkb_keymap_new_from_names (keyboard->xkb_context,
&xkb_names,
0 /* flags */),
flags);
}
struct wl_client *
meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard)
{

View File

@ -71,7 +71,6 @@ struct _MetaWaylandKeyboard
struct wl_array pressed_keys;
struct xkb_context *xkb_context;
MetaWaylandXkbInfo xkb_info;
GSettings *settings;
@ -91,18 +90,6 @@ gboolean meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
void meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
MetaWaylandSurface *surface);
typedef enum {
META_WAYLAND_KEYBOARD_SKIP_XCLIENTS = 1,
} MetaWaylandKeyboardSetKeymapFlags;
void meta_wayland_keyboard_set_keymap_names (MetaWaylandKeyboard *keyboard,
const char *rules,
const char *model,
const char *layout,
const char *variant,
const char *options,
int flags);
struct wl_client * meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard);
void meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,

View File

@ -916,40 +916,6 @@ handle_input_xevent (MetaDisplay *display,
return TRUE;
}
static void
reload_xkb_rules (MetaScreen *screen)
{
MetaWaylandCompositor *compositor;
char **names;
int n_names;
gboolean ok;
const char *rules, *model, *layout, *variant, *options;
compositor = meta_wayland_compositor_get_default ();
ok = meta_prop_get_latin1_list (screen->display, screen->xroot,
screen->display->atom__XKB_RULES_NAMES,
&names, &n_names);
if (!ok)
return;
if (n_names != 5)
goto out;
rules = names[0];
model = names[1];
layout = names[2];
variant = names[3];
options = names[4];
meta_wayland_keyboard_set_keymap_names (&compositor->seat->keyboard,
rules, model, layout, variant, options,
META_WAYLAND_KEYBOARD_SKIP_XCLIENTS);
out:
g_strfreev (names);
}
static void
process_request_frame_extents (MetaDisplay *display,
XEvent *event)
@ -1459,10 +1425,6 @@ handle_other_xevent (MetaDisplay *display,
else if (event->xproperty.atom ==
display->atom__NET_DESKTOP_NAMES)
meta_screen_update_workspace_names (display->screen);
else if (meta_is_wayland_compositor () &&
event->xproperty.atom ==
display->atom__XKB_RULES_NAMES)
reload_xkb_rules (display->screen);
/* we just use this property as a sentinel to avoid
* certain race conditions. See the comment for the