summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandwindow_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove QWaylandWindow::handleExposeTor Arne Vestbø2024-01-301-1/+0
| | | | | | | | It was part of xdg-shell-v6 which has since been removed. Pick-to: 6.6 6.7 Change-Id: Iecf5166b4c2710b209f7dfa0951958dcf82618f7 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Mark QWaylandWindow::wlSurface as constDavid Redondo2024-01-191-2/+2
| | | | | Change-Id: I416fee67bb35a88f55ac6d24d203e607f1ea1f32 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* QWaylandWindow: Update decoration when application palette/font changesKai Uwe Broulik2024-01-101-0/+2
| | | | | | | | Ensures the decoration can redraw to adjust for the new colors/font. Pick-to: 6.7 6.6 6.5 Change-Id: Ib46acde1d14baafda49f379f8279c396bc976bdc Reviewed-by: David Edmundson <davidedmundson@kde.org>
* bradient: Use QWaylandWindow actual window titleKai Uwe Broulik2024-01-101-0/+2
| | | | | | | | | | | | | It may include a suffix containing the application name and is also what's set on the XDG Toplevel, i.e. what the rest of the environment (task switcher, etc) sees. This stores the title in QWaylandWindow and adds a getter to retrieve it. Pick-to: 6.7 Change-Id: I84f41c68b16b680cdbb5cf656c7078d1e41767d4 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Don't use Qt keywords in headersKai Uwe Broulik2023-12-181-3/+3
| | | | | | | | | | | | | Unfortunately for many Wayland features applications need to access Qt private headers which will fail if the project is built with QT_NO_KEYWORDS. Ideally, the examples and tests were ported, too, and QT_NO_KEYWORDS enabled in .cmakec.conf. Pick-to: 6.7 Change-Id: I9f988d304bcc8dba4dd84761c41ba3da2473515d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Handle subsurfaces with async configureDavid Edmundson2023-12-111-1/+1
| | | | | | | | | | | | | | | With XDG Shell we cannot map a buffer until we get a configure event. To handle this the normal expose events is blocked then sent explicitly when we get this request. This works, but we also need to notify that subsurfaces are now exposed with the parent. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-119882 Fixes: QTBUG-119883 Change-Id: I0ae69c8da702037e7575cfc0939d3e783b50f323 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Client: Move topmost grabbing popup tracking to QWaylandWindowVlad Zahorodnii2023-11-171-1/+2
| | | | | | | | | | | | | | | | If the effective transient parent is different from QWaylandWindow::transientParent(), then the popups may be closed in wrong order and producing an xdg-shell protocol error. This change lifts topmost popup tracking from the xdg-shell plugin to QWaylandWindow so it can guess the correct transient parent and the xdg-shell plugin doesn't have to pick a different parent behind our back. Fixes: QTBUG-119110 Pick-to: 6.6 Change-Id: I7c5f780b7bd4c3362aa7b22762ff336ae908ff70 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* QWaylandSurface: client support wl_surface version 6JiDe Zhang2023-11-021-0/+4
| | | | | | | | | | | | | | Add QWaylandWindow::updateScale() function to update the window's scale from QWaylandFractionalScale or QWaylandSurface::preferredBufferScale or QWaylandScreen::scale or QWaylandSurface::preferredBufferScale. Add QWaylandWindow::updateBufferTransform() function to update the window's buffer transform from QScreen::primaryOrientation or QWaylandSurface::preferredBufferTransform. Change-Id: I2742701e92c7403a89df97b7fa06b5b0de6917a7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Include what you need: <QPointer>Marc Mutz2023-10-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | All these TUs relied on transitive includes of qpointer.h, maybe to a large extent via qevent.h, though, given that qevent.h is more or less the only public QtBase header that includes qpointer.h, something else seems to be at play here. Said qevent.h actually needs QPointer in-name-only, so a forward declaration would suffice. Prepare for qevent.h dropping the include. The algorithm I used was: If the TU mentions 'passiveGrabbers', the name of the QEvent function that returns QPointers, and the TU doesn't have qpointer.h included explicitly, include it. That may produce False Positives, but better safe than sorry. Otherwise, in src/, add an include to all source and header files which mention QPointer. Exception: if foo.h of a foo.cpp already includes it, don't include again. Task-number: QTBUG-117670 Change-Id: I8eb00fbd2df16300b0cbfc4157612a45c72ac12c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QWaylandWindow: add QWaylandWindow::setScaleJiDe Zhang2023-10-071-0/+1
| | | | | | | | The logic for update window's scale is scattered in multiple places, we should unify their behavior. Change-Id: Ic8ba20fdbc44942aed9b4bd0b0b12dad7bee1719 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Client: Fix QT_WAYLAND_RESIZE_AFTER_SWAPVlad Zahorodnii2023-09-121-2/+1
| | | | | | | | | | | | | | | | | | | | mResizeLock can be locked several times by the same thread in the following scenario QWaylandWindow::setGeometry() at qwaylandwindow.cpp:429:43 QWaylandEglWindow::setGeometry() at qwaylandeglwindow.cpp:58:32 QWaylandWindow::resizeFromApplyConfigure() at qwaylandwindow.cpp:517:16 QWaylandXdgSurface::Toplevel::applyConfigure() at qwaylandxdgshell.cpp:91:57 QWaylandXdgSurface::applyConfigure() at qwaylandxdgshell.cpp:381:35 QWaylandWindow::doApplyConfigure() at qwaylandwindow.cpp:628:38 QWaylandWindow::applyConfigure() at qwaylandwindow.cpp:671:25 Since mResizeLock is not a recursive mutex, the main thread just blocks in QWaylandWindow::setGeometry(). To prevent that, this patch changes the type of mResizeLock from QMutex to QRecursiveMutex. Change-Id: I362f4909bfdfc2d91b7cf902f27d35c742ac5091 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QWaylandWindow: Support Qt::WindowTransparentForInputKai Uwe Broulik2023-08-071-0/+6
| | | | | | | | | | | | | This is achieved by setting an explicitly empty input region (as opposed to a "null" region) on the window. Unlike set_opaque_region, where a null region means an empty region, in set_input_region it means an infinite region. Pick-to: 6.6 Change-Id: I018d53196bc816b5eaea7dd3b24626a9738c9f47 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* QWaylandWindow: adapt to QPlatformWindow::setBackingStore() additionMarc Mutz2023-08-021-0/+4
| | | | | | | | | | | | | | | | | When qtbase/a4ca9e80658bca7dad1529f03c1b59173a6ecf62 added a virtual QPlatformWindow::setBackingStore(), this was hidden by the existing QWaylandWindow::setBackingStore(), causing a FTBFS on -developer-builds. Fix by using the newly-added detection macro to turn the existing function into an overrider. Pick-to: 6.6 Fixes: QTBUG-115691 Task-number: QTBUG-97482 Change-Id: If1d8c4443fe50030addb23331a50b7b9e1274626 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Make sure doApplyConfigure() is called from main threadPaul Olav Tvete2023-04-181-0/+3
| | | | | | Task-number: QTBUG-101948 Change-Id: I867365384c43ccddf5b7a8600a3db84aa99aca6d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Track parent-popup relationship in QWaylandWindowVlad Zahorodnii2023-04-031-2/+5
| | | | | | | | | | | | | | | | | | This reduces the amount of boilerplate code that goes in shell integration plugins providing popups. The main motivation behind this change though is to ensure that QWaylandWindow::addChildPopup() gets called outside the QWaylandShellSurface constructor so one could use the popup's shell surface object to customize parent-child relationship. mShellSurface = mShellIntegration->createShellSurface(this); when this code executes, addChildPopup() will be called before the return value of createShellSurface() is assigned to mShellSurface. Change-Id: I9ccfb21f46febb451bdd7b4aa7851a99f3a03655 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Introduce path for surviving compositor restartsDavid Edmundson2023-03-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces an optional mechanism for clients to survive a crash and reconnect seemingly seamlessly. In the event of a disconnect from the compositor socket we simply try to reconnect again and replay any data needed so that we maintain a consistent state to where we left off. From an application point-of-view any open popups will be dismissed and we we potentially get a new framecallback, but it will be almost entirely transparent. Users of custom QWaylandClientExtensions will be notified via the activeChanged signal and rebuild as though the compositor had withdrawn and re-announced the global. OpenGL contexts will be marked as invalid, and handled the same way as a GPU reset. On the next frame RHI will notice these are invalid and recreate them, only now against a new wl_display and new EGLDisplay. Users of low level EGL/native objects might be affected, but the alternative at this point is being closed anyway. The entire codepath is only activated via an environment variable. Change-Id: I6c4acc885540e14cead7640794df86dd974fef4f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* client: Unify margins handlingIlya Fedin2023-02-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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 Pick-to: 6.5 Change-Id: I1b98afc8b5c867ecb7cc586267b13f7ec4b1a88c Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Client: Provide support for custom shellsVlad Zahorodnii2022-12-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+11
| | | | | | | 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-1/+6
| | | | | | | | | | | | | 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-5/+6
| | | | | | | | | | | | | | 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>
* Implement window alert with xdg-activationIlya Fedin2022-10-231-0/+3
| | | | | | | | | | 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>
* Client: add custom margins support to xdg popupsIlya Fedin2022-08-231-0/+1
| | | | | | | | | | 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>
* Only close popup in the the hiercharyWeng Xuetian2022-07-241-0/+6
| | | | | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | | | 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>
* Keep toplevel windows in the top left corner of the screenDavid Redondo2022-06-221-0/+3
| | | | | | | | | | | | | | | | 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: use the CMake exports.h supportThiago Macieira2022-04-281-1/+1
| | | | | | | | | | | | The one in qtwaylandglobal.h was wrong. It just happened to work on Linux because the lack of import wasn't an error... until GCC 12 with -mno-direct-extern-access. Pick-to: 6.3 Change-Id: If05aeeb7176e4f13af9afffd16e8535b469f9158 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Client: Fix up thread usage for mSurfaceDavid Edmundson2022-03-221-2/+4
| | | | | | | | 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-1/+1
| | | | | Change-Id: I0e91bda73722468b9339fc434fe04420b5e7d3da Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Revert "Client: Remove mWaitingForUpdateDelivery"Paul Olav Tvete2022-03-211-0/+1
| | | | | | | | | | | | 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>
* wayland: do not rely on transitive includesFabian Kosmale2022-03-111-0/+2
| | | | | Change-Id: I149e04d31ef3e897e25a91450427237069af4c34 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Do not delete window decorations before next updateInho Lee2022-02-091-0/+1
| | | | | | | | | | | | | 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-1/+0
| | | | | | | | | | | | | | | | 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>
* client: Fix crash on shutdown on Mesa driverEskil Abrahamsen Blomfeldt2021-12-211-0/+3
| | | | | | | | | | | | | | | | | | | | | 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-0/+4
| | | | | | Change-Id: Ib5c8d0c6a209308c2c1a7f5e45d8866ba0127d81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Introduce new qt-shell and an API for custom shellsPaul Olav Tvete2021-12-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | 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>
* Move the wayland socket polling to a separate event threadGiulio Camuffo2021-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* Use QEventPoint::State instead of Qt::TouchPointStateJiDe Zhang2021-06-251-1/+2
| | | | | | | | | 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/+25
| | | | | Change-Id: Ie9ee615de123e6deab5b7a5081ca9bcf53399df7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* client: Gracefully handle shutdown and window hidingEskil Abrahamsen Blomfeldt2021-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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/+16
| | | | | | | | | | | | | 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>
* Fix inconsistent window geometry on null windowYoungjin Kim2021-04-151-0/+1
| | | | | | | | | | | | Add virtual QtWaylandClient::QWaylandWindow::defaultGeometry(). So this method allows a client to set the desired default geometry. Otherwise, if the geometry of the window is null, the window with the hard-coded geometry size will be displayed for a while when starting a client application. Change-Id: I18c50f8f390c2b8e1a2c3d8e4641b896df4d6c3f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Replace scale with devicePixelRatio for non-integer scalingJungi Byun2021-03-251-1/+1
| | | | | | | | | | | | | | | The 'scale' event from wayland cannot support non-integer scaling which was originally supported in Qt. As default, devicePixelRatio follows the 'scale' so that the high DPI still works as the mechanism in Wayland. But if non-integer scaling factor such as 150% is needed, it can be supported to override the devicePixelRatio. Change-Id: I63a04db27bd521264b6d0904e1ddd05a572dc970 Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com> Reviewed-by: Jungi Byun <jungi.byun@lge.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Support handleFrameCallback to derived classesJungi Byun2021-03-081-0/+1
| | | | | | | | | | | The lambda expression doHandleExpose() is used in handleFrameCallback() to deal with exposure. In order to support platform specific implementation for frame callback, make the method doHandleExpose() into a virtual protected member doHandleFrameCallback() in QWaylandWindow. Change-Id: I8b22d4a552c72db1620d606929005917588c680d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Support platform specific implementationElvis Lee2021-02-171-1/+2
| | | | | | | | | QtWaylandClient can be inherited to support platform specific implementaton. Change-Id: Ie0f4aa28dbb2dcd6b1245cb14e23f3b45e687400 Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Issue set_opaque_region on opaque surfacesAleix Pol2020-10-201-0/+3
| | | | | | | | | | | | The application will tell Qt whether the background is transparent through either Qt::WA_TranslucentBackground or QQuickWindow::setColor. These will set a QSurfaceFormat. This change checks the QSurfaceFormat and issues the opacity information so we can properly implement culling optimizations in the compositor. Pick-to: 5.15 Change-Id: I4f7562467449eac7931f3011d4b835934212adad Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Fix race condition on frame callbackPaul Olav Tvete2020-10-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the frame listener callback is moved to a different queue while the frame event is being processed, the event will not get delivered. (It will not even show up in the WAYLAND_DEBUG output.) This will cause waitForFrameSync() to hang until it times out. To avoid this, perform the move just after the callback has been created. This exposed an issue with single-threaded rendering, where a new update would be started from inside the callback, resetting mWaitingForFrameCallback before waitForFrameSync could react to it. This caused all rendering to freeze. To avoid that problem, do not deliver update requests directly from the frame callback. With the callback always on a separate queue, we then have to make sure that queue is also dispatched during the main event loop, otherwise the events may not be processed. To do this, we need a mutex lock. But it turns out that we no longer need a global mutex lock as long as the frame events are being dispatched on their own queues, but can manage with per-window locks instead. A final thing needed is to make sure the frame callback does not request additional updates while we are already waiting for the main thread to process the last one. This is to avoid flooding the main event loop with events, when the main thread is processing them at a slower pace than the frame rate. Fixes: QTBUG-83263 Pick-to: 5.15 Done-with: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Change-Id: I0db9da64fc8ced147177391c2a7999c4cc7a0d58 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>
* Client: Send subsurface expose event when toplevel is configuredDavid Edmundson2020-08-211-0/+1
| | | | | | | | | | | | | | | | | If a subsurface is set to be visible on the cilent side before the top level is configured it will do not create an exposeEvent and map a buffer as we fail the check in isExposed() where we check the parent. This is correct behavior. However, when the toplevel receives an applyConfigure from the shell client we need subsurfaces to update accordingly. This fixes a race where subsurfaces are not shown with slow compositors. Change-Id: Icd156e7655d5b25535acc4d2fe77c31e19ebfa32 Pick-to: 5.15 Fixes: QTBUG-86176 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Use QList instead of QVectorJarek Kobus2020-06-081-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: I4bc7b2eb2913fc828f09f96e21480b76cabf8656 Reviewed-by: Lars Knoll <lars.knoll@qt.io>