Split XKB keymap compilation out into separate function
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
74419a2237
commit
9a9ee2c779
+33
-20
@@ -2242,6 +2242,28 @@ static int weston_compositor_xkb_init(struct weston_compositor *ec,
|
|||||||
if (!ec->xkb_info.names.layout)
|
if (!ec->xkb_info.names.layout)
|
||||||
ec->xkb_info.names.layout = strdup("us");
|
ec->xkb_info.names.layout = strdup("us");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void weston_compositor_xkb_destroy(struct weston_compositor *ec)
|
||||||
|
{
|
||||||
|
free((char *) ec->xkb_info.names.rules);
|
||||||
|
free((char *) ec->xkb_info.names.model);
|
||||||
|
free((char *) ec->xkb_info.names.layout);
|
||||||
|
free((char *) ec->xkb_info.names.variant);
|
||||||
|
free((char *) ec->xkb_info.names.options);
|
||||||
|
|
||||||
|
if (ec->xkb_info.keymap)
|
||||||
|
xkb_map_unref(ec->xkb_info.keymap);
|
||||||
|
xkb_context_unref(ec->xkb_info.context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
weston_compositor_build_global_keymap(struct weston_compositor *ec)
|
||||||
|
{
|
||||||
|
if (ec->xkb_info.keymap != NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_info.context,
|
ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_info.context,
|
||||||
&ec->xkb_info.names, 0);
|
&ec->xkb_info.names, 0);
|
||||||
if (ec->xkb_info.keymap == NULL) {
|
if (ec->xkb_info.keymap == NULL) {
|
||||||
@@ -2266,16 +2288,19 @@ static int weston_compositor_xkb_init(struct weston_compositor *ec,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void weston_compositor_xkb_destroy(struct weston_compositor *ec)
|
WL_EXPORT void
|
||||||
|
weston_seat_init_keyboard(struct weston_seat *seat)
|
||||||
{
|
{
|
||||||
xkb_map_unref(ec->xkb_info.keymap);
|
if (seat->has_keyboard)
|
||||||
xkb_context_unref(ec->xkb_info.context);
|
return;
|
||||||
|
|
||||||
free((char *) ec->xkb_info.names.rules);
|
if (weston_compositor_build_global_keymap(seat->compositor) == -1)
|
||||||
free((char *) ec->xkb_info.names.model);
|
return;
|
||||||
free((char *) ec->xkb_info.names.layout);
|
|
||||||
free((char *) ec->xkb_info.names.variant);
|
wl_keyboard_init(&seat->keyboard);
|
||||||
free((char *) ec->xkb_info.names.options);
|
wl_seat_set_keyboard(&seat->seat, &seat->keyboard);
|
||||||
|
|
||||||
|
seat->has_keyboard = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
@@ -2290,18 +2315,6 @@ weston_seat_init_pointer(struct weston_seat *seat)
|
|||||||
seat->has_pointer = 1;
|
seat->has_pointer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
|
||||||
weston_seat_init_keyboard(struct weston_seat *seat)
|
|
||||||
{
|
|
||||||
if (seat->has_keyboard)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_keyboard_init(&seat->keyboard);
|
|
||||||
wl_seat_set_keyboard(&seat->seat, &seat->keyboard);
|
|
||||||
|
|
||||||
seat->has_keyboard = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_seat_init_touch(struct weston_seat *seat)
|
weston_seat_init_touch(struct weston_seat *seat)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user