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.
48 * The minimal compatible major version of the XKB X11 extension which
49 * this library can use.
51 #define XKB_X11_MIN_MAJOR_XKB_VERSION 1
53 * The minimal compatible minor version of the XKB X11 extension which
54 * this library can use (for the minimal major version).
56 #define XKB_X11_MIN_MINOR_XKB_VERSION 0
58 /** Flags for the xkb_x11_setup_xkb_extension() function. */
59 enum xkb_x11_setup_xkb_extension_flags {
60 /** Do not apply any flags. */
61 XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0
65 * Setup the XKB X11 extension for this X client.
67 * The xkbcommon-x11 library uses various XKB requests. Before doing so,
68 * an X client must notify the server that it will be using the extension.
69 * This function (or an XCB equivalent) must be called before any other
70 * function in this library is used.
72 * Some X servers may not support or disable the XKB extension. If you
73 * want to support such servers, you need to use a different fallback.
75 * You may call this function several times; it is idempotent.
78 * An XCB connection to the X server.
79 * @param major_xkb_version, minor_xkb_version
80 * The XKB extension version to request. To operate correctly, you
81 * must have (major_xkb_version, minor_xkb_version) >=
82 * (XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION),
83 * though this is not enforced.
85 * Optional flags, or 0.
86 * @param[out] major_xkb_version_out, minor_xkb_version_out
87 * Backfilled with the compatible XKB extension version numbers picked
88 * by the server. Can be NULL.
89 * @param[out] base_event_out
90 * Backfilled with the XKB base (also known as first) event code, needed
91 * to distinguish XKB events. Can be NULL.
92 * @param[out] base_error_out
93 * Backfilled with the XKB base (also known as first) error code, needed
94 * to distinguish XKB errors. Can be NULL.
96 * @returns 1 on success, or 0 on failure.
99 xkb_x11_setup_xkb_extension(xcb_connection_t *connection,
100 uint16_t major_xkb_version,
101 uint16_t minor_xkb_version,
102 enum xkb_x11_setup_xkb_extension_flags flags,
103 uint16_t *major_xkb_version_out,
104 uint16_t *minor_xkb_version_out,
105 uint8_t *base_event_out,
106 uint8_t *base_error_out);
109 * Get the keyboard device ID of the core X11 keyboard.
111 * @param connection An XCB connection to the X server.
113 * @returns A device ID which may be used with other xkb_x11_* functions,
117 xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection);
120 * Create a keymap from an X11 keyboard device.
122 * This function queries the X server with various requests, fetches the
123 * details of the active keymap on a keyboard device, and creates an
124 * xkb_keymap from these details.
127 * The context in which to create the keymap.
129 * An XCB connection to the X server.
131 * An XInput 1 device ID (in the range 0-255) with input class KEY.
132 * Passing values outside of this range is an error.
134 * Optional flags for the keymap, or 0.
136 * @returns A keymap retrieved from the X server, or NULL on failure.
138 * @memberof xkb_keymap
141 xkb_x11_keymap_new_from_device(struct xkb_context *context,
142 xcb_connection_t *connection,
144 enum xkb_keymap_compile_flags flags);
147 * Create a new keyboard state object from an X11 keyboard device.
149 * This function is the same as xkb_state_new(), only pre-initialized
150 * with the state of the device at the time this function is called.
153 * The keymap for which to create the state.
155 * An XCB connection to the X server.
157 * An XInput 1 device ID (in the range 0-255) with input class KEY.
158 * Passing values outside of this range is an error.
160 * @returns A new keyboard state object, or NULL on failure.
162 * @memberof xkb_state
165 xkb_x11_state_new_from_device(struct xkb_keymap *keymap,
166 xcb_connection_t *connection,
175 #endif /* _XKBCOMMON_X11_H */