2 * Copyright © 2013 Ran Benita
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifndef _XKBCOMMON_X11_H
25 #define _XKBCOMMON_X11_H
28 #include <xkbcommon/xkbcommon.h>
36 * libxkbcommon-x11 API - Additional X11 support for xkbcommon.
40 * @defgroup x11 X11 support
41 * Additional X11 support for xkbcommon.
47 * The minimal compatible major version of the XKB X11 extension which
48 * this library can use.
50 #define XKB_X11_MIN_MAJOR_XKB_VERSION 1
52 * The minimal compatible minor version of the XKB X11 extension which
53 * this library can use (for the minimal major version).
55 #define XKB_X11_MIN_MINOR_XKB_VERSION 0
57 /** Flags for the xkb_x11_setup_xkb_extension() function. */
58 enum xkb_x11_setup_xkb_extension_flags {
59 /** Do not apply any flags. */
60 XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0
64 * Setup the XKB X11 extension for this X client.
66 * The xkbcommon-x11 library uses various XKB requests. Before doing so,
67 * an X client must notify the server that it will be using the extension.
68 * This function (or an XCB equivalent) must be called before any other
69 * function in this library is used.
71 * Some X servers may not support or disable the XKB extension. If you
72 * want to support such servers, you need to use a different fallback.
74 * You may call this function several times; it is idempotent.
77 * An XCB connection to the X server.
78 * @param major_xkb_version, minor_xkb_version
79 * The XKB extension version to request. To operate correctly, you
80 * must have (major_xkb_version, minor_xkb_version) >=
81 * (XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION),
82 * though this is not enforced.
84 * Optional flags, or 0.
85 * @param[out] major_xkb_version_out, minor_xkb_version_out
86 * Backfilled with the compatible XKB extension version numbers picked
87 * by the server. Can be NULL.
88 * @param[out] base_event_out
89 * Backfilled with the XKB base (also known as first) event code, needed
90 * to distinguish XKB events. Can be NULL.
91 * @param[out] base_error_out
92 * Backfilled with the XKB base (also known as first) error code, needed
93 * to distinguish XKB errors. Can be NULL.
95 * @returns 1 on success, or 0 on failure.
98 xkb_x11_setup_xkb_extension(xcb_connection_t *connection,
99 uint16_t major_xkb_version,
100 uint16_t minor_xkb_version,
101 enum xkb_x11_setup_xkb_extension_flags flags,
102 uint16_t *major_xkb_version_out,
103 uint16_t *minor_xkb_version_out,
104 uint8_t *base_event_out,
105 uint8_t *base_error_out);
108 * Get the keyboard device ID of the core X11 keyboard.
110 * @param connection An XCB connection to the X server.
112 * @returns A device ID which may be used with other xkb_x11_* functions,
116 xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection);
119 * Create a keymap from an X11 keyboard device.
121 * This function queries the X server with various requests, fetches the
122 * details of the active keymap on a keyboard device, and creates an
123 * xkb_keymap from these details.
126 * The context in which to create the keymap.
128 * An XCB connection to the X server.
130 * An XInput 1 device ID (in the range 0-255) with input class KEY.
131 * Passing values outside of this range is an error.
133 * Optional flags for the keymap, or 0.
135 * @returns A keymap retrieved from the X server, or NULL on failure.
137 * @memberof xkb_keymap
140 xkb_x11_keymap_new_from_device(struct xkb_context *context,
141 xcb_connection_t *connection,
143 enum xkb_keymap_compile_flags flags);
146 * Create a new keyboard state object from an X11 keyboard device.
148 * This function is the same as xkb_state_new(), only pre-initialized
149 * with the state of the device at the time this function is called.
152 * The keymap for which to create the state.
154 * An XCB connection to the X server.
156 * An XInput 1 device ID (in the range 0-255) with input class KEY.
157 * Passing values outside of this range is an error.
159 * @returns A new keyboard state object, or NULL on failure.
161 * @memberof xkb_state
164 xkb_x11_state_new_from_device(struct xkb_keymap *keymap,
165 xcb_connection_t *connection,
174 #endif /* _XKBCOMMON_X11_H */