[PATCH weston 1/2] Replace deprecated xkbcommon symbols with current names

Ran Benita ran234 at gmail.com
Tue Aug 19 13:59:51 PDT 2014


These symbols (xkb_map_* and others) were replaced in xkbcommon with more
consistent names. See the header xkbcommon/xkbcommon-compat.h for how
the old names map to the new.

The new names have been available since the first stable xkbcommon
release (0.2.0).

Signed-off-by: Ran Benita <ran234 at gmail.com>
---
 clients/weston-simple-im.c | 22 ++++++++--------
 clients/window.c           | 24 ++++++++---------
 src/compositor-wayland.c   | 10 +++----
 src/compositor-x11.c       |  4 +--
 src/input.c                | 66 ++++++++++++++++++++++++----------------------
 src/screen-share.c         | 10 +++----
 6 files changed, 70 insertions(+), 66 deletions(-)

diff --git a/clients/weston-simple-im.c b/clients/weston-simple-im.c
index ded6a04..787782f 100644
--- a/clients/weston-simple-im.c
+++ b/clients/weston-simple-im.c
@@ -187,10 +187,10 @@ input_method_keyboard_keymap(void *data,
 	}
 
 	keyboard->keymap =
-		xkb_map_new_from_string(keyboard->xkb_context,
-					map_str,
-					XKB_KEYMAP_FORMAT_TEXT_V1,
-					0);
+		xkb_keymap_new_from_string(keyboard->xkb_context,
+					   map_str,
+					   XKB_KEYMAP_FORMAT_TEXT_V1,
+					   0);
 
 	munmap(map_str, size);
 	close(fd);
@@ -203,16 +203,16 @@ input_method_keyboard_keymap(void *data,
 	keyboard->state = xkb_state_new(keyboard->keymap);
 	if (!keyboard->state) {
 		fprintf(stderr, "failed to create XKB state\n");
-		xkb_map_unref(keyboard->keymap);
+		xkb_keymap_unref(keyboard->keymap);
 		return;
 	}
 
 	keyboard->control_mask =
-		1 << xkb_map_mod_get_index(keyboard->keymap, "Control");
+		1 << xkb_keymap_mod_get_index(keyboard->keymap, "Control");
 	keyboard->alt_mask =
-		1 << xkb_map_mod_get_index(keyboard->keymap, "Mod1");
+		1 << xkb_keymap_mod_get_index(keyboard->keymap, "Mod1");
 	keyboard->shift_mask =
-		1 << xkb_map_mod_get_index(keyboard->keymap, "Shift");
+		1 << xkb_keymap_mod_get_index(keyboard->keymap, "Shift");
 }
 
 static void
@@ -234,7 +234,7 @@ input_method_keyboard_key(void *data,
 		return;
 
 	code = key + 8;
-	num_syms = xkb_key_get_syms(keyboard->state, code, &syms);
+	num_syms = xkb_state_key_get_syms(keyboard->state, code, &syms);
 
 	sym = XKB_KEY_NoSymbol;
 	if (num_syms == 1)
@@ -261,8 +261,8 @@ input_method_keyboard_modifiers(void *data,
 	xkb_state_update_mask(keyboard->state, mods_depressed,
 			      mods_latched, mods_locked, 0, 0, group);
 	mask = xkb_state_serialize_mods(keyboard->state,
-					XKB_STATE_DEPRESSED |
-					XKB_STATE_LATCHED);
+					XKB_STATE_MODS_DEPRESSED |
+					XKB_STATE_MODS_LATCHED);
 
 	keyboard->modifiers = 0;
 	if (mask & keyboard->control_mask)
diff --git a/clients/window.c b/clients/window.c
index a8bc260..90f45d3 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2749,10 +2749,10 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
 		return;
 	}
 
-	keymap = xkb_map_new_from_string(input->display->xkb_context,
-					 map_str,
-					 XKB_KEYMAP_FORMAT_TEXT_V1,
-					 0);
+	keymap = xkb_keymap_new_from_string(input->display->xkb_context,
+					    map_str,
+					    XKB_KEYMAP_FORMAT_TEXT_V1,
+					    0);
 	munmap(map_str, size);
 	close(fd);
 
@@ -2764,7 +2764,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
 	state = xkb_state_new(keymap);
 	if (!state) {
 		fprintf(stderr, "failed to create XKB state\n");
-		xkb_map_unref(keymap);
+		xkb_keymap_unref(keymap);
 		return;
 	}
 
@@ -2774,11 +2774,11 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
 	input->xkb.state = state;
 
 	input->xkb.control_mask =
-		1 << xkb_map_mod_get_index(input->xkb.keymap, "Control");
+		1 << xkb_keymap_mod_get_index(input->xkb.keymap, "Control");
 	input->xkb.alt_mask =
-		1 << xkb_map_mod_get_index(input->xkb.keymap, "Mod1");
+		1 << xkb_keymap_mod_get_index(input->xkb.keymap, "Mod1");
 	input->xkb.shift_mask =
-		1 << xkb_map_mod_get_index(input->xkb.keymap, "Shift");
+		1 << xkb_keymap_mod_get_index(input->xkb.keymap, "Shift");
 }
 
 static void
@@ -2834,7 +2834,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
 	if (input->grab && input->grab_button == 0)
 		return;
 
-	num_syms = xkb_key_get_syms(input->xkb.state, code, &syms);
+	num_syms = xkb_state_key_get_syms(input->xkb.state, code, &syms);
 
 	sym = XKB_KEY_NoSymbol;
 	if (num_syms == 1)
@@ -2893,8 +2893,8 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
 	xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
 			      mods_locked, 0, 0, group);
 	mask = xkb_state_serialize_mods(input->xkb.state,
-					XKB_STATE_DEPRESSED |
-					XKB_STATE_LATCHED);
+					XKB_STATE_MODS_DEPRESSED |
+					XKB_STATE_MODS_LATCHED);
 	input->modifiers = 0;
 	if (mask & input->xkb.control_mask)
 		input->modifiers |= MOD_CONTROL_MASK;
@@ -4993,7 +4993,7 @@ static void
 fini_xkb(struct input *input)
 {
 	xkb_state_unref(input->xkb.state);
-	xkb_map_unref(input->xkb.keymap);
+	xkb_keymap_unref(input->xkb.keymap);
 }
 
 #define MIN(a,b) ((a) < (b) ? a : b)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index d5ea925..57e850f 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1436,10 +1436,10 @@ input_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format,
 			goto error;
 		}
 
-		keymap = xkb_map_new_from_string(input->compositor->base.xkb_context,
-						 map_str,
-						 XKB_KEYMAP_FORMAT_TEXT_V1,
-						 0);
+		keymap = xkb_keymap_new_from_string(input->compositor->base.xkb_context,
+						    map_str,
+						    XKB_KEYMAP_FORMAT_TEXT_V1,
+						    0);
 		munmap(map_str, size);
 
 		if (!keymap) {
@@ -1465,7 +1465,7 @@ input_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format,
 		weston_seat_init_keyboard(&input->base, keymap);
 
 	if (keymap)
-		xkb_map_unref(keymap);
+		xkb_keymap_unref(keymap);
 
 	return;
 
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 56b3228..984d799 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -154,7 +154,7 @@ x11_compositor_get_keymap(struct x11_compositor *c)
 	copy_prop_value(options);
 #undef copy_prop_value
 
-	ret = xkb_map_new_from_names(c->base.xkb_context, &names, 0);
+	ret = xkb_keymap_new_from_names(c->base.xkb_context, &names, 0);
 
 	free(reply);
 	return ret;
@@ -323,7 +323,7 @@ x11_input_create(struct x11_compositor *c, int no_input)
 	if (weston_seat_init_keyboard(&c->core_seat, keymap) < 0)
 		return -1;
 	if (keymap)
-		xkb_map_unref(keymap);
+		xkb_keymap_unref(keymap);
 
 	x11_compositor_setup_xkb(c);
 
diff --git a/src/input.c b/src/input.c
index 1ab55ce..2130789 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1078,13 +1078,13 @@ notify_modifiers(struct weston_seat *seat, uint32_t serial)
 	/* Serialize and update our internal state, checking to see if it's
 	 * different to the previous state. */
 	mods_depressed = xkb_state_serialize_mods(keyboard->xkb_state.state,
-						  XKB_STATE_DEPRESSED);
+						  XKB_STATE_MODS_DEPRESSED);
 	mods_latched = xkb_state_serialize_mods(keyboard->xkb_state.state,
-						XKB_STATE_LATCHED);
+						XKB_STATE_MODS_LATCHED);
 	mods_locked = xkb_state_serialize_mods(keyboard->xkb_state.state,
-					       XKB_STATE_LOCKED);
-	group = xkb_state_serialize_group(keyboard->xkb_state.state,
-					  XKB_STATE_EFFECTIVE);
+					       XKB_STATE_MODS_LOCKED);
+	group = xkb_state_serialize_layout(keyboard->xkb_state.state,
+					   XKB_STATE_LAYOUT_EFFECTIVE);
 
 	if (mods_depressed != seat->keyboard->modifiers.mods_depressed ||
 	    mods_latched != seat->keyboard->modifiers.mods_latched ||
@@ -1870,7 +1870,7 @@ weston_xkb_info_destroy(struct weston_xkb_info *xkb_info)
 		return;
 
 	if (xkb_info->keymap)
-		xkb_map_unref(xkb_info->keymap);
+		xkb_keymap_unref(xkb_info->keymap);
 
 	if (xkb_info->keymap_area)
 		munmap(xkb_info->keymap_area, xkb_info->keymap_size);
@@ -1907,33 +1907,37 @@ weston_xkb_info_create(struct xkb_keymap *keymap)
 	if (xkb_info == NULL)
 		return NULL;
 
-	xkb_info->keymap = xkb_map_ref(keymap);
+	xkb_info->keymap = xkb_keymap_ref(keymap);
 	xkb_info->ref_count = 1;
 
 	char *keymap_str;
 
-	xkb_info->shift_mod = xkb_map_mod_get_index(xkb_info->keymap,
-						    XKB_MOD_NAME_SHIFT);
-	xkb_info->caps_mod = xkb_map_mod_get_index(xkb_info->keymap,
-						   XKB_MOD_NAME_CAPS);
-	xkb_info->ctrl_mod = xkb_map_mod_get_index(xkb_info->keymap,
-						   XKB_MOD_NAME_CTRL);
-	xkb_info->alt_mod = xkb_map_mod_get_index(xkb_info->keymap,
-						  XKB_MOD_NAME_ALT);
-	xkb_info->mod2_mod = xkb_map_mod_get_index(xkb_info->keymap, "Mod2");
-	xkb_info->mod3_mod = xkb_map_mod_get_index(xkb_info->keymap, "Mod3");
-	xkb_info->super_mod = xkb_map_mod_get_index(xkb_info->keymap,
-						    XKB_MOD_NAME_LOGO);
-	xkb_info->mod5_mod = xkb_map_mod_get_index(xkb_info->keymap, "Mod5");
+	xkb_info->shift_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						       XKB_MOD_NAME_SHIFT);
+	xkb_info->caps_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						      XKB_MOD_NAME_CAPS);
+	xkb_info->ctrl_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						      XKB_MOD_NAME_CTRL);
+	xkb_info->alt_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						     XKB_MOD_NAME_ALT);
+	xkb_info->mod2_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						      "Mod2");
+	xkb_info->mod3_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						      "Mod3");
+	xkb_info->super_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						       XKB_MOD_NAME_LOGO);
+	xkb_info->mod5_mod = xkb_keymap_mod_get_index(xkb_info->keymap,
+						      "Mod5");
 
-	xkb_info->num_led = xkb_map_led_get_index(xkb_info->keymap,
-						  XKB_LED_NAME_NUM);
-	xkb_info->caps_led = xkb_map_led_get_index(xkb_info->keymap,
-						   XKB_LED_NAME_CAPS);
-	xkb_info->scroll_led = xkb_map_led_get_index(xkb_info->keymap,
-						     XKB_LED_NAME_SCROLL);
+	xkb_info->num_led = xkb_keymap_led_get_index(xkb_info->keymap,
+						     XKB_LED_NAME_NUM);
+	xkb_info->caps_led = xkb_keymap_led_get_index(xkb_info->keymap,
+						      XKB_LED_NAME_CAPS);
+	xkb_info->scroll_led = xkb_keymap_led_get_index(xkb_info->keymap,
+							XKB_LED_NAME_SCROLL);
 
-	keymap_str = xkb_map_get_as_string(xkb_info->keymap);
+	keymap_str = xkb_keymap_get_as_string(xkb_info->keymap,
+					      XKB_KEYMAP_FORMAT_TEXT_V1);
 	if (keymap_str == NULL) {
 		weston_log("failed to get string version of keymap\n");
 		goto err_keymap;
@@ -1965,7 +1969,7 @@ err_dev_zero:
 err_keymap_str:
 	free(keymap_str);
 err_keymap:
-	xkb_map_unref(xkb_info->keymap);
+	xkb_keymap_unref(xkb_info->keymap);
 	free(xkb_info);
 	return NULL;
 }
@@ -1978,9 +1982,9 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
 	if (ec->xkb_info != NULL)
 		return 0;
 
-	keymap = xkb_map_new_from_names(ec->xkb_context,
-					&ec->xkb_names,
-					0);
+	keymap = xkb_keymap_new_from_names(ec->xkb_context,
+					   &ec->xkb_names,
+					   0);
 	if (keymap == NULL) {
 		weston_log("failed to compile global XKB keymap\n");
 		weston_log("  tried rules %s, model %s, layout %s, variant %s, "
diff --git a/src/screen-share.c b/src/screen-share.c
index f9dcba1..9e81ef9 100644
--- a/src/screen-share.c
+++ b/src/screen-share.c
@@ -186,10 +186,10 @@ ss_seat_handle_keymap(void *data, struct wl_keyboard *keyboard,
 			goto error;
 		}
 
-		keymap = xkb_map_new_from_string(seat->base.compositor->xkb_context,
-						 map_str,
-						 XKB_KEYMAP_FORMAT_TEXT_V1,
-						 0);
+		keymap = xkb_keymap_new_from_string(seat->base.compositor->xkb_context,
+						    map_str,
+						    XKB_KEYMAP_FORMAT_TEXT_V1,
+						    0);
 		munmap(map_str, size);
 
 		if (!keymap) {
@@ -215,7 +215,7 @@ ss_seat_handle_keymap(void *data, struct wl_keyboard *keyboard,
 		weston_seat_init_keyboard(&seat->base, keymap);
 
 	if (keymap)
-		xkb_map_unref(keymap);
+		xkb_keymap_unref(keymap);
 
 	return;
 
-- 
2.0.4



More information about the wayland-devel mailing list