summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-07-20 23:21:44 +0300
committerRan Benita <ran234@gmail.com>2014-02-02 11:16:40 +0200
commiteb34825560edf570d883d3e52a8fe657c17b3d9c (patch)
treedc1d7d3dba0acc6a07ccbbf297093c9ea08ce3f5 /src/utils.h
parentddbefda383cccbf8d537b30471fc2ce893826d35 (diff)
downloadlibxkbcommon-eb34825560edf570d883d3e52a8fe657c17b3d9c.tar.gz
libxkbcommon-eb34825560edf570d883d3e52a8fe657c17b3d9c.tar.bz2
libxkbcommon-eb34825560edf570d883d3e52a8fe657c17b3d9c.zip
x11: add XKB protocol keymap and state creation support
These are function to create an xkb_keymap directly from XKB requests to the X server. This opens up the possibility for X clients to use xcb + xcb-xkb + xkbcommon as a proper replacement for Xlib + xkbfile for keyboard support. The X11 support must be enabled with --enable-x11 for now. The functions are in xkbcommon/xkbcommon-x11.h. It depends on a recent libxcb with xkb enabled. The functions are in a new libxkbcommon-x11.so, with a new pkg-config file, etc. so that the packages may be split, and libxkbcommon.so itself remains dependency-free. Why not just use the RMLVO that the server puts in the _XKB_RULES_NAMES property? This does not account for custom keymaps, on-the-fly keymap modifications, remote clients, etc., so is not a proper solution in practice. Also, some servers don't even set it. Now, the client just needs to recreate the keymap in response to a change in the server's keymap (as Xlib clients do with XRefreshKeyboardMapping() and friends). Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 04fb9c5..81d1cc9 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -158,6 +158,22 @@ is_graph(char ch)
return ch >= '!' && ch <= '~';
}
+/*
+ * Return the bit position of the most significant bit.
+ * Note: this is 1-based! It's more useful this way, and returns 0 when
+ * mask is all 0s.
+ */
+static inline int
+msb_pos(uint32_t mask)
+{
+ int pos = 0;
+ while (mask) {
+ pos++;
+ mask >>= 1;
+ }
+ return pos;
+}
+
bool
map_file(FILE *file, const char **string_out, size_t *size_out);