build: Make libxkbcommon build-time optional in the compositor
v2: Incorporate review feedback from Daniel Stone - improved configure message about the purpose of this option and reorganisation of #ifdefs.
This commit is contained in:
committed by
Kristian Høgsberg
parent
01a9273bd2
commit
382ff46ffb
+1
-1
@@ -2829,7 +2829,6 @@ weston_compositor_init(struct weston_compositor *ec,
|
||||
weston_plane_init(&ec->primary_plane, 0, 0);
|
||||
weston_compositor_stack_plane(ec, &ec->primary_plane, NULL);
|
||||
|
||||
ec->use_xkbcommon = 1;
|
||||
s = weston_config_get_section(ec->config, "keyboard", NULL, NULL);
|
||||
weston_config_section_get_string(s, "keymap_rules",
|
||||
(char **) &xkb_names.rules, NULL);
|
||||
@@ -2841,6 +2840,7 @@ weston_compositor_init(struct weston_compositor *ec,
|
||||
(char **) &xkb_names.variant, NULL);
|
||||
weston_config_section_get_string(s, "keymap_options",
|
||||
(char **) &xkb_names.options, NULL);
|
||||
|
||||
if (weston_compositor_xkb_init(ec, &xkb_names) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
+32
-7
@@ -744,6 +744,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
|
||||
value);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_XKBCOMMON
|
||||
WL_EXPORT void
|
||||
notify_modifiers(struct weston_seat *seat, uint32_t serial)
|
||||
{
|
||||
@@ -833,6 +834,18 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key,
|
||||
|
||||
notify_modifiers(seat, serial);
|
||||
}
|
||||
#else
|
||||
WL_EXPORT void
|
||||
notify_modifiers(struct weston_seat *seat, uint32_t serial)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key,
|
||||
enum wl_keyboard_key_state state)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
WL_EXPORT void
|
||||
notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
|
||||
@@ -1276,16 +1289,12 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id)
|
||||
wl_seat_send_name(resource, seat->seat_name);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_XKBCOMMON
|
||||
int
|
||||
weston_compositor_xkb_init(struct weston_compositor *ec,
|
||||
struct xkb_rule_names *names)
|
||||
{
|
||||
/*
|
||||
* If we're operating in raw keyboard mode, libxkbcommon isn't used and
|
||||
* shouldn't be initialized.
|
||||
*/
|
||||
if (!ec->use_xkbcommon)
|
||||
return 0;
|
||||
ec->use_xkbcommon = 1;
|
||||
|
||||
if (ec->xkb_context == NULL) {
|
||||
ec->xkb_context = xkb_context_new(0);
|
||||
@@ -1423,6 +1432,19 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int
|
||||
weston_compositor_xkb_init(struct weston_compositor *ec,
|
||||
struct xkb_rule_names *names)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
weston_compositor_xkb_destroy(struct weston_compositor *ec)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
WL_EXPORT int
|
||||
weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
|
||||
@@ -1432,7 +1454,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
|
||||
if (seat->keyboard)
|
||||
return 0;
|
||||
|
||||
|
||||
#ifdef ENABLE_XKBCOMMON
|
||||
if (seat->compositor->use_xkbcommon) {
|
||||
if (keymap != NULL) {
|
||||
seat->xkb_info.keymap = xkb_map_ref(keymap);
|
||||
@@ -1453,6 +1475,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
|
||||
|
||||
seat->xkb_state.leds = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
keyboard = weston_keyboard_create();
|
||||
if (keyboard == NULL) {
|
||||
@@ -1537,11 +1560,13 @@ weston_seat_release(struct weston_seat *seat)
|
||||
wl_list_remove(&seat->link);
|
||||
/* The global object is destroyed at wl_display_destroy() time. */
|
||||
|
||||
#ifdef ENABLE_XKBCOMMON
|
||||
if (seat->compositor->use_xkbcommon) {
|
||||
if (seat->xkb_state.state != NULL)
|
||||
xkb_state_unref(seat->xkb_state.state);
|
||||
xkb_info_destroy(&seat->xkb_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (seat->pointer)
|
||||
weston_pointer_destroy(seat->pointer);
|
||||
|
||||
Reference in New Issue
Block a user