summaryrefslogtreecommitdiff
path: root/src/client/qwaylandwindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Apply only valid min/max sizesInho Lee2023-05-091-3/+9
| | | | | | | | | | | | | | | When setting min/max sizes, the minimum size can be larger than the maximum size. In that case, the size hint won't be applied to the geometry. Setting size hint will be pending until the min/max pair is valid and the actual geometry will not be changed with the invalid size hint. Fixes: QTBUG-113233 Change-Id: Ia05944e8342e7f8d794aee7883e0637a4c711c9d Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 42128ec10e2365b5235a80ebc0bb429402b8f95f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QWaylandWindow: Init parent wl_surface when creating subsurfaceDavid Rosca2023-04-191-0/+2
| | | | | | | | | | Fixes recreating subsurfaces after hiding and then again showing the window. Change-Id: I2e3e7ceb42ec6b25cb64db260dfb74f6ebb10d27 Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit d06d66fad70d7c61559211b6f489b94d1c3a8a05) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Client: Fix wl_surface destruction orderVlad Zahorodnii2023-03-201-6/+6
| | | | | | | | | | | | | | | The main thread can attempt to close the window while the QtQuick render thread is still busy. If that happens, ensure that QtQuick render thread has finished rendering and presented the last frame before destroying the wp_viewport and any other associated surface extensions so the window destruction looks more reasonable. Change-Id: I8d2a3372fe6de51f357eed513baaa34a148470e3 Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 504b9f1491d7244d05bee243bacf03aa9df1a17c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* client: Unify margins handlingIlya Fedin2023-02-281-25/+12
| | | | | | | | | | | | | | | | | | | | | | | Currently all the shell integrations except of xdg-shell pass full surface size to resizeFromApplyConfigure. xdg-shell behavior is not even consistent between the first and the consequent calls to resizeFromApplyConfigure. This replaces QWaylandWindow::customMargins with QWaylandWindow::windowContentMargins in order to being able to retrieve set_window_geometry margins separately from the geometry itself and makes xdg-shell passing the geometry consistently as full surface size removing the need in special casing. This also makes QWaylandWindow::clientSizeMargins public so e.g. xdg-shell can compute out absolute position for window content geometry without special casing decorations Change-Id: I1b98afc8b5c867ecb7cc586267b13f7ec4b1a88c Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit ae026d6ac7b7910b9f3934a1df2b69d3fce344bc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix automoc warning regarding includeMårten Nordheim2023-02-211-1/+1
| | | | | | | | | | | | There's no Q_OBJECT etc. in the .cpp file, so likely it was removed, or it was intended to include the moc file for the sake of the header. But moc-file for the header has another naming scheme. Change-Id: If1202537a40d746e263fd6e6f67e316a2cdb109e Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit a328e2c5e0594ff476a9df2fcdc3b03894ff7a15) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Client: Provide support for custom shellsVlad Zahorodnii2022-12-081-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, an application can use only one shell surface protocol at a time. However, there are applications that need to use more than one shell surface protocol, e.g. xdg-shell + layer-shell. layer-shell can be used for the desktop background window, and xdg-shell for popups, etc. This change introduces an API in QWaylandWindow that allows specifying the shell integration per window. Custom shell code needs to call QWaylandWindow::setShellIntegration() while the window is unmapped. By default, QWaylandWindow will use QWaylandDisplay's shell integration plugin. This change should be source compatible with existing shell integration plugins deployed in the wild. If the custom shell wants to track additional state for the window, it should do it using its own means. Perhaps we could improve this in the future releases of Qt. [ChangeLog][QtWaylandClient] It is possible to run Qt applications using more than one shell surface protocol, e.g. xdg-shell + layer-shell. Change-Id: Id0458b32af623f114c06d51d0d21ad06efd69328 Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* client: Implement QNativeInterface::Private::QWaylandWindowDavid Redondo2022-12-081-0/+14
| | | | | | | Task-number: QTBUG-94729 Change-Id: Ib79f3199a4518700aa032c5ca4760a2b53c401e5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Implement fractional_scale_v1 and wp_viewportDavid Edmundson2022-12-071-6/+55
| | | | | | | | | | | | | This allows compositors to hint a non-integer scale to use on a window which we can hook to Qt's existing fractional scaling support. The viewport is used to communicate the relationship between buffer size and logical size to the compositor. It is a non-integer alternative to wl_buffer_scale Change-Id: I1a850f1bcd40e8d04e241e18a538b11f18bc671c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Fix frame sync related to unprotected multithread accessWeng Xuetian2022-12-031-27/+37
| | | | | | | | | | | | | | There is a few crashes happens in real life that frame callback is double-free'd and hit an assertion in wayland-client. e.g. https://bugs.kde.org/show_bug.cgi?id=450003 This is due to the WaylandEventThread and calls to QWaylandWindow::reset may free and unset the mFrameCallback at the same time. mFrameSyncMutex should be used to protect such access. Pick-to: 6.4 Change-Id: Ie01d08d07a2f10f70606ed1935caac09cb4f0382 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Client: Honor QGuiApplication::overrideCursor()Vlad Zahorodnii2022-11-301-1/+4
| | | | | | | | | | | If there's a QGuiApplication::overrideCursor(), QWindow::cursor() can still return a different cursor. This can result in a wrong cursor when the pointer enters a window. Pick-to: 6.4 6.2 5.15 Fixes: QTBUG-75919 Change-Id: I015117b4b6d252b421ab14bd8f2a8f582f7cae52 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Implement window alert with xdg-activationIlya Fedin2022-10-231-0/+14
| | | | | | | | | | This is implemented by not specifying serial, as mentioned in https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9#note_854977 Tested on KDE Plasma Change-Id: I4ef0975040bbce581b615b0318f90601e080235c Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-101-2/+2
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: Ia64c6615ee81f7ad5d0658449b0ee347c3db8c29 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Port from container::count() and length() to size()Marc Mutz2022-10-101-3/+3
| | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: I574208abc90a8042b500b3f96e3862b0ff339eb6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Client: fix enlargening window position by margins sizeIlya Fedin2022-09-201-2/+1
| | | | | | | | | | | | | | | In d89c8920f3b82dd2098971b5a66c4b9c75da5af0 it was changed to sum the current geometry with the margins. This makes Qt thinking that the window is moving on every configure request and makes the previous fix (5f8db38e49b5bee4962fa9ac048c23a3faae587b) actually no-op I'm not sure why it was changed as the commit is squashed, but I hope the intention wasn't to make Qt think the window is endlessly moving (exactly that happened though) Pick-to: 6.4 6.3 Change-Id: I7cde12ea5548d59810e2631be2a0085f86d5c4b9 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Client: add custom margins support to xdg popupsIlya Fedin2022-08-231-0/+5
| | | | | | | | | | xdg_positioner operates in window content geometry (i.e. without shadows), so it's necessary to remove popup's and parent's shadow from position and size calculations. Pick-to: 6.4 Change-Id: I997ba2c45ae341a09a8284226629e8107800e894 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Avoid calling requestUpdate from wrong threadEskil Abrahamsen Blomfeldt2022-08-171-1/+5
| | | | | | | | | | | | | | | | In certain circumstances, we can get to createDecoration() from the render thread (from QWaylandGLContext::makeCurrent) Calling requestUpdate() from this secondary thread would cause an assert, so we queue the call on the appropriate thread instead. This amends af7b60ade5c4be81cbc58eb18307c017d5594071. Pick-to: 5.15 6.2 6.3 6.3.2 6.4 Fixes: QTBUG-105308 Change-Id: I4805265f39e24eb1464897532be2025bc3c27728 Reviewed-by: Inho Lee <inho.lee@qt.io>
* Only close popup in the the hiercharyWeng Xuetian2022-07-241-17/+16
| | | | | | | | | | | | | | | | | Imagine following event sequences: 1. a tooltip is shown. activePopups = {tooltip} 2. user click menu bar to show the menu, QMenu::setVisible is called. now activePopups(tooltip, menu} 3. tooltip visibility changed to false. 4. closePopups() close both tooltip and menu. This is a common pattern under wayland that menu is shown as a invisible state. This patch tries to memorize the surface hierchary used to create the popup role. And only close those popups whose ancesotor is hidden. Pick-to: 6.4 Change-Id: I78aa0b4e32a5812603e003e756d8bcd202e94af4 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Client: Expose a way to set window margins via native interfaceIlya Fedin2022-07-191-2/+15
| | | | | | | | | | | | The lack of such API is a big hassle to me since a long time. All that time I was forced to have my own fork of the xdg-shell plugin in the application code in order to have shadows on Wayland with custom client-side decorations. I hope I won't have to maintain the fork anymore. Pick-to: 6.4 Change-Id: Iaf498469843b5cac5c458049164065c4ef15877d Reviewed-by: David Edmundson <davidedmundson@kde.org>
* client: Respect initial size when only one component is setEskil Abrahamsen Blomfeldt2022-06-301-4/+7
| | | | | | | | | | | | We would ignore the initial size of the window if only either the width or height were set and the other was left at 0. Instead of using isEmpty() for checking if the geometry is valid, we check the width and height individually. Pick-to: 6.4 Task-number: QTBUG-66818 Change-Id: Ib2a22443fd6b88175599da08651fa72c921ea485 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Keep toplevel windows in the top left corner of the screenDavid Redondo2022-06-221-1/+13
| | | | | | | | | | | | | | | | We can't know the actual position of a window on the screen. This causes an issue when Widgets try to position a popup/menu absolutely and keep it on the screen when the screen geometry doesn't include (0,0). Instead report their positions always as the top left corner of the screen that they are on. This new behavior can be disabled for qt-shell or via an environment variable by users that rely on the old behavior. Fixes: QTBUG-85297 Change-Id: Iacb91cb03a0df87af950115760d2f41124ac06a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
* Use SPDX license identifiersLucie Gérard2022-06-101-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I106d3a5d1a7b96250380b6f51a48f3b19d10e4d9 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtWaylandClient: includemocsLiang Qi2022-06-011-0/+2
| | | | | | | Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-103295 Change-Id: Ibac5e794c7d7f35d51d8d48110892c33a0b67c7a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Client: fix mouse cursor restoring check when cursor enters the content areaIlya Fedin2022-06-011-1/+1
| | | | | | | | | | | | | | | In a32cc186e645e8dac6dd7089f374f6d20e924f39, windowContentGeometry was changed by adding shadow margins, but the check ensures that the point inside the content area rather than the decoration and windowContentGeometry is smaller than the decoration geometry now as it excludes the shadow. Creating the geometry from surfaceSize fixes it. Pick-to: 6.3 6.2 Change-Id: If20a387b6864c1bc961352654f827a45cee77bd1 Reviewed-by: Jan Grulich <jgrulich@redhat.com> Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
* Client: Fix up thread usage for mSurfaceDavid Edmundson2022-03-221-1/+1
| | | | | | | | It didn't make sense that mSurface was protected, but the mutex was not. Also try to improve documentation. Change-Id: I2f59557cccbb2d6f0b2772ce3c8a2dab01167a6c Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Fix race condition on mWaitingForUpdateDeliveryPaul Olav Tvete2022-03-211-4/+2
| | | | | Change-Id: I0e91bda73722468b9339fc434fe04420b5e7d3da Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Revert "Client: Remove mWaitingForUpdateDelivery"Paul Olav Tvete2022-03-211-3/+8
| | | | | | | | | | | | The reverted commit introduces a severe performance regression when a client window is resized while a QtQuick renderthread animation is running. This reverts commit feb1a5c207c13d0bf87c0d8ad039279dbf8cee9e. Fixes: QTBUG-101726 Change-Id: Ib5b52ce06efec8c86fada1623c2af82099e57fc6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Guard mResizeDirty by the correctMutexDavid Edmundson2022-03-171-3/+4
| | | | | | | | | mResizeDirty is used in the GUI thread in setCanResize which can be called from the GUI thread. It is queried and set whilst the resizeLock is held. We need to guard our usage. Change-Id: I5f8dcf8aa2cb2c4bb6274103df1da9e3e268605a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Fix opaque region setterVlad Zahorodnii2022-02-211-1/+1
| | | | | | | | The rect is in the global coordinate system, while the opaque region must be in the surface local coordinate system. Change-Id: I75042b4d779dfd4dfe610aad1f0387879f11b048 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
* Update the window geometry when changing decorationsInho Lee2022-02-091-1/+1
| | | | | | | | | | Windows' geometries should be updated when changing decorations. Fixes: QTBUG-100467 Pick-to: 6.3 6.2 5.15 Change-Id: I5ec9968aa48422776d184a8fa2f5d86ecc3ca5c3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
* Do not delete window decorations before next updateInho Lee2022-02-091-18/+23
| | | | | | | | | | | | | When window decorations are turned on/off, a timing issue might happen with accessing deleted decorations. A boolean value, mWindowDecorationEnabled, will be used instead of mWindowDecoration. Pick-to: 6.3 6.2 Fixes: QTBUG-59627 Change-Id: I5514a408d89340fdbf481721ea2dc4bf62078852 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Remove mWaitingForUpdateDeliveryVlad Zahorodnii2022-02-081-8/+3
| | | | | | | | | | | | | | | | Currently, mWaitingForUpdateDelivery is shared between the main thread (doHandleFrameCallback()) and the frame callback event thread (handleFrameCallback()), however the access to it is not synchronized between both threads. On the other hand, QWaylandWindow already ensures not to create a frame callback if there's already one pending. This change removes mWaitingForUpdateDelivery flag because it should be already covered by mWaitingForFrameCallback and to remove unsynchronized shared state between threads. Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Fix missing update when toggling client-side decorationsEskil Abrahamsen Blomfeldt2021-12-211-0/+7
| | | | | | | | | | | | | | | | | | | | When CSD is toggled while a window is showing, it would change the size and recreate the buffers, but since the widget area remained the same size, we would not trigger a redraw. The result was that when you got any update to the window, it would redraw the widgets that had changed, and the rest would be transparent. Since this is a fairly specialized case, we fix it the simple way, by just issuing an extra update when it happens. This also required an update to the surface test, since there is an additional buffer commit in the beginning of the sequence now. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-95032 Change-Id: Ic4bdb9c66a2ea76546926dd622f2d2dac5dce10c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Liang Qi <liang.qi@qt.io>
* client: Fix crash on shutdown on Mesa driverEskil Abrahamsen Blomfeldt2021-12-211-1/+12
| | | | | | | | | | | | | | | | | | | | | On Wayland, then the mesa driver is in use, calling eglDestroySurface() while OpenGL commands are being executed may crash. While this means the driver does not operate by the specs in this case, the driver is so popular that it makes sense to work around it. To work around this, we read-lock the surface while rendering and wait for a write-lock before we destroy the EGL surface. [ChangeLog][QtWaylandClient] Fixed a crash on shutdown that could happen with some graphics-heavy applications when running on Mesa drivers. Pick-to: 6.3 Fixes: QTBUG-92249 Change-Id: I8b8461066cc9f948dc44ddeeddaa6e7d92b76f04 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Implement xdg_activation_v1 protocolAleix Pol2021-12-091-2/+11
| | | | | | Change-Id: Ib5c8d0c6a209308c2c1a7f5e45d8866ba0127d81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Avoid processing of events when showing windowsDavid Edmundson2021-12-021-1/+0
| | | | | | | | | | | | | | | | The only time we want to dispatch events from the wayland socket is when the application is waiting for external events. Doing so at any other time will cause unpredictable behavior in client code. This caused a crash downstream where we had outputs get altered whilst itterating through outputs, which shouldn't happen. There is no benefit to flushing here, it won't make anything appear faster as we haven't attached the buffer yet. Change-Id: Ie13eae4012dab96a93d8810f468d1343402b8c28 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
* Introduce new qt-shell and an API for custom shellsPaul Olav Tvete2021-12-021-11/+49
| | | | | | | | | | | | | | | | | | | | | | Adds a new API for writing custom shell extensions. This API is supported, but semi-public. Binary compatibility is not guaranteed. Also adds qt-shell, a new shell that maps directly to the QWindow API, and provides functionality that Qt provides on other window systems, such as absolute window positions and window activation. This shell is not intended for use on the desktop. This is a squashed commit of a development branch consisting of approximately 60 changes. Contributors: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Paul Olav Tvete <paul.tvete@qt.io> Task-number: QTBUG-94330 Task-number: QTBUG-91542 Change-Id: I419b6bd8179fe03e4da47d328c7ff4b4795b8a91 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Do not create decorations when the shellSurface is not readyInho Lee2021-11-121-1/+1
| | | | | | | | | | | | | | | A cases reported that client windows try to make decorations when their shell surfaces are null. Since the surfaces' requests for decorations should be applied, those case will be failed to create decorations. This patch was modified by Paul Tvete's advice. (paul.tvete@qt.io) Pick-to: 6.2 5.15 Task-number: QTBUG-97608 Change-Id: I2563dbd73b730f81cc411857af07da99ceb2d063 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Move the wayland socket polling to a separate event threadGiulio Camuffo2021-10-181-10/+24
| | | | | | | | | | | | | | | | | | | | | New event threads is introduced which calls poll() on the wayland fd, instead of relying on the event dispatcher by using the QSocketNotifier. This allows to call in the proper order the wl_display_prepare_read(), poll() and wl_display_read_events() functions. One thread is responsible for the default queue; when needed, it emit a signal so that the main thread can dispatch the queue. Another thread is responsible for the dedicated queue for frame callbacks; this thread will dispatch events on the thread itself. QWaylandWindow is updated to, instead of each window's dedicated event queue, use this queue for frame callbacks. Co-authored-by: Ratchanan Srirattanamet <ratchanan@ubports.com> Task-number: QTBUG-66075 Change-Id: Ibb33ad7f4193b866d1b8d7a0405a94d59dcad5eb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Wayland client: use wl_keyboard to determine active stateMéven Car2021-10-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit f497a5bb87270174b8e0106b7eca1992d44ff15d made QWaylandDisplay use the xdgshell's active state for QWindow::isActive(), instead of using wl_keyboard activate/deactivate events. That seems to have been a misunderstanding, since xdgshell activation is only supposed to be used to determine visual appearance, and there is an explicit warning not to assume it means focus. This commit reverts this logic back to listening to wl_keyboard. It adds a fallback when there is no wl_keyboard available to handle activated/deactivated events through xdg-shell, in order to fix QTBUG-53702. windowStates is handled so that we're not using the Xdg hint for anything with QWindowSystemInterface::handleWindowStateChanged or anything where we need to track only having one active. We are still exposing it for decorations, which is the only reason to use the Xdghint over keyboard focus - so you can keep the toplevel active whilst you show a popup. Change-Id: I4343d2ed9fb5b066cde95628ed0b4ccc84a424db Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Always destroy frame callback in the actual callbackGeorges Basile Stavracas Neto2021-09-271-9/+5
| | | | | | | | | | | | It's good hygiene to destroy all frame callbacks. Destroy the frame callback and cleanup the mFrameCallback class member in the callback itself. The callback destruction happens before calling handleFrameCallback() to avoid the theoretical case where another frame callback is queued by handleFrameCallback(), and then immediately destroyed in the callback handler. Change-Id: Ide6dc95e3402932c58bfc088a9d471fda821e9a1 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Don't always recreate frame callbacksGeorges Basile Stavracas Neto2021-09-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main QWaylandWindow method that is executed when handling updates is QWaylandWindow::handleUpdate(). This method always, unconditionally queues a frame callback, regardless of whether any other one is already queued. On some circumstances, e.g. when a window is hidden or completely obscured by other windows, it stops receiving frame callbacks from the compositor. However, QWaylandWindow would continue to request for them, which eventually fills up the Wayland socket, and causes the application to crash. This can be avoided by checking if the platform window is already waiting for a frame callback, before queueing another one. In QWaylandWindow::handleUpdate(), check if mWaitingForFrameCallback is true before queueing frame callbacks, and early return if that's the case. The XDG-shell test needed to be updated for this: The mock compositor is not responding to any frame callbacks, so the window will be unexposed, no longer get paint events and therefore not trigger any commit. This worked by accident before because we were issuing updates quickly enough to reset the timer before it had a chance to unexpose the window. The easiest fix is just to disable the dependency on frame callbacks in this test, since that is clearly not what it's testing. Task-number: QTBUG-81504 Change-Id: Ieacb05c7d5a5fcf662243d9177ebcc308cb9ca84 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Georges Basile Stavracas Neto <gbsneto@gnome.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Wayland client: Don't applyConfigure for destroyed surfacePaul Olav Tvete2021-09-241-0/+1
| | | | | | | | | | | | | | If a window is rapidly hidden and re-shown multiple times, the configure for a deleted wl_surface may be invoked after a new surface has been created. This change makes sure we always reset mWaitingToApplyConfigure before a new wl_surface is created. The superfluous applyConfigure invocation will then be safely ignored. Fixes: QTBUG-96464 Pick-to: 6.2 Change-Id: Ie2d718f77dc8de93674c6b86b5128c4f50414df1 Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Use QPointF for native gesture delta valuesShawn Rutledge2021-07-151-4/+4
| | | | | | | | | Needed after qtbase e3aa45006dc883adb92b4c94a0108d3b75012dce and de540c283d96630c189df9c9be37f68ad8285056. Pick-to: 6.2 Change-Id: Ieb199eca9d550d9e8e4963458508a91ec9db1728 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Improve categorized logging outputShawn Rutledge2021-07-141-4/+4
| | | | | | Change-Id: I8e4b48af21fe41bc76f83baa89e79a0e0fe8037c Reviewed-by: Povilas Kanapickas <povilas@radix.lt> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Do not update the mask if we do not have a surfaceAleix Pol2021-07-131-4/+4
| | | | | | | | | | | mMask serves as a cache to remember what we've sent, the source of truth for the value is window()->mask(). No need to store values that we are going to discard, because it will confuse the state of newly created windows. Change-Id: I6aa3da82c7f09c7ef90d0f7060f292fb042730f0 Pick-to: 5.15 6.2 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Use QEventPoint::State instead of Qt::TouchPointStateJiDe Zhang2021-06-251-1/+1
| | | | | | | | | Also fix compile warnings about -Wenum-compare. Pick-to: 6.2 6.1 6.0 5.15 Change-Id: I5e94fc028c727b155d5db4c7def35d518c497c5c Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Implement support for pointer gestures v1Povilas Kanapickas2021-05-281-0/+127
| | | | | Change-Id: Ie9ee615de123e6deab5b7a5081ca9bcf53399df7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* client: Gracefully handle shutdown and window hidingEskil Abrahamsen Blomfeldt2021-05-271-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | When a window is hidden or destroyed, the render thread may already be rendering. We need to properly read-lock the surface pointer when it is in use and exit when it becomes null. Note that there is also a potential crash in the Mesa GL driver where it keeps a proxy to the wl_surface, so if we delete this while we are still rendering, it can crash inside the driver. This is not addressed by this patch, and has not been reproduced on any other drivers so far. [ChangeLog][Client] Fixed a crash that could happen when hiding or closing windows while Qt Quick was actively rendering on a different thread. Pick-to: 6.0 6.1 5.15 Fixes: QTBUG-91264 Fixes: QTBUG-90037 Task-number: QTBUG-92249 Change-Id: I029b123b83c58740321e8b90a463ced748d8bcf4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Client: expose toplevel window stateJan Grulich2021-05-141-0/+15
| | | | | | | | | | | | | QWaylandWindow has only basic information about window state, like if it's active or maximized, but it has no information about tiling, which can be useful for client-side decorations. We also need to bump version of xdg-shell protocol we support, because additional states are not in the version currently supported by QtWayland. It shouldn't be a problem to increase the version as the new version adds just these additional window states. Change-Id: I4c46516d9c7296c69ea51a022b3bdb4ca06bef8d Reviewed-by: David Edmundson <davidedmundson@kde.org>
* client: Fix frame callback leak when window unexposedEskil Abrahamsen Blomfeldt2021-04-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we get a new update while already waiting for a frame callback and the window is unexposed, we would previously destroy the callback and issue a new one. But if the window is unexposed, the compositor may accumulate these and answer all the callbacks when the window is shown again. This may cause overflows and the client to be killed by the compositor in some cases where the number of pending updates is too high. To avoid this, we skip requesting new callbacks if there is already one pending and the window is unexposed. When the window is re-exposed, the existing pending callback will be triggered anyway, and until then there is no need to repeatedly verify that we still cannot render. One risk is that there may be compositors which never issues a response to the callbacks requested while the window was unexposed. But that would probably be in conflict with the specification and possibly cause other issues as well. The patch was tested with Weston and Mutter, and seems to improve behavior in both of these at least. [ChangeLog][Client] Fixed a bug where Wayland clients would continuously request frame callbacks while unexposed, which potentially caused crashes on some compositors. Fixes: QTBUG-81504 Change-Id: I16dbe51cc5a9acf1f49b4070af91e7f2c8996122 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>