summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbkeyboard.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement XCB key mapper in terms of QPlatformKeyMapperTor Arne Vestbø2023-10-091-2/+12
| | | | | Change-Id: I81af1200b7b1113062d66a76a185a6d15eab0ba9 Reviewed-by: Liang Qi <liang.qi@qt.io>
* xcb: update xkb_state mask as much as possibleLiang Qi2022-06-281-2/+2
| | | | | | | | | | | | | | | Though we can get xcb_xkb_state_notify_event_t for the change, but it looks like not enough, especially when a new usb barcode scanner was used, it should be a slave keyboard, and Qt only uses core_device_id for now. It should be enough to update xkb_state mask when we get key event. See also https://xkbcommon.org/doc/current/md_doc_quick_guide.html . Fixes: QTBUG-95933 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ie1e82c19edd777630c7f9057a3b2b8b7cad59e38 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Revert "xcb: stablilize xkb state when keymap updated"Liang Qi2022-05-061-20/+4
| | | | | | | | | | | | | | | | | | | | | This reverts commit 27c25fc909c19ddc4750f36d26b7c500db9eb0ab. Currently Qt only supports core device of keyboard, not every real keyboard. Create a new xkb state during xcb_xkb_new_keyboard_notify_event_t, it will lose the correct state before the event, for example, when using the second or later layout than the first one. The new xkb state will use the first layout. It's difficult to sync the xkb states. Fixes: QTBUG-102493 Fixes: QTBUG-102640 Task-number: QTBUG-95933 Pick-to: 6.3 6.2 5.15 Change-Id: Iaa5369ff9f5495e194577dcbb8f78303158c9a73 Reviewed-by: Lu YaNing <luyaning@uniontech.com> Reviewed-by: Zhang Hao <543985125@qq.com> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru>
* XCB: fix GCC 12 warning about uninitialized variable useThiago Macieira2022-04-251-1/+1
| | | | | | | | | | | | GCC is right that symbolsGroup2 could remain uninitialized for some conditions. So always initialize it. qxcbkeyboard.cpp:284:48: error: ‘symbolsGroup2’ may be used uninitialized [-Werror=maybe-uninitialized] Pick-to: 6.2 6.3 Change-Id: If05aeeb7176e4f13af9afffd16e84af7d7806b0d Reviewed-by: Zhang Hao <543985125@qq.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* xcb: stablilize xkb state when keymap updatedLiang Qi2021-11-261-4/+20
| | | | | | | | | | | | | | | | QXcbKeyboard only deals with core_device_id. With the reporter's test case: using xdotool to send a string, the deviceID is not changed, then we assume xkb_state_new() is more stable(or correct) than xkb_x11_state_new_from_device() in this case. See also https://www.x.org/releases/current/doc/man/man3/xcb_xkb_new_keyboard_notify_event_t.3.xhtml . Fixes: QTBUG-95933 Pick-to: 6.2 5.15 Change-Id: Ic595e1f1424fbc6814871a85ac159907f1aeb12a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Zhang Hao <zhanghao@uniontech.com> Reviewed-by: Liang Qi <liang.qi@qt.io>
* Revert "Qt xcb: remove false detects of Qt::GroupSwitchModifier"Liang Qi2021-09-171-3/+3
| | | | | | | | | | | | | | | | | This reverts commit 25a7034d78aeb12726a1052d64c0aa3314a1f69d. The change makes the 5th modifier key broken, which is more serious than Backspace key doesn't work in CapsLock on. And we don't have a better solution for both of them now, perhaps it's better to keep the old behavior in 6.2 LTS. Task-number: QTBUG-49771 Fixes: QTBUG-95108 Fixes: QTBUG-95289 Pick-to: 6.2 6.2.0 5.15 Change-Id: Ie5d0aafa562b5097e089cafc83ae227c75c6d752 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Qt xcb: remove false detects of Qt::GroupSwitchModifierAleksei Nikiforov2021-05-261-3/+3
| | | | | | | | | | | | | | | | | In some cases, if X11 is configured with CapsLock as keyboard language switch key, and CapsLock is toggled via Shift+CapsLock key combination, toggled CapsLock is falsely detected as Qt::GroupSwitchModifier for subsequent key events. This change fixes this false detect, but doesn't fix detection of Qt::GroupSwitchModifier which is likely still broken. Fixes: QTBUG-49771 Pick-to: 5.15 6.0 6.1 Change-Id: I485e2d4f3c654707c62adaba367c1b8afb3fc36c Reviewed-by: Liang Qi <liang.qi@qt.io>
* Use QList instead of QVector in pluginsJarek Kobus2020-07-061-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic86f4a3000592a1c9ae62e4a83f4fe39832a6b24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-2/+2
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* 3rdparty: remove xcb libs and bump minimal required version to 1.11Gatis Paeglis2019-08-271-24/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With libxcb 1.11 as minimal required version we can: (a) (Maybe) Enable threaded GL for MESA, see QTBUG-67277. (b) Avoid performance issues described in QTBUG-46017. Bundled xcb libs don't contain the more modern SHM fd passing APIs. The official binaries use "-qt-xcb", therefore we were shipping with the performance fix #ifdef-ed out. (c) Make xcb-xkb a mandatory dependency avoiding issues described in QTBUG-30911. Issues that appear when Qt was configure with "-no-xkb -xcb-xlib", but X server has the XKB extension. (d) Drop all, but xcb-xinput sources from src/3rdparty/xcb/, for which we need "xcb-xinput >= 1.12". This way we can reduce maintenance work. The xcb libraries were origianlly bundled because of lack of availability on supported distributions. This is not the case anymore: CI for Qt 5.13 has: Ubuntu 18.04 - libxcb 1.13 RHEL 7.4 - libxcb 1.13 openSUSE 15.0 - libxcb 1.13 CI for Qt 5.12 has: Ubuntu 16.04 - libxcb 1.11 RHEL 7.4 - libxcb 1.13 openSUSE 42.3 - libxcb 1.11 RHEL 6.x - not relevant because it was dropped from supported platforms. Why 1.11 (released on Aug, 2014), but not 1.13 (released on March 2018)? Based on what we have in CI for 5.13 and 5.14 we could update to 1.13, but it means that Qt would require a very recent version of 3rd party dependency. [ChangeLog][Configure][X11] The minimal required version of libxcb now is 1.11. [ChangeLog][Third-Party Code][X11] Removed all bundled XCB libs, with the exception of xcb-xinput, which is not available on systems with libxcb 1.11. [ChangeLog][Configure][X11] Removed -qt-xcb, -system-xcb, -xkb, -xcb-xinput switches. [ChangeLog][Platform Specific Changes][X11] XKB and XInput2 now are mandatory dependencies for XCB plugin. XCB-XKB is a part of libxcb 1.11 releases. XCB-XInput is not part of libxcb 1.11 releases, but Qt builders can use -bundled-xcb-xinput switch. Fixes: QTBUG-73862 Fixes: QTBUG-73888 Task-number: QTBUG-67277 Task-number: QTBUG-30939 Change-Id: I4c2bd2a0e667220d32fd1fbfa1419c844f17fcce Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* platforminputcontexts: use libxkbcommon compose key APIGatis Paeglis2019-03-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our implementation of compose table parser was added on Mar, 2013. libxkbcommon added APIs for the same thing in Oct, 2014 (ver: 0.5.0). After removing RHEL 6.6 from the list of supported platforms we were able to move the minimal required libxkbcommon version to 0.5.0. Now we can use the xkbcommon-compose APIs on all supported platforms. With this patch we can drop nearly 1000 lines of maintenance burden. This patch fixes user reported issues with our implementation. Known issues: - Testing revealed that xkbcommon-compose does not support non-utf8 locales, and that is by design - https://github.com/xkbcommon/libxkbcommon/issues/76 Our implementation did work for those locales too, but it is unclear if anyone actually uses non-utf8 locales. It is a corner case (work-arounds existing) and likely a configuration error on the users' system. - Looking at the release notes for versions above 0.6.1, only one issue that stands out. Compose input does not work on system with tr_TR.UTF-8 locale, fixed in 0.7.1. Compose input works fine when using e.g. en_US.UTF-8 locale with Turkish keyboard layout. Note: With Qt 5.13 we have removed Ubuntu 16.04 and openSUSE 42.3 from CI: Ubuntu 16.04 - 0.5.0 openSUSE 42.3 - 0.6.1 CI for Qt 5.13 has: Ubuntu 18.04 - 0.8.0 RHEL-7.4 - 0.7.1 openSUSE 15.0 - 0.8.1 Currently the minimal required libxkbcommon version in src/gui/configure.json is set to 0.5.0, but we could bump it to 0.7.1 to avoid known issues from above, but that is a decision for a separate patch. [ChangeLog][plugins][platforminputcontexts] Now using libxkbcommon-compose APIs for compose key input, instead of Qt's own implementation. Fixes: QTBUG-42181 Fixes: QTBUG-53663 Fixes: QTBUG-48657 Change-Id: I79aafe2bc601293844066e7e5f5eddd3719c6bba Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com> Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* platformsupport/input: add xkbcommon utilities libGatis Paeglis2019-03-011-701/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xcb/eglfs/wayland - all use XKB keyboard configs and APIs. There is a lot of duplicated and naturally a diverging code. This patch adds a helper library to avoid all the mentioned problems and unify feature set between these platforms. qlibinputkeyboard: Added a fixup for 2803cdf758dbae1006a0c50300af12dac9f71531. From spec: "keysyms, when bound to modifiers, affect the rules [..]", meaning we can't look at keys in isolation, but have to check if bounding exists in the keymap. This is done by using xkb_state_mod_name_is_active() API, but that API has its limitations - https://github.com/xkbcommon/libxkbcommon/issues/88 I will fix this separately in the LTS (5.12) branch. We need to read the modifier state before the key action. This patch fixes a regression introduced by aforementioned patch, which caused modifiers being reported wrongly in QKeyEvent::modifiers(). qtwayland: Moved toKeysym(QKeyEvent) from qtwayland repository into this library. For this and other key mapping functionality wayland was duplicating the key table. All of that will be removed from qtwayland, and calls will be replaced to use this lib. Adjusted toKeysym() to fix QTBUG-71301. Qt keys don't map to ASCII codes, so first we need search in our key table, instead of mapping from unicode. lookupStringNoKeysymTransformations(): fixed off-by-one error, where we were including terminating NUL in QString. Fixes: QTBUG-71301 Task-number: QTBUG-65503 Change-Id: Idfddea5b34ad620235dc08c0b9e5a0669111821a Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* xcb: qxcbconnection_basicGatis Paeglis2018-10-171-1/+38
| | | | | | | | | | | | A basic base class that creates a connection and initializes extensions. The goal was to reduce the size of qxcbconnection.h/cpp. Made QXcbAtom into a class that handles atom initialization and exposes the relevant APIs. Before this patch, all of that logic was inside of qxcbconnection.h/cpp. Change-Id: Ia893c3b31e2343dfbe62fe2aa6bfd0017abf46ea Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: lock-free event processingGatis Paeglis2018-10-141-2/+3
| | | | | | | | | | | | | | | | | For details how this works refer to the documentation in the patch. The follow-up patches will switch to calling processXcbEvents() on every event loop iteration. With the existing code that would mean frequent locking of shared data (event queue). Acquiring a lock is fast, but lock contention isn't. To avoid potential problems, reimplement xcb event processing to be lock-free. Besides theoretical performance benefits, this definitally improves code readability in qxcbconnection.cpp. Thanks to Mikhail Svetkin for questioning the design of the existing code. Done-with: Mikhail Svetkin <mikhail.svetkin@qt.io> Change-Id: I935f2b6ca802580f5c80205aef7b2f9afc172d26 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* xcb: Add missing X11/XCB keysyms Undo, Redo, Find, CancelMikhail Svetkin2018-08-161-0/+7
| | | | | | | | It was added 558dd7f58735716d7d1f61fb5323d807b178f0c7 It was missed after 128a6eec065dfe683e6d776183d63908ca02e8fb Change-Id: I99f5c42ea45227bef08092e22d656e2d7d3cf60f Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: rewrite auto-repeat key detection logicGatis Paeglis2018-08-161-88/+20
| | | | | | | | | | | | | | | | | | | | | | | | It's unclear what the original code was doing. It relied on 'm_release' which could never be 'false' (ref. QTBUG-69679). It was subtracting event times and comparing with arbitrary '10'. On X11 auto-repeat keys can be detected by checking time and keycode of the current release event and the next event in the queue. If an event is an auto-repeat, then next event in the queue will be a key press with matching time and keycode. Verified that auto-repeat was unreliable in Qt 4 as well. With this patch auto-repeat works as expected. Added support for Xlib's XPeekEvent in our XCB implementation QXcbConnection::checkEvent(): "The XPeekEvent() function returns the first event from the event queue, but it does not remove the event from the queue." Sneaking in one variable renaming: "string" -> "text", to match the QKeyEvent::text(). Task-number: QTBUG-57335 Task-number: QTBUG-69679 Change-Id: I0a23f138287f57eaaecf1a009bd939e7e0e23269 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: Use functors in QXcbConnection::checkEvent()Gatis Paeglis2018-08-161-5/+1
| | | | | | | | | | | | | | | | | ... to check for buffered events. This makes the code less verbose and easier to read. Changed the filter signature to pass an event type in addition to the actual event, for the convenience of API user. And do not pass worthless nullptr-s to the filter. The only reason why KeyChecker from qxcbkeyboard.cpp was not converted to lambda expression is that the code looks suspicious - KeyChecker::m_release default value is 'true' and I don't see where it would ever be assigned 'false' (ref. QTBUG-69679) and the code is known to be buggy (ref. QTBUG-57335). Those issues are out-of-scope for this patch. Change-Id: If2fdd60fbb93eb983f3c9ad616aaf04834fede9f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
* xcb: Change KeyTbl from pure C array to compile time sorted std::arrayMikhail Svetkin2018-07-281-356/+369
| | | | | | | Allow to use binary search instead of iterate over array Change-Id: Ibcce1a2296e85f51a61fbb5e64e23e5a27464959 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-07-021-0/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_dragging.mm src/plugins/platforms/ios/qiosinputcontext.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/tools/androiddeployqt/main.cpp Was moved from qttools into qtbase in 5.11. So re-apply 32398e4d here. tests/auto/corelib/global/qlogging/test/test.pro tests/auto/corelib/global/qlogging/tst_qlogging.cpp tests/auto/corelib/io/qfile/tst_qfile.cpp tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp tests/auto/corelib/thread/qthreadstorage/test/test.pro tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp tests/auto/widgets/kernel/qapplication/test/test.pro Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Done-with: Mårten Nordheim <marten.nordheim@qt.io> Done-with: Oliver Wolff <oliver.wolff@qt.io> Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
| * Recognize X11/XCB keysyms Undo, Redo, Find, CancelJonathan Marten2018-06-221-0/+7
| | | | | | | | | | | | | | | | | | Convert these keysyms into the corresponding Qt::Key_ enum values, so that they can be part of a QKeySequence and used by applications. Task-number: QTBUG-69062 Change-Id: I6f2e28191dd8dacd63d4bf710e1714fc5dcce75f Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | xcb: Use XCB instead of Xlib for XInputAlexander Volkov2018-03-221-13/+11
|/ | | | | | | | | | | | | | | | | | | | | | | - Replace xinput2 feature by xcb-xinput, which doesn't depend on xcb-xlib - Remove xi2PrepareXIGenericDeviceEvent() that was used to fix incompatibilty between XCB and libXi structs - Drop XCB_USE_XINPUT21 and XCB_USE_XINPUT22 defines that were needed with libXi Although xcb-xinput was released in version 1.13 of libxcb, it was quite stable in version 1.12, and the parts that we use did not change between versions, so require system xcb-xinput 1.12. [ChangeLog][X11] The xcb plugin was ported to use libxcb-xinput instead of libXi for XInput2 support. The -xinput2 configure option was replaced by -xcb-xinput. Task-number: QTBUG-39624 Change-Id: I37475b09b2bd7057763345c3f33d8c7751a4e831 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: simplify handling of keymap updatesGatis Paeglis2018-02-251-36/+34
| | | | | | | The old code was somewhat too scattered. Change-Id: Ib0445c66653f757ccac28778f34f4bcb5df49a70 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: cleanup TODOs for KeyboardLayoutChangeGatis Paeglis2018-02-251-18/+22
| | | | | Change-Id: I5d2207fdb21cbabb04460faf73c35275bc76b7b0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: minor refactoring in QXcbKeyboard::checkForLatinLayout()Gatis Paeglis2018-02-251-6/+6
| | | | | | | We don't need xkb state APIs to check for keys on first level. Change-Id: I728e6bfe09bce127ad8eae78ecee7cefd620f52e Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: remove X11 deps from QXcbKeyboard::checkForLatinLayout/lookupLatinKeysym()Gatis Paeglis2018-02-251-4/+4
| | | | | | | | | | This will allow us to reuse these functions on systems that do not rely on X11, but use libxkbcommon for handling keyboard input. Task-number: QTBUG-65503 Change-Id: I78034238771be96fbb38e8187801fefbee1a5fed Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: have a proper detection of key events originating from SendEventGatis Paeglis2018-02-251-43/+55
| | | | | | | | | | | This is a more correct fix for QTBUG-48795. The original fix was unnecessarily using non-XKB code path for updating state for all incoming key events. This would result in losing some valuable bits from xkb state. Task-number: QTBUG-48795 Change-Id: Ic4fb28b2d834272f1db2cbf5888cafb209707847 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: use keysym defs from xkbcommon, instead of X11 headersGatis Paeglis2018-02-251-590/+322
| | | | | | | | | | | | | | | | xkbcommon-keysyms.h is generated from X11 header files, so it contains all the same values. Removed all of #ifndef XK_* as those keysyms are present in xkbcommon-keysyms.h (checked the header from 0.4.1, the minimal required version). The same for XF86XK_* defines. This will allow to reuse some of this code on platforms that don't depend on X11, for details see QTBUG-65503. Task-number: QTBUG-65503 Change-Id: I68083e11cea1f29d775a6ed46503a06b04b9a05c Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: minor cleanup in QXcbKeyboard::handleKeyEvent()v5.11.0-beta1Gatis Paeglis2018-02-241-15/+23
| | | | | | | | | | - Use smart pointer for handling xkb state. - Make it more clear (in the code and the comment) when a latin keysym is used. Change-Id: Iee8106c72177c22b1a8fe875027b1dda82196b36 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: refactor QXcbKeyboard::keysymToQtKey() and fix bugGatis Paeglis2018-02-241-59/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now also digits from other alphabets e.g ۲ (arabic two) are mapped to Qt::Key_* digit keys. Re-factored logic: - All known dead keys have direct mappings since 1d86e5f84abac6db0b7b1503a6f52c72b272a897. Don't special treat them in "unicode mapping" code path. - Removed the ISO8859-1 legacy logic, which is leftover from Qt4 where keysym to Qt decoding was done from raw data. In Qt5 we always get a utf8 string from xkb_state_key_get_utf8(). Furthermore, ISO8859-1 and utf8 encode ASCII exactly the same way. - Set Qt::KeypadModifier from key input handler methods. This logic does not belong in keysymToQtKey(). Note: KeyTbl[] and keysymToQtKey() have been duplicated in several places in Qt. That stuff will be cleaned up as part of QTBUG-65503. This change will make those cleanups easier. Task-number: QTBUG-58865 Task-number: QTBUG-65503 Change-Id: Iaf10205a26804f7fc03eb8a16a0879f1bd7bf332 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: re-factor QXcbKeyboard::updateKeymap() to remove various fallbacksGatis Paeglis2018-02-241-167/+57
| | | | | | | | | | | | | | | | | | | | | 3edcd9420e3ad661cad89420e18dbb70e7ad450b added more robust support for keyboard input on XKeyboard-less X servers. The various fallbacks that we had did not work that well in practice. We can remove them now. The xkb_keymap_new_from_names() function relies on reading XKB config files from a file system. Since we don't use this function anymore, we can also simplify xkb context creation (see XKB_CONTEXT_NO_DEFAULT_INCLUDES), as we don't care about DFLT_XKB_CONFIG_ROOT (which we previously set via -xkb-config-root for the bundled libxkbcommon). This patch also changes the code to use smart pointers for managing the global xkb context, keymap and state. [ChangeLog][X11] The -xkb-config-root command line switch has been removed as it it no longer needed when configuring with -qt-xkbcommon-x11. Change-Id: I80eecf83adae90af5cd20df434c1fba0358a12fd Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: remove xlib dependency from core keymap assemblingGatis Paeglis2018-02-241-21/+11
| | | | | | | | | | | | | | | Remove the Xlib dependency by extracting XConvertCase from libxkbcommon sources (xkbcommon/src/keysym.c). libxkbcommon >= 0.8.0 exposes case conversion APIs, but we should prefer using the slightly adjusted version (see the patch for more details). This change also is necessary for follow-up cleanups. Change-Id: Icf1716e0ad26f46a7aefb23722cfc57957754d5e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* xcb: remove fragile and unnecessary missing-latin-keymap workaroundGatis Paeglis2018-02-221-46/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... which was trying to fix a rarely occurring situation where system settings from a desktop environment does not set any latin keymap on X. This is a DE bug and it has a simple workaround (details in the patch). Ubuntu has fixed this issue sometime between 12.10 -> 14.04. Gnome 3 always appends 'us' layout, even if you have only e.g. 'gr' listed in keyboard layouts (can be checked via setxkbmap -query). In KDE, the global system shorcuts seem to stop working as soon as latin keymap is not the first in the list, which means that KDE users won't be affected as they will likely always have a latin keymap present in the list. This patch removes parts of 2b666d9576210aa98700e219dba6b1bd4f93d793, the parts that in the commit message I was referring to by this quote: "lookupLatinKeysym() also handles the cases that did not work in Qt4 with XLookupString". Since finding a latin key is not working by XLookupString() in this rare case, then it would not work pretty much across the whole desktop. And users would be more interested at finding a solution that works across the desktop. We should not workaround this issue. Desktops that are doing it wrong should learn about this and not repeat the same mistakes on Wayland systems, where XKB keymap is assembled by compositor and passed to clients. Clients should work with the provided keymap as is. The missing-latin-keymap workaround is considered fragile for several reasons - it might not work with legacy or enterprise X server key codes and it relies on global _XKB_RULES_NAMES (there might be several connected keyboards). And theoretical limitation: client might be running in a restricted environment where we don't have access to keymaps on the file system. Change-Id: Ib445b2ea46174248cfa0e5da0eb642cd2a5cf2f6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add missing dead key symbolsMatt Whitlock2018-01-151-5/+96
| | | | | | | | | | | | | | | Qt was missing symbols for many dead keys defined in <X11/keysymdef.h>. These dead keys were thus ignored by the "compose" input module. This commit adds the missing dead key symbols. [ChangeLog][Linux/XCB] Added missing dead key symbols, enabling their use with the "compose" input module. Task-number: QTBUG-56452 Change-Id: Ib5c37168990c9d9fa99fdd50f63b934c793e8dc4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Matt Whitlock <qt@mattwhitlock.name>
* XCB: Undef KeyPress and KeyRelease also when not using xinput2Ulf Hermann2018-01-081-0/+2
| | | | | | | The defines come from X.h here, which is included via Xutil.h. Change-Id: I19887424cff28567fcbb1c352b42bb9d750b1928 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Support legacy X11 keymapsFrank Richter2018-01-041-3/+317
| | | | | | | | | | | | | | | | | Not all X server vendors support the XKB protocol. Furthermore, while X.org seems to use keycodes that match the usual keyboard scancodes, other vendors may not do so. This means that using an XKB keymap suitable for an X.org server results in garbled input with servers for other vendors. Both of these issues are addressed by using the core keycode information as a fallback. [ChangeLog][X11] Fall back to X11 core keycode information if an XKB keymap could not be determined through the connection. Task-number: QTBUG-44938 Change-Id: I64568aa31113d5a3fd90f70c63320a497db21477 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Refactor QXcbKeyboard::updateModifiers()Frank Richter2017-12-191-26/+90
| | | | | | | | | | | The current implementation is poorly documented and hides the mapping between keysyms and modifier bits. This changeset adds documentation about the inner workings and makes the keysym/modifier bit mapping reusable. (The latter will be needed for xkb keymap synthesis if the XKEYBOARD extension is unavailable.) Change-Id: I70c6d204b2357365db4dafeda680132ab6823ca3 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: use XInput2 for mouse starting from 2.0 not 2.2Gatis Paeglis2017-08-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 53d289ec4c0f512a3475da4bbf1f940cd6838ac fixed the issue of not getting touch events when grabbing via the plain xcb functions. And due to wanting to support a setup where mouse events are delivered via core events it was chosen to use mouse via XI2 only when really necessary. Thus starting only from 2.2, the version from which the mouse+touch grabbing becomes the issue (XI2 introduced touch support from 2.2). The same patch states that using QT_XCB_NO_XI2_MOUSE restores to the old behavior (grabbing via core) with broken touch grabbing. Broken only with 2.2+, not 2.0 and 2.1 since those versions of protocol do not know about touch. All of this implies the following: 1) The user code that already depends on QT_XCB_NO_XI2_MOUSE, won't see any behavioural difference if we will use XInput starting from 2.0 for mouse. Mouse grabbing will continue to be done via core (xcb_grab_pointer) as mentioned above and thus touch grabbing will continue to be broken with 2.2+. 2) The code that has never cared how we get the native events (core vs xinput2), won't see any behavioural difference. In this case grabbing will always be done via XI2 (XIGrabDevice) grab when XI2.0+ is available. Since there is no difference in the outcome, we migth as well use XI2 for mouse from 2.0, not 2.2. Extension events are always better choice than core. Besides the broken touch grabbing issue with QT_XCB_NO_XI2_MOUSE, there are other issues with that code path, for details see internal documentation of xi2SelectDeviceEventsCompatibility(), where the conclusion is: *** If your code relies on QT_XCB_NO_XI2_MOUSE, then your code needs fixing. *** This patch also cleans up how we select XInput2 events, by separating the QT_XCB_NO_XI2_MOUSE code path. This has two benefits - improved code readability and will make the deprecation of QT_XCB_NO_XI2_MOUSE easier. The patch removes some sparse comments as the behavior is now documented in one place, see xi2SelectDeviceEventsCompatibility(). [ChangeLog][Platform Specific Changes][Linux] The QT_XCB_NO_XI2_MOUSE environment variable is deprecated and will be removed in Qt 6. If your application relies on behavior set by QT_XCB_NO_XI2_MOUSE, it should be updated accordingly. [ChangeLog][Platform Specific Changes][Linux] Pointer event delivery on X11 is now done starting from XInput version 2.0 (when available) instead of 2.2. XInput support can be disabled by setting QT_XCB_NO_XI2=1 environment variable. Note that using QT_XCB_NO_XI2 would also disable tablet and touch support. Change-Id: I661b36d6710b9f6ec71fecc8287ba479432bff4c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: remove x11FilterEvent() code pathGatis Paeglis2017-04-071-34/+2
| | | | | | | | | | | | | | | This is a legacy code that was there to support IM plugins using the Qt4's QInputContext::x11FilterEvent. Updating IM plugins to the new API is a trivial task, external plugins have had enough time to switch to the new API QInputContext::filterEvent(). The 'fcitx' plugin did the required changes in Oct 2014. AFAIK this was the only remaining plugin that still used x11FilterEvent. Change-Id: I7702bcd7017d2d24a1ed07fdebac8b61ca178161 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* xcb: remove code and macros related to Q_XCB_DEBUGGatis Paeglis2017-03-101-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ... early spring-cleaning, leaving one block of virtual root debug code that was inappropriately conditioned on Q_XCB_DEBUG; it now gets its own define. Removed Q_XCB_CALL: 1) I don't know anyone who actually uses it. 2) Enabling this feature (via Q_XCB_DEBUG) fails to build (and has been like that for about 1 year). 3) There are better ways to debug X11 client message exchange (see xtrace for example). 4) Using Q_XCB_CALL is a very fragile approach. Grep for example for xcb_change_property and you will see that half of the calls are not wrapped with the Q_XCB_CALL macro. This patch also removes the Q_XCB_NOOP macro. It's unclear what its purpose was. There was a TODO comment in qxcbeglcontext.h suggesting removal of this macro as well. Its evaluation of its parameter, even without Q_XCB_DEBUG, had no side-effects, so its removal should be harmless. Change-Id: I9fa48af454061d8b38f69f308131647cd18f85f4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: Wrap xcb callings in macrosAlexander Volkov2017-02-231-39/+17
| | | | | | | | | | | | | | | | | ... to improve readability and reliability. This change introduces macros Q_XCB_REPLY and Q_XCB_REPLY_UNCHECKED that allow to replace couples of xcb cookie/reply callings by a single "calling" of a macro. The macros wrap the reply in std::unique_ptr thus preventing the need to free it manually. The following C++11 features are used: - variadic macros - std::unique_ptr - auto type deduction Change-Id: Icf9b93353404a39bf5f4a4562b9234db18cac696 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* XCB: Use member initializationFriedemann Kleint2017-01-271-6/+0
| | | | | | | Shorten or remove constructors accordingly. Change-Id: I9c8bcf512c922c3c72be8a965d9557589bc9874f Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-221-28/+44
|\ | | | | | | | | | | | | Conflicts: src/plugins/platforms/ios/qiosviewcontroller.mm Change-Id: I2dda31867cbc79ea7fe965f52afb518aefa4ad20
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-211-28/+44
| |\ | | | | | | | | | Change-Id: I9cfefaf22b010fca937be77979f5fb50574bb71e
| | * xcb: Use the state of the key event to process itAlbert Astals Cid2016-09-181-28/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of the global state Task-number: QTBUG-48795 Change-Id: Ic2c545718adb68df41730e5a3bf25adb374ffce3 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-211-3/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5971b88e is not needed in new configure. This merge also reverts "fix QMAKE_DEFAULT_*DIRS resolution with apple SDK", 2c9d15d7, because it breaks iOS build with new configure system. Conflicts: mkspecs/features/default_pre.prf mkspecs/features/mac/toolchain.prf mkspecs/features/toolchain.prf src/dbus/qdbusconnection.cpp src/plugins/sqldrivers/mysql/qsql_mysql.cpp src/sql/drivers/mysql/qsql_mysql.cpp src/widgets/widgets/qmenubar.cpp src/widgets/widgets/qmenubar_p.h tools/configure/configureapp.cpp tools/configure/environment.cpp tools/configure/environment.h Change-Id: I995533dd334211ebd25912db05b639d6f908aaec
| * | xcb: Do not eat events with different keyboard stateAlbert Astals Cid2016-09-181-3/+5
| | | | | | | | | | | | | | | | | | Change-Id: Iac8dc7b369eb7c2fbe0cf27baa34a40278088219 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | | Rework privateFeatureLars Knoll2016-08-191-6/+6
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | privateFeature would add QT_NO_FEATURE to the DEFINES in the private .pri file, which was somewhat inelegant. Additionally, it would add the feature to the _public_ QT_CONFIG variable, which was plain wrong. Replace the implementation with the one just introduced for publicFeature, with the difference that the features are written to the private files instead. As this entirely disposes of the old system, all usages in the project files need to be replaced atomically as well. Change-Id: I506b5d41054410659ea503bc6901736cd5edec6e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Edward Welbourne2016-07-041-2/+13
|\| | | | | | | Change-Id: Ibd81cd1df4a0650d93fcb556a57be90be2e1f569
| * Fix shortcut handling for level three and above shortcutsBernhard Scheirle2016-06-301-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling `xkb_state_update_mask` with correctly set `depressed_mods` allows xkb to return keys on level three or above (and not the equivalent level one key). To preserve level two shortcuts (return equivalent level one key) `depressed_mods` gets only set, if the pressed key is on level three or above. Example shortcuts which now will work: Shortcut German Layout (de) [AltGr is a level three switch] Ctrl+@ Ctrl+AltGr+Q Shift+1 Shift+1 (as before) Shortcut German Neo Layout (de neo) [1] [AltGr is a level five switch] Left AltGr+S [1] http://neo-layout.org Task-number: QTBUG-53121 Change-Id: I637a01edc9f2f92a5d3e7a24f5051fb1d3ac2f7f Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>