summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement XCB key mapper in terms of QPlatformKeyMapperTor Arne Vestbø2023-10-091-1/+0
| | | | | Change-Id: I81af1200b7b1113062d66a76a185a6d15eab0ba9 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Mark all remaining RAII/smart pointer class ctors [[nodiscard]]Marc Mutz2023-06-221-1/+1
| | | | | | | | | | | | | | | | | | | ... like QUIP-0019 suggests. The main problem here is finding these classes. We don't have markup for RAII classes, so I had to find them by name. This patch is based on the output of git grep -we Q[A-Z0-9a-z_]+er extracting the matches and piping them through sort -u, then removing a lot of suffixes like Manager and Handler, then visually inspecting the remaining list. Task-number: QTBUG-104164 Pick-to: 6.6 Change-Id: I59b18d8d0a0237fcc11047857adc39b984ad7fcb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* xcb: set _NET_STARTUP_ID at client leader windowIlya Fedin2022-09-021-3/+2
| | | | | | | | | | This should help to overcome WM's focus prevention mechanism Fixes: QTBUG-96276 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ic5fb46f7ce54f0df29850725bafa364b74e30d25 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Liang Qi <liang.qi@qt.io>
* xcb: create fake screen when XRandR 1.2 and later unavailableLiang Qi2022-05-201-0/+1
| | | | | | | | | Keep the old behavior from 6.0 to 6.2. Fixes: QTBUG-102637 Pick-to: 6.3 Change-Id: I2e596c7d5161a3dc7a8493358e272a481aee5308 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: only set primary for monitor on primary X screenLiang Qi2022-05-201-2/+2
| | | | | | | | | | | | | It's possible to have multiple X screens, and a primary monitor on each X screen. We should only use one on primary X screen as primary QScreen. The reference of QXcbScreen pointer should be used correctly. Fixes: QTBUG-102758 Pick-to: 6.3 Change-Id: I1eafd509c8c109606967a4abe9ad7e9d8c0dd464 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>
* XCB: fix leaked QXcbScrollingDevicePrivateLiang Qi2022-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | ==1585319== 1,112 (720 direct, 392 indirect) bytes in 2 blocks are definitely lost in loss record 110 of 123 ==1585319== at 0x483EF2F: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==1585319== by 0x7D01D6C: QXcbConnection::xi2SetupSlavePointerDevice(void*, bool, QPointingDevice*)::{lambda()#1}::operator()() const (qxcbconnection_xi2.cpp:262) ==1585319== by 0x7D025C2: QXcbConnection::xi2SetupSlavePointerDevice(void*, bool, QPointingDevice*) (qxcbconnection_xi2.cpp:316) ==1585319== by 0x7D03D2D: QXcbConnection::xi2SetupDevices() (qxcbconnection_xi2.cpp:499) ==1585319== by 0x7CE81A3: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (qxcbconnection.cpp:105) ==1585319== by 0x7D27BEA: QXcbIntegration::QXcbIntegration(QList<QString> const&, int&, char**) (qxcbintegration.cpp:199) ==1585319== by 0x7C9D282: QXcbIntegrationPlugin::create(QString const&, QList<QString> const&, int&, char**) (qxcbmain.cpp:56) ==1585319== by 0x4B516DE: QPlatformIntegration* qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin, QList<QString> const&, int&, char**&>(QFactoryLoader const*, QString const&, QList<QString> const&, int&, char**&) (qfactoryloader_p.h:108) ==1585319== by 0x4B512A9: QPlatformIntegrationFactory::create(QString const&, QList<QString> const&, int&, char**, QString const&) (qplatformintegrationfactory.cpp:71) ==1585319== by 0x4B074EC: init_platform(QString const&, QString const&, QString const&, int&, char**) (qguiapplication.cpp:1209) ==1585319== by 0x4B0A646: QGuiApplicationPrivate::createPlatformIntegration() (qguiapplication.cpp:1491) ==1585319== by 0x4B0A7C9: QGuiApplicationPrivate::createEventDispatcher() (qguiapplication.cpp:1508) ==1585319== by 0x568853F: QCoreApplicationPrivate::init() (qcoreapplication.cpp:847) ==1585319== by 0x4B0A89F: QGuiApplicationPrivate::init() (qguiapplication.cpp:1532) ==1585319== by 0x4B05D16: QGuiApplication::QGuiApplication(int&, char**, int) (qguiapplication.cpp:653) ==1585319== by 0x451613: main (tst_qmetatype.cpp:2141) Fixes: QTBUG-95468 Pick-to: 6.3 6.2 Change-Id: I7e0b82c2d2fe464082d8fffd1696c0122c3b35b7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: Implement support for touchpad gesturesPovilas Kanapickas2021-11-151-0/+6
| | | | | | | | | | | | | | | | | | | | They map to the data exposed by libinput exactly the same way as touchpad gestures on Wayland. The implementation is functionally the same and follows the same patterns to preserve similar behavior across X11 and Wayland. For example, we use the last known pointer position as the position for gestures, even though on X11 this data is available as part of events. The new implementation is only enabled if the used xcb supports the required APIs. [ChangeLog][Platform Specific Changes][X11] Touchpads can now detect multi-finger gestures and send RotateNativeGesture, ZoomNativeGesture and PanNativeGesture events, since XInput 2.4 and X Server 21.1. Change-Id: If404dcf8385210deadeb7e7c6d29171e9abc9e50 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: remove confusing indirections for qt selection ownerGatis Paeglis2021-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | This makes it more obvious that clipboard and DnD use the same selection owner (QXcbConnection::qtSelectionOwner()). This way we can also drop some QT_NO_CLIPBOARD defines. These defines actually are broken, but that is out-of-scope for this patch. And renamed the functions according to Qt guidelines: getSelectionOwner() -> selectionOwner() getQtSelectionOwner() -> qtSelectionOwner() The previous naming probably was influenced by underlying C API - xcb_get_selection_owner(). Change-Id: I467f1a3dbe75b4e8fd41c7e66ca9b0e25ef1039c Reviewed-by: Liang Qi <liang.qi@qt.io>
* xcb: support xrandr(1.5) monitor setupLiang Qi2021-09-011-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | More information about monitor in xrandr 1.5, see https://keithp.com/blogs/MST-monitors/ Since this change, screen is logical instead of physical. If xrandr 1.5 and later is installed, Qt screen info will get from xrandr monitor object instead of xrandr output if only have 1.2 to 1.4. Users can manipulate monitor as they want, for example, a combination for two physical screens, half of one screen and etc. Didn't have chance to access MST monitors, but it should work if xrandr monitor object was created automatically. [ChangeLog][xcb] Qt screen info will get from xrandr monitor object if 1.5 is installed. Fixes: QTBUG-65457 Change-Id: Iad339cc0d4293b2403b4ef6bf6eb770feb3e685f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: fix QWindow::startSystemMove()/Resize() triggered by touchLiang Qi2021-06-161-3/+1
| | | | | | | | | | Abort the system move/resise at XCB_INPUT_TOUCH_END. Limit the behavior only on supported platforms, such as KDE and OpenBox. Change-Id: I53c86979ca56f4de8c5cf2807f781abdad6987b2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: fix QWindow::startSystemMove()/Resize() triggered by mouseLiang Qi2021-06-161-2/+8
| | | | | | | | | | | | | | | | We can't get mouse release event from master pointers after QXcbWindow::doStartSystemMoveResize() which calls xcb_ungrab_pointer(), it looks like most X11 WMs work as that. So we try to get mouse release event from slave pointers. Based on https://specifications.freedesktop.org/wm-spec/1.4/ar01s04.html , we need to send _NET_WM_MOVERESIZE_CANCEL when we get mouse release event. Task-number: QTBUG-91077 Change-Id: I01e74a01c87b381ee7cd6f20d51a1fa61c0e98fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: use QXcbScrollingDevice for a touchpadShawn Rutledge2021-03-081-1/+2
| | | | | | | | | | | | | When using XQuartz on macOS, the virtual pointer device is detected as a touchpad, not a mouse; but QXcbConnection::xi2HandleScrollEvent() expects the device to be an instance of QXcbScrollingDevice for storage of some state. A touchpad that has the scrolling capability must be that type, not a plain QPointingDevice. Fixes: QTBUG-91402 Pick-to: 6.1 Change-Id: I1b82766d4a3f87f656e56c0d8904def26fb0979a Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix out-of-bounds writePaul Olav Tvete2020-12-231-3/+3
| | | | | | | | | | | | | Change ac210c73e4 introduced the requirement that all input devices with Scroll capability must have a QXcbScrollingDevicePrivate as their d_ptr. However, this was not enforced, and would fail for the "Virtual core pointer". To fix this, always use qobject_cast to verify that the device is of the correct type. Change-Id: I4a6b1d4d79308eb04e9f52dda00294fffe377bdf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* xcb: report wheel events from the correct device instanceShawn Rutledge2020-12-151-17/+6
| | | | | | | | | | | | | | | | | Until now, all wheel events came from one "core pointer". It's useful in Qt Quick to tell the devices apart, because some support smooth scrolling and some don't. Also remove the QHash storing legacy ScrollingDevice structs, and use a subclass of QPointingDevicePrivate instead. Task-number: QTBUG-46412 Task-number: QTBUG-72167 Task-number: QTBUG-69433 Change-Id: Ie6a3d8dd494f981e8706b9a66a1021dfb51baec4 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* xcb: remove QT_XCB_NO_XI2_MOUSE code pathGatis Paeglis2020-08-231-2/+1
| | | | | | | | | | | | | | | This code path was deprecated in 5.12 and scheduled for removal in Qt 6. See 9184384bc9d9d71a146fff535021357258a0295e. According to the source comments from f48170b479df359f47af12b03a501d9d0c386e66, apperantly XInput2 had some issues when running on Xinerama screens and therefore there was a check for it in xi2MouseEventsDisabled(). We plan to remove Xinerama support, therefore Xinerama handling in xi2MouseEventsDisabled() is irrelevant. Task-number: QTBUG-69412 Change-Id: I384d7c46337358caecccf644acc8ffbd381dc69d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use QList instead of QVector in pluginsJarek Kobus2020-07-061-4/+3
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic86f4a3000592a1c9ae62e4a83f4fe39832a6b24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Introduce QInputDevice hierarchy; replace QTouchDeviceShawn Rutledge2020-06-161-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have seen during the Qt 5 series that QMouseEvent::source() does not provide enough information: if it is synthesized, it could have come from any device for which mouse events are synthesized, not only from a touchscreen. By providing in every QInputEvent as complete information about the actual source device as possible, we will enable very fine-tuned behavior in the object that handles each event. Further, we would like to support multiple keyboards, pointing devices, and named groups of devices that are known as "seats" in Wayland. In Qt 5, QPA plugins registered each touchscreen as it was discovered. Now we extend this pattern to all input devices. This new requirement can be implemented gradually; for now, if a QTWSI input event is received wtihout a device pointer, a default "core" device will be created on-the-fly, and a warning emitted. In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when multiple devices were in use simultaneously. Now that each event identifies the device it came from, this hack is no longer needed. A stub of the new QPointerEvent is added; it will be developed further in subsequent patches. [ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer to an instance of QInputDevice, or the subclass QPointingDevice in case of mouse, touch and tablet events. Each platform plugin is expected to create the device instances, register them, and provide valid pointers with all input events. If this is not done, warnings are emitted and default devices are created as necessary. When the device has accurate information, it provides the opportunity to fine-tune behavior depending on device type and capabilities: for example if a QMouseEvent is synthesized from a touchscreen, the recipient can see which touchscreen it came from. Each device also has a seatName to distinguish users on multi-user windowing systems. Touchpoint IDs are no longer unique on their own, but the combination of ID and device is. Fixes: QTBUG-46412 Fixes: QTBUG-72167 Task-number: QTBUG-69433 Task-number: QTBUG-52430 Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add QWindow::startSystemMove and startSystemResizeJohan Klokkhammer Helsing2020-01-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be used to create custom client side window decorations. Refactors the xcb implementation to use edges instead of corners and we now use the last mouse position for `root_x` and `root_y` in the `_NET_WM_MOVERESIZE` event. Touch has also been changed, so just pick a point that's currently being pressed. The workaround for QTBUG-69716 has now been moved to QSizeGrip, as the comment in the bug report says that it should ideally be fixed at the widget level. On Windows, we no longer abort when GetSystemMenu returns false. I assume this code was added to check whether the window didn't have any decorations and not resize in that case. However, since the point of this patch is to let windows without native decorations resize/move, it makes most sense to remove the check. Adds a manual test, which calls QWindow::startSystemMove and startSystemResize on touch and mouse events. [ChangeLog][QtGui] Added API for starting interactive window resize and move operations handled by the system. Fixes: QTBUG-73011 Change-Id: I7e47a0b2cff182af71d3d479d6e3746f08ea30aa Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-1/+1
| | | | | | | | | | | 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>
* Deprecate constructing QFlags from a pointerAllan Sandfeld Jensen2019-11-201-4/+4
| | | | | | | | | This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 3rdparty: remove xcb libs and bump minimal required version to 1.11Gatis Paeglis2019-08-271-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-03-161-2/+4
|\ | | | | | | Change-Id: Ief0a0b754c104d5348fee9ee15e967bd37c526f8
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-151-2/+4
| |\ | | | | | | | | | Change-Id: I2bf3b4ceb79364330eae4cbf3cdee9a82d1be46d
| | * XCB: Fix clipboard breaking when timer wraps after 50 daysLukáš Turek2019-03-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xcb_timestamp_t is a 32-bit unsigned value in miliseconds, so it wraps after 49.7 days. When it happens, QXcbConnection::m_time stops updating and copy & paste in an application would not work until the application is restarted. This patch detects the timer wrap and allows m_time to wrap too. The fix was verified in KDE desktop with applications running for 51 days. Fixes: QTBUG-65145 Change-Id: I328c4179c1b1f71914adda6f9a0ca3991a7e808e Reviewed-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | | More nullptr usage in headersKevin Funk2019-03-141-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | xcb: respect big-request encoding in max request sizeGatis Paeglis2019-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From big-request specification: "This extension defines a mechanism for extending the length field beyond 16 bits. If the normal 16-bit length field of the protocol request is zero, then an additional 32-bit field containing the actual length (in 4-byte units) is inserted into the request, immediately following the 16-bit length field." Meaning that the request requires 4 additional bytes. This patch provides a convenience API for calculating maximum request data size. Besides fixing QTBUG-73044, it was also discovered that calculations for xcb_image_put (in QXcbBackingStoreImage::flushPixmap) were wrong. The code assumed that xcb_get_maximum_request_length() returns bytes, but what it actually returns is length which is measured in four-byte units. This means that we were sending 4x less bytes than allowed by the protocol. Furthermore, use the actual 'stride' (bytes per line) value when calculating rows_per_put. The new stride value was introduced by 760b2929a3b268e2edf14a561329bdb78fbdc26e, but was not updated in rows_per_put calculations. Fixes: QTBUG-73044 Done-with: JiDe Zhang <zccrs@live.com> Done-with: Mikhail Svetkin <mikhail.svetkin@qt.io> Change-Id: I06beb6082da3e8bc78225a87603914e796fe5878 Reviewed-by: Błażej Szczygieł <spaz16@wp.pl> Reviewed-by: JiDe Zhang <zccrs@live.com> Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | xcb: rework focus-in peeker so we can drop PeekFunc APIGatis Paeglis2019-01-041-5/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The API for registering temporary peek function was added ~7 years ago by 78264f333eb7c262380714ed6517562266f11a03. It was never been used for anything else. The solution from 78264f333 also did not work very well on KDE desktop, quoting Martin Flöser: "In case the keyboard gets grabbed by another process and immediately ungrabbed the active Qt application window receives a FocusOut and a FocusIn event. FocusOut on the grab of keyboard, FocusIn on the ungrab. Qt registers a peek function for checking the FocusIn event, but the timespan is too short: the new event is not yet queued. This causes a QEvent::WindowDeactivate being emitted, followed directly by a QEvent::WindowActivate. This has quite some side effects, for example rendering flickering in the GUI (switching to inactive/active in short time frame), hooks on WindowDeactivate being run, etc. Real world examples for such short keyboard grabs are global shortcut listener applications like kglobalaccel5. It has e.g. a passive key grab on the mute key, which is then turned into an active grab when the key is grabbed. Kglobalaccel5 immediately ungrabs the keyboard and flushes the connection if it gets a key event, but it of course causes the sequence of FocusOut and FocusIn events in the active Qt window." Reworked the code to use QTimer instead, which is more elegant solution, because it does not rely on race-conditions, but uses a concreate time to wait instead. Also the need to write focusInPeeker() caused us to duplicate event handlers that were present already elsewhere. Change-Id: I647e52fb2634fdf55a640e19b13265c356f96c95 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: move clipboard code out of QXcbConnection::processXcbEventsGatis Paeglis2018-10-311-0/+1
| | | | | | | | | | ... to QXcbConnection::handleXcbEvent(), which is where it belongs. This patch amends bc6f5b3ff61f4b1dea14084349702f2895feda66 (Sep, 2013). And some other design cleanups. Change-Id: Iefa0793c58de16a59d2294f38311e1e8dfa3035b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: fix unresponsive mouse clicks after VT switchGatis Paeglis2018-10-251-1/+1
| | | | | | | | | | | | | | This patch amends d67214302f269242ae3d8d2b962fd91ec42c979e. The issue was caused by mistakenly interchanging m_hasXRender <-> m_hasXRandr. Also renamed selectXRandrEvents() -> xrandrSelectEvents() to be more consistent with xi2Select*() API. And moved the xrandrSelectEvents() to QXcbConnection ctor for the same reason. Fixes: QTBUG-71305 Change-Id: I26f9bac3ae1f997f53134eb97f3569fb6d3c13fe Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: qxcbconnection_screensGatis Paeglis2018-10-171-10/+9
| | | | | | | | | | Moved all screen handling method implementations into qxcbconnection_screens, the same way we are doing with xinput2 code in qxcbconnection_xi.cpp. The goal was to reduce the size of qxcbconnection.h/cpp. Change-Id: I9bad55ca4b0874171b7313d923b13c66034c3b3e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: qxcbconnection_basicGatis Paeglis2018-10-171-320/+9
| | | | | | | | | | | | 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: respect QEventLoop::ExcludeUserInputEvents in native event handlersGatis Paeglis2018-10-161-1/+3
| | | | | | | | | | | | | | | | | This was a regression from Qt 4. Before this patch, we supported filtering events only at QWindowSystemInterface level, but to properly support filtering in QAbstractEventDispatcher::filterNativeEvent, we have to filter the events earlier. Now it is possible to enable/disable this feature for platforms that support native event filtering. The mapping of which events are user input events were taken from QWindowSystemInterfacePrivate::EventType. Task-number: QTBUG-69687 Change-Id: I9a5fb9f999451c47abcdc83fdcc129b5eeb55447 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: call processXcbEvents() on every event loop iterationGatis Paeglis2018-10-151-2/+1
| | | | | | | | | | | | | | | | | | It is necessary for QTBUG-69687. The original code processes the xcb event queue only when new events have arrived, but if we want to do an event filtering that buffers some events and processes them later based on set/unset flags (e.g. QEventLoop::ExcludeUserInputEvents), we need to call processXcbEvents() on every event loop iteration, not only when new events have arrived from X server. The required functionality is implemented by having custom event dispatchers, instead of using the generic ones from QtGenericUnixDispatcher:: createUnixEventDispatcher() / eventdispatcher_support-private. This also enables for further customizations, as might be necessary by QTBUG-70095. Task-number: QTBUG-69687 Change-Id: I1f8b2400d26cccf17279d57bb4b678e40c615f33 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: lock-free event processingGatis Paeglis2018-10-141-76/+9
| | | | | | | | | | | | | | | | | 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>
* Revert "XCB: Do not create instance of QPlatformIntegration for invalid ↵Gatis Paeglis2018-10-141-12/+5
| | | | | | | | | | | | | | | displays" This reverts commit 67cc8fea106c35c7ca75bf476667d07b3bbf3257. I forgot about this patch and now it makes rebasing the local changes too time-consuming. Besides, 67cc8fea10 broke a build for -no-xcb-xlib. I will restore this patch, with adaptations to the new QXcb*Connection hierarchy. Task-number: QTBUG-68859 Change-Id: I938f32b5da22ce18f95d761f9b34e77fff923e24 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: remove runtime check for xcb_poll_for_queued_eventGatis Paeglis2018-10-121-5/+0
| | | | | | | | | | | | | | | xcb_poll_for_queued_event() was introduced in libxcb 1.8. The minimal required libxcb version was bumped up to 1.9 in 1f5d791708d5d256a76872f254251dac66e82cdb. Before this version bump we needed the runtime check to support older versions of libxcb. Updated connections in the event reader to use the new signal and slot syntax. Removed threadedEventHandling() method because now it is always 'true'. Change-Id: I0bce61fd478a871d35e676239ee5280c4f40be8a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* xcb: Initialize OpenGL integration only when requiredAlexander Volkov2018-09-291-2/+3
| | | | | | | | | | | In some cases OpenGL integration may be unnecessary, e.g. an application may set Qt::AA_ForceRasterWidgets attribute and don't use OpenGL in any other way. In addition OpenGL initialization can take noticeable time on some configurations. So do it on demand only. Change-Id: If88953f8d5c826bc96fd49eb397b5e1ad693546d Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-09-141-0/+2
|\ | | | | | | Change-Id: Ic4c1a8041dcfd143861c39e0014fbdaaa3fb25c6
| * Fix XCB on endian mismatched client and server with SHM offAllan Sandfeld Jensen2018-09-121-0/+2
| | | | | | | | | | | | | | If SHM is disabled, that code path already does its own bswaping. Change-Id: I6c17f6c5c5502c8f89098d38d931b6b8f50b2640 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge dev into 5.12Oswald Buddenhagen2018-08-211-9/+15
|\ \ | | | | | | | | | Change-Id: I63f632b595f66d2fc93e9aa713500e3799e3df2a
| * | xcb: avoid unnecessary InternAtom requestsGatis Paeglis2018-08-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QXcbConnection::internAtom() creates the atom if it does not exist. The lifetime of an atom is not tied to the interning client. Atoms remain defined until server reset (lost connection, restart). So create the atom once via QXcbConnection::initializeAllAtoms(), and later fetch the atom value from local array, instead of repeating InternAtom requests. Change-Id: I3cae21895febad6e5daf8c32e72612202baaad64 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
| * | xcb: cleanup QXcbConnection::handleXcbEvent()Gatis Paeglis2018-08-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - the usage of 'handled' variable was a mess. - remove "generic" from API names. The naming was probably influenced too much from underlying C API (xcb_generic_event_t): - handleGenericEvent() -> handleNativeEvent() to be consistent with QWindow::nativeEvent(). - dropped unnecessary 'long *result' from signature. It is useful only on MS Windows. - genericEventFilterType() -> nativeEventType(), it *is* an event type, not a filter type. - XCB_CLIENT_MESSAGE was not passed to QWindow::nativeEvent(), which is done via HANDLE_PLATFORM_WINDOW_EVENT. - minor: added some 'auto's where it makes sense and improved some variable names. Change-Id: Id1c9896054e2dbd9a79bacd88394149c8cf2cdea Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
| * | xcb: rewrite auto-repeat key detection logicGatis Paeglis2018-08-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... 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: Do not create instance of QPlatformIntegration for invalid displaysFriedemann Kleint2018-08-201-5/+12
|/ / | | | | | | | | | | | | | | | | Extract a static factory for QXcbConnection objects and pass potential connection errors to qxcbmain.cpp, which will then return 0. Task-number: QTBUG-68859 Change-Id: I9c0faf82462a78a576360c19bef251ad1d034d84 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-071-1/+0
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/corelib/doc/src/objectmodel/signalsandslots.qdoc src/plugins/platforms/cocoa/qcocoamenuloader.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp tests/auto/gui/image/qimage/tst_qimage.cpp Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I9bd24ee9b00d4f26c8f344ce3970aa6e93935ff5
| * xcb: partly revert 3bc0f1724ae49c2fd7e6d7bcb650350d20d12246Gatis Paeglis2018-08-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After trying to fix (work around) system resize/move issues in various ways from within the platform plugin, it has been concluded that it is a bug at widget layer and should be fixed there instead: QTBUG-69716. This patch reverts parts of 3bc0f1724a and disables system move / resize on XCB plugin. Meaning, QSizeGrip will use its own implementation for resizing a window. Task-number: QTBUG-68501 Task-number: QTBUG-69628 Change-Id: Ib4744a93fb3e3c20f690a8f43713103856cb7d1a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Merge branch '5.11' into devEdward Welbourne2018-07-311-0/+7
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/library/qmakebuiltins.cpp src/plugins/platforms/windows/qwindowstabletsupport.h src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/widgets/styles/qstylesheetstyle.cpp tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp Done-With: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I000b0eb3cea2a5c7a99b95732bfdd41507cf916e