|
||||
Warning, file /include/xkbcommon/xkbcommon-x11.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright © 2013 Ran Benita 0003 * 0004 * Permission is hereby granted, free of charge, to any person obtaining a 0005 * copy of this software and associated documentation files (the "Software"), 0006 * to deal in the Software without restriction, including without limitation 0007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 0008 * and/or sell copies of the Software, and to permit persons to whom the 0009 * Software is furnished to do so, subject to the following conditions: 0010 * 0011 * The above copyright notice and this permission notice (including the next 0012 * paragraph) shall be included in all copies or substantial portions of the 0013 * Software. 0014 * 0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 0018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0020 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 0021 * DEALINGS IN THE SOFTWARE. 0022 */ 0023 0024 #ifndef _XKBCOMMON_X11_H 0025 #define _XKBCOMMON_X11_H 0026 0027 #include <xcb/xcb.h> 0028 #include <xkbcommon/xkbcommon.h> 0029 0030 #ifdef __cplusplus 0031 extern "C" { 0032 #endif 0033 0034 /** 0035 * @file 0036 * libxkbcommon-x11 API - Additional X11 support for xkbcommon. 0037 */ 0038 0039 /** 0040 * @defgroup x11 X11 support 0041 * Additional X11 support for xkbcommon. 0042 * @since 0.4.0 0043 * 0044 * @{ 0045 */ 0046 0047 /** 0048 * @page x11-overview Overview 0049 * @parblock 0050 * 0051 * The xkbcommon-x11 module provides a means for creating an xkb_keymap 0052 * corresponding to the currently active keymap on the X server. To do 0053 * so, it queries the XKB X11 extension using the xcb-xkb library. It 0054 * can be used as a replacement for Xlib's keyboard handling. 0055 * 0056 * Following is an example workflow using xkbcommon-x11. A complete 0057 * example may be found in the tools/interactive-x11.c file in the 0058 * xkbcommon source repository. On startup: 0059 * 0060 * 1. Connect to the X server using xcb_connect(). 0061 * 2. Setup the XKB X11 extension. You can do this either by using the 0062 * xcb_xkb_use_extension() request directly, or by using the 0063 * xkb_x11_setup_xkb_extension() helper function. 0064 * 0065 * The XKB extension supports using separate keymaps and states for 0066 * different keyboard devices. The devices are identified by an integer 0067 * device ID and are managed by another X11 extension, XInput. The 0068 * original X11 protocol only had one keyboard device, called the "core 0069 * keyboard", which is still supported as a "virtual device". 0070 * 0071 * 3. We will use the core keyboard as an example. To get its device ID, 0072 * use either the xcb_xkb_get_device_info() request directly, or the 0073 * xkb_x11_get_core_keyboard_device_id() helper function. 0074 * 4. Create an initial xkb_keymap for this device, using the 0075 * xkb_x11_keymap_new_from_device() function. 0076 * 5. Create an initial xkb_state for this device, using the 0077 * xkb_x11_state_new_from_device() function. 0078 * 0079 * @note At this point, you may consider setting various XKB controls and 0080 * XKB per-client flags. For example, enabling detectable autorepeat: \n 0081 * https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Detectable_Autorepeat 0082 * 0083 * Next, you need to react to state changes (e.g. a modifier was pressed, 0084 * the layout was changed) and to keymap changes (e.g. a tool like xkbcomp, 0085 * setxkbmap or xmodmap was used): 0086 * 0087 * 6. Select to listen to at least the following XKB events: 0088 * NewKeyboardNotify, MapNotify, StateNotify; using the 0089 * xcb_xkb_select_events_aux() request. 0090 * 7. When NewKeyboardNotify or MapNotify are received, recreate the 0091 * xkb_keymap and xkb_state as described above. 0092 * 8. When StateNotify is received, update the xkb_state accordingly 0093 * using the xkb_state_update_mask() function. 0094 * 0095 * @note It is also possible to use the KeyPress/KeyRelease @p state 0096 * field to find the effective modifier and layout state, instead of 0097 * using XkbStateNotify: \n 0098 * https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Computing_A_State_Field_from_an_XKB_State 0099 * \n However, XkbStateNotify is more accurate. 0100 * 0101 * @note There is no need to call xkb_state_update_key(); the state is 0102 * already synchronized. 0103 * 0104 * Finally, when a key event is received, you can use ordinary xkbcommon 0105 * functions, like xkb_state_key_get_one_sym() and xkb_state_key_get_utf8(), 0106 * as you normally would. 0107 * 0108 * @endparblock 0109 */ 0110 0111 /** 0112 * The minimal compatible major version of the XKB X11 extension which 0113 * this library can use. 0114 */ 0115 #define XKB_X11_MIN_MAJOR_XKB_VERSION 1 0116 /** 0117 * The minimal compatible minor version of the XKB X11 extension which 0118 * this library can use (for the minimal major version). 0119 */ 0120 #define XKB_X11_MIN_MINOR_XKB_VERSION 0 0121 0122 /** Flags for the xkb_x11_setup_xkb_extension() function. */ 0123 enum xkb_x11_setup_xkb_extension_flags { 0124 /** Do not apply any flags. */ 0125 XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0 0126 }; 0127 0128 /** 0129 * Setup the XKB X11 extension for this X client. 0130 * 0131 * The xkbcommon-x11 library uses various XKB requests. Before doing so, 0132 * an X client must notify the server that it will be using the extension. 0133 * This function (or an XCB equivalent) must be called before any other 0134 * function in this library is used. 0135 * 0136 * Some X servers may not support or disable the XKB extension. If you 0137 * want to support such servers, you need to use a different fallback. 0138 * 0139 * You may call this function several times; it is idempotent. 0140 * 0141 * @param connection 0142 * An XCB connection to the X server. 0143 * @param major_xkb_version 0144 * See @p minor_xkb_version. 0145 * @param minor_xkb_version 0146 * The XKB extension version to request. To operate correctly, you 0147 * must have (major_xkb_version, minor_xkb_version) >= 0148 * (XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION), 0149 * though this is not enforced. 0150 * @param flags 0151 * Optional flags, or 0. 0152 * @param[out] major_xkb_version_out 0153 * See @p minor_xkb_version_out. 0154 * @param[out] minor_xkb_version_out 0155 * Backfilled with the compatible XKB extension version numbers picked 0156 * by the server. Can be NULL. 0157 * @param[out] base_event_out 0158 * Backfilled with the XKB base (also known as first) event code, needed 0159 * to distinguish XKB events. Can be NULL. 0160 * @param[out] base_error_out 0161 * Backfilled with the XKB base (also known as first) error code, needed 0162 * to distinguish XKB errors. Can be NULL. 0163 * 0164 * @returns 1 on success, or 0 on failure. 0165 */ 0166 int 0167 xkb_x11_setup_xkb_extension(xcb_connection_t *connection, 0168 uint16_t major_xkb_version, 0169 uint16_t minor_xkb_version, 0170 enum xkb_x11_setup_xkb_extension_flags flags, 0171 uint16_t *major_xkb_version_out, 0172 uint16_t *minor_xkb_version_out, 0173 uint8_t *base_event_out, 0174 uint8_t *base_error_out); 0175 0176 /** 0177 * Get the keyboard device ID of the core X11 keyboard. 0178 * 0179 * @param connection An XCB connection to the X server. 0180 * 0181 * @returns A device ID which may be used with other xkb_x11_* functions, 0182 * or -1 on failure. 0183 */ 0184 int32_t 0185 xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection); 0186 0187 /** 0188 * Create a keymap from an X11 keyboard device. 0189 * 0190 * This function queries the X server with various requests, fetches the 0191 * details of the active keymap on a keyboard device, and creates an 0192 * xkb_keymap from these details. 0193 * 0194 * @param context 0195 * The context in which to create the keymap. 0196 * @param connection 0197 * An XCB connection to the X server. 0198 * @param device_id 0199 * An XInput device ID (in the range 0-127) with input class KEY. 0200 * Passing values outside of this range is an error (the XKB protocol 0201 * predates the XInput2 protocol, which first allowed IDs > 127). 0202 * @param flags 0203 * Optional flags for the keymap, or 0. 0204 * 0205 * @returns A keymap retrieved from the X server, or NULL on failure. 0206 * 0207 * @memberof xkb_keymap 0208 */ 0209 struct xkb_keymap * 0210 xkb_x11_keymap_new_from_device(struct xkb_context *context, 0211 xcb_connection_t *connection, 0212 int32_t device_id, 0213 enum xkb_keymap_compile_flags flags); 0214 0215 /** 0216 * Create a new keyboard state object from an X11 keyboard device. 0217 * 0218 * This function is the same as xkb_state_new(), only pre-initialized 0219 * with the state of the device at the time this function is called. 0220 * 0221 * @param keymap 0222 * The keymap for which to create the state. 0223 * @param connection 0224 * An XCB connection to the X server. 0225 * @param device_id 0226 * An XInput 1 device ID (in the range 0-255) with input class KEY. 0227 * Passing values outside of this range is an error. 0228 * 0229 * @returns A new keyboard state object, or NULL on failure. 0230 * 0231 * @memberof xkb_state 0232 */ 0233 struct xkb_state * 0234 xkb_x11_state_new_from_device(struct xkb_keymap *keymap, 0235 xcb_connection_t *connection, 0236 int32_t device_id); 0237 0238 /** @} */ 0239 0240 #ifdef __cplusplus 0241 } /* extern "C" */ 0242 #endif 0243 0244 #endif /* _XKBCOMMON_X11_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |