From b19b0808940c8c54b102012be134a370b26e348e Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 5 Feb 2014 16:25:06 +0100 Subject: Update bundled libxkbcommon version to 0.4.0 This release comes with important bug fixes. Also we can now remove the workaround code which was needed for libxkbcommon 0.2.0. Task-number: QTBUG-31712 Task-number: QTBUG-33732 Task-number: QTBUG-34056 Change-Id: I57caf7f803b9a01a15541a5ad82e464de3b8abbb Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- .../xkbcommon/xkbcommon/xkbcommon-keysyms.h | 8 + src/3rdparty/xkbcommon/xkbcommon/xkbcommon-names.h | 1 + src/3rdparty/xkbcommon/xkbcommon/xkbcommon-x11.h | 166 ++++++++++++++++++ src/3rdparty/xkbcommon/xkbcommon/xkbcommon.h | 187 +++++++++++++++------ .../xkbcommon/xkbcommon/xkbcommon_workaround.h | 105 ------------ 5 files changed, 306 insertions(+), 161 deletions(-) create mode 100644 src/3rdparty/xkbcommon/xkbcommon/xkbcommon-x11.h delete mode 100644 src/3rdparty/xkbcommon/xkbcommon/xkbcommon_workaround.h (limited to 'src/3rdparty/xkbcommon/xkbcommon') diff --git a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-keysyms.h b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-keysyms.h index 253ea59ceb..69c582e45f 100644 --- a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-keysyms.h +++ b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-keysyms.h @@ -418,6 +418,12 @@ SOFTWARE. #define XKB_KEY_dead_belowcomma 0xfe6e #define XKB_KEY_dead_currency 0xfe6f +/* extra dead elements for German T3 layout */ +#define XKB_KEY_dead_lowline 0xfe90 +#define XKB_KEY_dead_aboveverticalline 0xfe91 +#define XKB_KEY_dead_belowverticalline 0xfe92 +#define XKB_KEY_dead_longsolidusoverlay 0xfe93 + /* dead vowels for universal syllable entry */ #define XKB_KEY_dead_a 0xfe80 #define XKB_KEY_dead_A 0xfe81 @@ -2652,6 +2658,8 @@ SOFTWARE. #define XKB_KEY_XF86TouchpadOn 0x1008FFB0 /* The touchpad got switched on */ #define XKB_KEY_XF86TouchpadOff 0x1008FFB1 /* The touchpad got switched off */ +#define XKB_KEY_XF86AudioMicMute 0x1008FFB2 /* Mute the Mic from the system */ + /* Keys for special action keys (hot keys) */ /* Virtual terminals on some operating systems */ #define XKB_KEY_XF86Switch_VT_1 0x1008FE01 diff --git a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-names.h b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-names.h index db071d8a2a..ecb551ff10 100644 --- a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-names.h +++ b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-names.h @@ -35,6 +35,7 @@ #define XKB_MOD_NAME_CAPS "Lock" #define XKB_MOD_NAME_CTRL "Control" #define XKB_MOD_NAME_ALT "Mod1" +#define XKB_MOD_NAME_NUM "Mod2" #define XKB_MOD_NAME_LOGO "Mod4" #define XKB_LED_NAME_CAPS "Caps Lock" diff --git a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-x11.h b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-x11.h new file mode 100644 index 0000000000..4ec9b649c7 --- /dev/null +++ b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon-x11.h @@ -0,0 +1,166 @@ +/* + * Copyright © 2013 Ran Benita + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _XKBCOMMON_X11_H +#define _XKBCOMMON_X11_H + +#include +#include + +/** + * @file + * libxkbcommon-x11 API - Additional X11 support for xkbcommon. + */ + +/** + * @defgroup x11 X11 support + * Additional X11 support for xkbcommon. + * + * @{ + */ + +/** + * The minimal compatible major version of the XKB X11 extension which + * this library can use. + */ +#define XKB_X11_MIN_MAJOR_XKB_VERSION 1 +/** + * The minimal compatible minor version of the XKB X11 extension which + * this library can use (for the minimal major version). + */ +#define XKB_X11_MIN_MINOR_XKB_VERSION 0 + +/** Flags for the xkb_x11_setup_xkb_extension() function. */ +enum xkb_x11_setup_xkb_extension_flags { + /** Do not apply any flags. */ + XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0 +}; + +/** + * Setup the XKB X11 extension for this X client. + * + * The xkbcommon-x11 library uses various XKB requests. Before doing so, + * an X client must notify the server that it will be using the extension. + * This function (or an XCB equivalent) must be called before any other + * function in this library is used. + * + * Some X servers may not support or disable the XKB extension. If you + * want to support such servers, you need to use a different fallback. + * + * You may call this function several times; it is idempotent. + * + * @param connection + * An XCB connection to the X server. + * @param major_xkb_version, minor_xkb_version + * The XKB extension version to request. To operate correctly, you + * must have (major_xkb_version, minor_xkb_version) >= + * (XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION), + * though this is not enforced. + * @param flags + * Optional flags, or 0. + * @param[out] major_xkb_version_out, minor_xkb_version_out + * Backfilled with the compatible XKB extension version numbers picked + * by the server. Can be NULL. + * @param[out] base_event_out + * Backfilled with the XKB base (also known as first) event code, needed + * to distinguish XKB events. Can be NULL. + * @param[out] base_error_out + * Backfilled with the XKB base (also known as first) error code, needed + * to distinguish XKB errors. Can be NULL. + * + * @returns 1 on success, or 0 on failure. + */ +int +xkb_x11_setup_xkb_extension(xcb_connection_t *connection, + uint16_t major_xkb_version, + uint16_t minor_xkb_version, + enum xkb_x11_setup_xkb_extension_flags flags, + uint16_t *major_xkb_version_out, + uint16_t *minor_xkb_version_out, + uint8_t *base_event_out, + uint8_t *base_error_out); + +/** + * Get the keyboard device ID of the core X11 keyboard. + * + * @param connection An XCB connection to the X server. + * + * @returns A device ID which may be used with other xkb_x11_* functions, + * or -1 on failure. + */ +int32_t +xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection); + +/** + * Create a keymap from an X11 keyboard device. + * + * This function queries the X server with various requests, fetches the + * details of the active keymap on a keyboard device, and creates an + * xkb_keymap from these details. + * + * @param context + * The context in which to create the keymap. + * @param connection + * An XCB connection to the X server. + * @param device_id + * An XInput 1 device ID (in the range 0-255) with input class KEY. + * Passing values outside of this range is an error. + * @param flags + * Optional flags for the keymap, or 0. + * + * @returns A keymap retrieved from the X server, or NULL on failure. + * + * @memberof xkb_keymap + */ +struct xkb_keymap * +xkb_x11_keymap_new_from_device(struct xkb_context *context, + xcb_connection_t *connection, + int32_t device_id, + enum xkb_keymap_compile_flags flags); + +/** + * Create a new keyboard state object from an X11 keyboard device. + * + * This function is the same as xkb_state_new(), only pre-initialized + * with the state of the device at the time this function is called. + * + * @param keymap + * The keymap for which to create the state. + * @param connection + * An XCB connection to the X server. + * @param device_id + * An XInput 1 device ID (in the range 0-255) with input class KEY. + * Passing values outside of this range is an error. + * + * @returns A new keyboard state object, or NULL on failure. + * + * @memberof xkb_state + */ +struct xkb_state * +xkb_x11_state_new_from_device(struct xkb_keymap *keymap, + xcb_connection_t *connection, + int32_t device_id); + +/** @} */ + +#endif diff --git a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon.h b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon.h index a2aecfbb2a..cc9262ff89 100644 --- a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon.h +++ b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon.h @@ -197,7 +197,7 @@ typedef uint32_t xkb_keysym_t; * layout is active. These may be different alphabets, different key * arrangements, etc. * - * Layout indexes are consecutive. The first layout has index 0. + * Layout indices are consecutive. The first layout has index 0. * * Each layout is not required to have a name, and the names are not * guaranteed to be unique (though they are usually provided and unique). @@ -209,13 +209,20 @@ typedef uint32_t xkb_keysym_t; * @sa xkb_keymap_num_layouts() xkb_keymap_num_layouts_for_key() */ typedef uint32_t xkb_layout_index_t; -/** A mask of layout indexes. */ +/** A mask of layout indices. */ typedef uint32_t xkb_layout_mask_t; /** * Index of a shift level. * - * @todo Explain what are shift levels. + * Any key, in any layout, can have several shift levels. Each + * shift level can assign different keysyms to the key. The shift level + * to use is chosen according to the current keyboard state; for example, + * if no keys are pressed, the first level may be used; if the Left Shift + * key is pressed, the second; if Num Lock is pressed, the third; and + * many such combinations are possible (see xkb_mod_index_t). + * + * Level indices are consecutive. The first level has index 0. */ typedef uint32_t xkb_level_index_t; @@ -233,7 +240,7 @@ typedef uint32_t xkb_level_index_t; * consulted; this detemines the correct shift level to use within the * currently active layout (see xkb_level_index_t). * - * Modifier indexes are consecutive. The first modifier has index 0. + * Modifier indices are consecutive. The first modifier has index 0. * * Each modifier must have a name, and the names are unique. Therefore, it * is safe to use the name as a unique identifier for a modifier. The names @@ -243,15 +250,17 @@ typedef uint32_t xkb_level_index_t; * @sa xkb_keymap_num_mods() */ typedef uint32_t xkb_mod_index_t; -/** A mask of modifier indexes. */ +/** A mask of modifier indices. */ typedef uint32_t xkb_mod_mask_t; /** * Index of a keyboard LED. * - * @todo Explain what are LEDs. + * LEDs are logical objects which may be @e active or @e inactive. They + * typically correspond to the lights on the keyboard. Their state is + * determined by the current keyboard state. * - * LED indexes are non-consecutive. The first LED has index 0. + * LED indices are non-consecutive. The first LED has index 0. * * Each LED must have a name, and the names are unique. Therefore, * it is safe to use the name as a unique identifier for a LED. The names @@ -261,7 +270,7 @@ typedef uint32_t xkb_mod_mask_t; * @warning A given keymap may specify an exact index for a given LED. * Therefore, LED indexing is not necessarily sequential, as opposed to * modifiers and layouts. This means that when iterating over the LEDs - * in a keymap using e.g. xkb_keymap_num_leds(), some indexes might be + * in a keymap using e.g. xkb_keymap_num_leds(), some indices might be * invalid. Given such an index, functions like xkb_keymap_led_get_name() * will return NULL, and xkb_state_led_index_is_active() will return -1. * @@ -270,7 +279,7 @@ typedef uint32_t xkb_mod_mask_t; * @sa xkb_keymap_num_leds() */ typedef uint32_t xkb_led_index_t; -/** A mask of LED indexes. */ +/** A mask of LED indices. */ typedef uint32_t xkb_led_mask_t; #define XKB_KEYCODE_INVALID (0xffffffff) @@ -351,6 +360,8 @@ xkb_keysym_get_name(xkb_keysym_t keysym, char *buffer, size_t size); /** Flags for xkb_keysym_from_name(). */ enum xkb_keysym_flags { + /** Do not apply any flags. */ + XKB_KEYSYM_NO_FLAGS = 0, /** Find keysym by case-insensitive search. */ XKB_KEYSYM_CASE_INSENSITIVE = (1 << 0) }; @@ -416,6 +427,8 @@ xkb_keysym_to_utf32(xkb_keysym_t keysym); /** Flags for context creation. */ enum xkb_context_flags { + /** Do not apply any context flags. */ + XKB_CONTEXT_NO_FLAGS = 0, /** Create this context with an empty include path. */ XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0), /** Don't take RMLVO names from the environment. */ @@ -667,6 +680,8 @@ 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 }; @@ -811,6 +826,46 @@ xkb_keymap_get_as_string(struct xkb_keymap *keymap, * @{ */ +/** + * Get the minimum keycode in the keymap. + * + * @sa xkb_keycode_t + * @memberof xkb_keymap + */ +xkb_keycode_t +xkb_keymap_min_keycode(struct xkb_keymap *keymap); + +/** + * Get the maximum keycode in the keymap. + * + * @sa xkb_keycode_t + * @memberof xkb_keymap + */ +xkb_keycode_t +xkb_keymap_max_keycode(struct xkb_keymap *keymap); + +/** + * The iterator used by xkb_keymap_key_for_each(). + * + * @sa xkb_keymap_key_for_each + * @memberof xkb_keymap + */ +typedef void +(*xkb_keymap_key_iter_t)(struct xkb_keymap *keymap, xkb_keycode_t key, + void *data); + +/** + * Run a specified function for every valid keycode in the keymap. If a + * keymap is sparse, this function may be called fewer than + * (max_keycode - min_keycode + 1) times. + * + * @sa xkb_keymap_min_keycode() xkb_keymap_max_keycode() xkb_keycode_t + * @memberof xkb_keymap + */ +void +xkb_keymap_key_for_each(struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter, + void *data); + /** * Get the number of modifiers in the keymap. * @@ -1001,9 +1056,9 @@ xkb_keymap_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key); */ /** - * Create a new keyboard state object for a keymap. + * Create a new keyboard state object. * - * @param keymap The keymap for which to create the state. + * @param keymap The keymap which the state will use. * * @returns A new keyboard state object, or NULL on failure. * @@ -1033,10 +1088,10 @@ void xkb_state_unref(struct xkb_state *state); /** - * Get the keymap from which a keyboard state object was created. + * Get the keymap which a keyboard state object is using. * - * @returns The keymap which was used in xkb_state_new() to create this - * state object. + * @returns The keymap which was passed to xkb_state_new() when creating + * this state object. * * This function does not take a new reference on the keymap; you must * explicitly reference it yourself if you plan to use it beyond the @@ -1070,7 +1125,8 @@ enum xkb_state_component { * lock has been pressed again. */ XKB_STATE_MODS_LOCKED = (1 << 2), /** Effective modifiers, i.e. currently active and affect key - * processing (derived from the other state components). */ + * processing (derived from the other state components). + * Use this unless you explictly care how the state came about. */ XKB_STATE_MODS_EFFECTIVE = (1 << 3), /** Depressed layout, i.e. a key is physically holding it. */ XKB_STATE_LAYOUT_DEPRESSED = (1 << 4), @@ -1081,7 +1137,8 @@ enum xkb_state_component { * has been pressed again. */ XKB_STATE_LAYOUT_LOCKED = (1 << 6), /** Effective layout, i.e. currently active and affects key processing - * (derived from the other state components). */ + * (derived from the other state components). + * Use this unless you explictly care how the state came about. */ XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7), /** LEDs (derived from the other state components). */ XKB_STATE_LEDS = (1 << 8) @@ -1091,15 +1148,64 @@ enum xkb_state_component { * Update the keyboard state to reflect a given key being pressed or * released. * + * This entry point is intended for programs which track the keyboard state + * explictly (like an evdev client). If the state is serialized to you by + * a master process (like a Wayland compositor) using functions like + * xkb_state_serialize_mods(), you should use xkb_state_update_mask() instead. + * The two functins should not generally be used together. + * + * A series of calls to this function should be consistent; that is, a call + * with XKB_KEY_DOWN for a key should be matched by an XKB_KEY_UP; if a key + * is pressed twice, it should be released twice; etc. Otherwise (e.g. due + * to missed input events), situations like "stuck modifiers" may occur. + * * @returns A mask of state components that have changed as a result of * the update. If nothing in the state has changed, returns 0. * * @memberof xkb_state + * + * @sa xkb_state_update_mask() */ enum xkb_state_component xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key, enum xkb_key_direction direction); +/** + * Update a keyboard state from a set of explicit masks. + * + * This entry point is intended for window systems and the like, where a + * master process holds an xkb_state, then serializes it over a wire + * protocol, and clients then use the serialization to feed in to their own + * xkb_state. + * + * All parameters must always be passed, or the resulting state may be + * incoherent. + * + * The serialization is lossy and will not survive round trips; it must only + * be used to feed slave state objects, and must not be used to update the + * master state. + * + * If you do not fit the description above, you should use + * xkb_state_update_key() instead. The two functions should not generally be + * used together. + * + * @returns A mask of state components that have changed as a result of + * the update. If nothing in the state has changed, returns 0. + * + * @memberof xkb_state + * + * @sa xkb_state_component + * @sa xkb_state_update_key + */ +enum xkb_state_component +xkb_state_update_mask(struct xkb_state *state, + xkb_mod_mask_t depressed_mods, + xkb_mod_mask_t latched_mods, + xkb_mod_mask_t locked_mods, + xkb_layout_index_t depressed_layout, + xkb_layout_index_t latched_layout, + xkb_layout_index_t locked_layout); + /** * Get the keysyms obtained from pressing a particular key in a given * keyboard state. @@ -1114,8 +1220,9 @@ xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key, * key in the given keyboard state. * * As an extension to XKB, this function can return more than one keysym. - * If you do not want to handle this case, you can use - * xkb_state_key_get_one_sym(). + * If you do not want to handle this case, you should use + * xkb_state_key_get_one_sym(), which additionally performs transformations + * which are specific to the one-keysym case. * * @returns The number of keysyms in the syms_out array. If no keysyms * are produced by the key in the given keyboard state, returns 0 and sets @@ -1131,9 +1238,10 @@ xkb_state_key_get_syms(struct xkb_state *state, xkb_keycode_t key, * Get the single keysym obtained from pressing a particular key in a * given keyboard state. * - * This function is similar to xkb_state_key_get_syms(), but with a - * simplified interface for users which cannot or do not want to handle - * the case where multiple keysyms are returned. + * This function is similar to xkb_state_key_get_syms(), but intended + * for users which cannot or do not want to handle the case where + * multiple keysyms are returned (in which case this function is + * preferred). * * @returns The keysym. If the key does not have exactly one keysym, * returns XKB_KEY_NoSymbol @@ -1203,39 +1311,6 @@ enum xkb_state_match { XKB_STATE_MATCH_NON_EXCLUSIVE = (1 << 16) }; -/** - * Update a keyboard state from a set of explicit masks. - * - * This entry point is really only for window systems and the like, where a - * master process holds an xkb_state, then serializes it over a wire - * protocol, and clients then use the serialization to feed in to their own - * xkb_state. - * - * All parameters must always be passed, or the resulting state may be - * incoherent. - * - * The serialization is lossy and will not survive round trips; it must only - * be used to feed slave state objects, and must not be used to update the - * master state. - * - * Please do not use this unless you fit the description above. - * - * @returns A mask of state components that have changed as a result of - * the update. If nothing in the state has changed, returns 0. - * - * @memberof xkb_state - * - * @sa xkb_state_component - */ -enum xkb_state_component -xkb_state_update_mask(struct xkb_state *state, - xkb_mod_mask_t depressed_mods, - xkb_mod_mask_t latched_mods, - xkb_mod_mask_t locked_mods, - xkb_layout_index_t depressed_layout, - xkb_layout_index_t latched_layout, - xkb_layout_index_t locked_layout); - /** * The counterpart to xkb_state_update_mask for modifiers, to be used on * the server side of serialization. @@ -1336,11 +1411,11 @@ xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx, * given modifiers. * @param match The manner by which to match the state against the * given modifiers. - * @param ... The set of of modifier indexes to test, terminated by a + * @param ... The set of of modifier indices to test, terminated by a * XKB_MOD_INVALID argument (sentinel). * * @returns 1 if the modifiers are active, 0 if they are not. If any of - * the modifier indexes are invalid in the keymap, returns -1. + * the modifier indices are invalid in the keymap, returns -1. * * @memberof xkb_state */ diff --git a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon_workaround.h b/src/3rdparty/xkbcommon/xkbcommon/xkbcommon_workaround.h deleted file mode 100644 index 58ce143978..0000000000 --- a/src/3rdparty/xkbcommon/xkbcommon/xkbcommon_workaround.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XKBCOMMON_WORKAROUND_H -#define XKBCOMMON_WORKAROUND_H - -// Function utf32_to_utf8() is borrowed from the libxkbcommon library, -// file keysym-utf.c. The workaround should be removed once the fix from -// https://bugs.freedesktop.org/show_bug.cgi?id=56780 gets released. -static int utf32_to_utf8(uint32_t unichar, char *buffer) -{ - int count, shift, length; - uint8_t head; - - if (unichar <= 0x007f) { - buffer[0] = unichar; - buffer[1] = '\0'; - return 2; - } - else if (unichar <= 0x07FF) { - length = 2; - head = 0xc0; - } - else if (unichar <= 0xffff) { - length = 3; - head = 0xe0; - } - else if (unichar <= 0x1fffff) { - length = 4; - head = 0xf0; - } - else if (unichar <= 0x3ffffff) { - length = 5; - head = 0xf8; - } - else { - length = 6; - head = 0xfc; - } - - for (count = length - 1, shift = 0; count > 0; count--, shift += 6) - buffer[count] = 0x80 | ((unichar >> shift) & 0x3f); - - buffer[0] = head | ((unichar >> shift) & 0x3f); - buffer[length] = '\0'; - - return length + 1; -} - -static bool needWorkaround(uint32_t sym) -{ - /* patch encoding botch */ - if (sym == XKB_KEY_KP_Space) - return true; - - /* special keysyms */ - if ((sym >= XKB_KEY_BackSpace && sym <= XKB_KEY_Clear) || - (sym >= XKB_KEY_KP_Multiply && sym <= XKB_KEY_KP_9) || - sym == XKB_KEY_Return || sym == XKB_KEY_Escape || - sym == XKB_KEY_Delete || sym == XKB_KEY_KP_Tab || - sym == XKB_KEY_KP_Enter || sym == XKB_KEY_KP_Equal) - return true; - - return false; -} - -#endif // XKBCOMMON_WORKAROUND_H -- cgit v1.2.3