Commit 973b8fd47e885f1c80c715b317fa896f8d31a7a4

Ran Benita 2014-02-08T16:40:20

api: deprecate XKB_MAP_COMPILE_PLACEHOLDER, and use KEYMAP instead of MAP The PLACEHOLDER was not meant to be used, but c++ doesn't like passing 0 to enums, so it was used. For this reason we add all the NO_FLAGS items, so the PLACEHOLDER shouldn't be used anymore. Second, XKB_MAP is the prefix we used ages ago, KEYMAP is the expected prefix here. So deprecate that as well. The old names may still be used through the xkbcommon-compat.h header, which is included by default (no need to include directly). Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/keymap.c b/src/keymap.c
index 0830cc1..abf1387 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -132,7 +132,7 @@ xkb_keymap_new_from_names(struct xkb_context *ctx,
         return NULL;
     }
 
-    if (flags & ~(XKB_MAP_COMPILE_PLACEHOLDER)) {
+    if (flags & ~(XKB_KEYMAP_COMPILE_NO_FLAGS)) {
         log_err_func(ctx, "unrecognized flags: %#x\n", flags);
         return NULL;
     }
@@ -193,7 +193,7 @@ xkb_keymap_new_from_buffer(struct xkb_context *ctx,
         return NULL;
     }
 
-    if (flags & ~(XKB_MAP_COMPILE_PLACEHOLDER)) {
+    if (flags & ~(XKB_KEYMAP_COMPILE_NO_FLAGS)) {
         log_err_func(ctx, "unrecognized flags: %#x\n", flags);
         return NULL;
     }
@@ -230,7 +230,7 @@ xkb_keymap_new_from_file(struct xkb_context *ctx,
         return NULL;
     }
 
-    if (flags & ~(XKB_MAP_COMPILE_PLACEHOLDER)) {
+    if (flags & ~(XKB_KEYMAP_COMPILE_NO_FLAGS)) {
         log_err_func(ctx, "unrecognized flags: %#x\n", flags);
         return NULL;
     }
diff --git a/src/x11/keymap.c b/src/x11/keymap.c
index fd05fab..aa91033 100644
--- a/src/x11/keymap.c
+++ b/src/x11/keymap.c
@@ -1125,7 +1125,7 @@ xkb_x11_keymap_new_from_device(struct xkb_context *ctx,
     struct xkb_keymap *keymap;
     const enum xkb_keymap_format format = XKB_KEYMAP_FORMAT_TEXT_V1;
 
-    if (flags & ~(XKB_MAP_COMPILE_PLACEHOLDER)) {
+    if (flags & ~(XKB_KEYMAP_COMPILE_NO_FLAGS)) {
         log_err_func(ctx, "unrecognized flags: %#x\n", flags);
         return NULL;
     }
diff --git a/test/x11.c b/test/x11.c
index f16dded..232e136 100644
--- a/test/x11.c
+++ b/test/x11.c
@@ -56,7 +56,7 @@ main(void)
     assert(device_id != -1);
 
     keymap = xkb_x11_keymap_new_from_device(ctx, conn, device_id,
-                                            XKB_MAP_COMPILE_NO_FLAGS);
+                                            XKB_KEYMAP_COMPILE_NO_FLAGS);
     assert(keymap);
 
     state = xkb_x11_state_new_from_device(keymap, conn, device_id);
diff --git a/xkbcommon/xkbcommon-compat.h b/xkbcommon/xkbcommon-compat.h
index f96e4c8..299732f 100644
--- a/xkbcommon/xkbcommon-compat.h
+++ b/xkbcommon/xkbcommon-compat.h
@@ -91,4 +91,8 @@
 
 #define xkb_state_get_map(state) xkb_state_get_keymap(state)
 
+/* Not needed anymore, since there's NO_FLAGS. */
+#define XKB_MAP_COMPILE_PLACEHOLDER XKB_KEYMAP_COMPILE_NO_FLAGS
+#define XKB_MAP_COMPILE_NO_FLAGS XKB_KEYMAP_COMPILE_NO_FLAGS
+
 #endif
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index cc9262f..1e6c803 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -681,9 +681,7 @@ xkb_context_set_log_fn(struct xkb_context *context,
 /** Flags for keymap compilation. */
 enum xkb_keymap_compile_flags {
     /** Do not apply any flags. */
-    XKB_MAP_COMPILE_NO_FLAGS = 0,
-    /** Apparently you can't have empty enums.  What a drag. */
-    XKB_MAP_COMPILE_PLACEHOLDER = 0
+    XKB_KEYMAP_COMPILE_NO_FLAGS = 0
 };
 
 /**