[PATCH weston v2 3/3] build: Make libxkbcommon build-time optional in the compositor

Rob Bradford robert.bradford at intel.com
Fri Jun 21 10:19:45 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

---
 configure.ac     |  9 ++++++++-
 src/compositor.c |  6 +++++-
 src/input.c      | 20 +++++++++++++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index b625221..5e5e7bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ AC_CHECK_HEADERS([execinfo.h])
 
 AC_CHECK_FUNCS([mkostemp strchrnul])
 
-COMPOSITOR_MODULES="wayland-server >= 1.1.90 xkbcommon pixman-1"
+COMPOSITOR_MODULES="wayland-server >= 1.1.90 pixman-1"
 
 AC_ARG_ENABLE(egl, [  --disable-egl],,
               enable_egl=yes)
@@ -64,6 +64,13 @@ if test x$enable_egl = xyes; then
 	COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2"
 fi
 
+AC_ARG_ENABLE(xkbcommon, [  --disable-xkbcommon],,
+              enable_xkbcommon=yes)
+if test x$enable_xkbcommon = xyes; then
+	AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon support])
+	COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon"
+fi
+
 PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES])
 
 AC_ARG_ENABLE(setuid-install, [  --enable-setuid-install],,
diff --git a/src/compositor.c b/src/compositor.c
index c9ee67b..d96560b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2795,7 +2795,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);
@@ -2807,8 +2806,11 @@ 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);
+#ifdef ENABLE_XKBCOMMON
+	ec->use_xkbcommon = 1;
 	if (weston_compositor_xkb_init(ec, &xkb_names) < 0)
 		return -1;
+#endif
 
 	ec->ping_handler = NULL;
 
@@ -3314,7 +3316,9 @@ int main(int argc, char *argv[])
 	for (i = ARRAY_LENGTH(signals); i;)
 		wl_event_source_remove(signals[--i]);
 
+#ifdef ENABLE_XKBCOMMON
 	weston_compositor_xkb_destroy(ec);
+#endif
 
 	ec->destroy(ec);
 	wl_display_destroy(display);
diff --git a/src/input.c b/src/input.c
index 9eb980a..6140340 100644
--- a/src/input.c
+++ b/src/input.c
@@ -740,6 +740,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)
 {
@@ -829,6 +830,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,
@@ -1272,6 +1285,7 @@ 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)
@@ -1419,6 +1433,7 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
 
 	return 0;
 }
+#endif
 
 WL_EXPORT int
 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
@@ -1428,7 +1443,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);
@@ -1449,6 +1464,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) {
@@ -1533,11 +1549,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);
-- 
1.8.2.1



More information about the wayland-devel mailing list