Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
7
26
27#include <QtCore/QFileInfo>
28#include <QtCore/QPointer>
29#include <QtCore/QRegularExpression>
30#include <QtGui/QWindow>
31
32#include <QGuiApplication>
33#include <qpa/qwindowsysteminterface.h>
34#include <QtGui/private/qguiapplication_p.h>
35#include <QtGui/private/qwindow_p.h>
36
37#include <QtCore/QDebug>
38#include <QtCore/QThread>
39
40#include <QtWaylandClient/private/qwayland-fractional-scale-v1.h>
41
43
44using namespace Qt::StringLiterals;
45
46namespace QtWaylandClient {
47
48Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore")
49
52
53/*!
54 \class QtWaylandClient::QWaylandWindow
55 \internal
56*/
83
85{
86 reset();
87
88 const QWindow *parent = window();
89 const auto tlw = QGuiApplication::topLevelWindows();
90 for (QWindow *w : tlw) {
91 if (w->transientParent() == parent)
93 }
94
95 if (mMouseGrab == this) {
96 mMouseGrab = nullptr;
97 }
98}
99
107
109{
111
114
115 auto *parent = static_cast<QWaylandWindow *>(QPlatformWindow::parent());
116 if (!parent->mSurface)
118 if (parent->wlSurface()) {
121 }
122 } else if (shouldCreateShellSurface()) {
126 if (mTransientParent) {
127 if (window()->type() == Qt::Popup) {
129 qCWarning(lcQpaWayland) << "Creating a popup with a parent," << mTransientParent->window()
130 << "which does not match the current topmost grabbing popup,"
131 << mTopPopup->window() << "With some shell surface protocols, this"
132 << "is not allowed. The wayland QPA plugin is currently handling"
133 << "it by setting the parent to the topmost grabbing popup."
134 << "Note, however, that this may cause positioning errors and"
135 << "popups closing unxpectedly. Please fix the transient parent of the popup.";
137 }
138 mTopPopup = this;
139 }
140 }
141
143 if (mShellSurface) {
144 if (mTransientParent) {
145 if (window()->type() == Qt::ToolTip || window()->type() == Qt::Popup || window()->type() == Qt::Tool)
147 }
148
149 // Set initial surface title
152
153 // The appId is the desktop entry identifier that should follow the
154 // reverse DNS convention (see
155 // http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html). According
156 // to xdg-shell the appId is only the name, without the .desktop suffix.
157 //
158 // If the application specifies the desktop file name use that,
159 // otherwise fall back to the executable name and prepend the
160 // reversed organization domain when available.
163 } else {
168
169 if (domainName.isEmpty()) {
171 } else {
173 for (int i = 0; i < domainName.size(); ++i)
177 }
178 }
179 // the user may have already set some window properties, so make sure to send them out
180 for (auto it = m_properties.cbegin(); it != m_properties.cend(); ++it)
182
184 } else {
185 qWarning("Could not create a shell surface object.");
186 }
187 }
188
191
192 // Enable high-dpi rendering. Scale() returns the screen scale factor and will
193 // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale()
194 // to inform the compositor that high-resolution buffers will be provided.
195 if (mViewport)
197 else if (mSurface->version() >= 3)
199
202 if (geometry.width() <= 0)
204 if (geometry.height() <= 0)
206
208 setMask(window()->mask());
209 if (mShellSurface) {
212 }
214
216 mSurface->commit();
217
220 }
221}
222
224{
226}
227
260
277
284
286{
288 if (mShellSurface) {
289 qCWarning(lcQpaWayland) << "Cannot set shell integration while there's already a shell surface created";
290 return;
291 }
293}
294
296{
297 if (!shellIntegration())
298 return false;
299
301 return false;
302
303 if (window()->inherits("QShapedPixmapWindow"))
304 return false;
305
306 if (qEnvironmentVariableIsSet("QT_WAYLAND_USE_BYPASSWINDOWMANAGERHINT"))
307 return !(window()->flags() & Qt::BypassWindowManagerHint);
308
309 return true;
310}
311
313{
314 return QPlatformWindow::parent() != nullptr;
315}
316
322
324{
326 mInFrameRender = false;
327}
328
330{
332
335
336 if (mSurface) {
337 {
344
345 // Destroy surface last.
346 // Some compositors (e.g. ChromeOS Sommelier) crash if they receive
347 // destroy requests for these objects after the associated surface
348 // has already been destroyed.
349 mSurface.reset();
350 }
352 }
353
354 mScale = std::nullopt;
356 mMask = QRegion();
357
361
363}
364
366{
367 // Old Reset
369
370 if (mTopPopup == this)
374 mTransientParent = nullptr;
375 delete std::exchange(mShellSurface, nullptr);
376 delete std::exchange(mSubSurfaceWindow, nullptr);
378
380 mInFrameRender = false;
382 mExposed = false;
383}
384
386{
387 {
389 if (mFrameCallback) {
391 mFrameCallback = nullptr;
392 }
395 }
399 }
401}
402
404{
406 return s->waylandWindow();
407 return nullptr;
408}
410{
411 return reinterpret_cast<WId>(wlSurface());
412}
413
415{
416 if (lastParent == parent)
417 return;
418
419 if (mSubSurfaceWindow && parent) { // new parent, but we were a subsurface already
420 delete mSubSurfaceWindow;
421 QWaylandWindow *p = const_cast<QWaylandWindow *>(static_cast<const QWaylandWindow *>(parent));
423 } else if ((!lastParent && parent) || (lastParent && !parent)) {
424 // we're changing role, need to make a new wl_surface
425 reset();
427 if (window()->isVisible()) {
428 initWindow();
429 }
430 }
432}
433
435{
436 return mWindowTitle;
437}
438
440{
441 const QString separator = QString::fromUtf8(" \xe2\x80\x94 "); // unicode character U+2014, EM DASH
443
444 const int libwaylandMaxBufferSize = 4096;
445 // Some parts of the buffer is used for metadata, so subtract 100 to be on the safe side.
446 // Also, QString is in utf-16, which means that in the worst case each character will be
447 // three bytes when converted to utf-8 (which is what libwayland uses), so divide by three.
448 const int maxLength = libwaylandMaxBufferSize / 3 - 100;
449
451 if (truncated.size() < formatted.size()) {
452 qCWarning(lcQpaWayland) << "Window titles longer than" << maxLength << "characters are not supported."
453 << "Truncating window title (from" << formatted.size() << "chars)";
454 }
455
457
458 if (mShellSurface)
460
461 if (auto *dec = decoration(); dec && window()->isVisible())
462 dec->update();
463}
464
466{
468
469 if (auto *dec = decoration(); dec && window()->isVisible())
470 dec->update();
471 if (mShellSurface)
473}
474
476{
477 return QRect(QPoint(), QSize(500,500));
478}
479
481{
483 if (mViewport)
485
486 if (mSubSurfaceWindow) {
488
490 if (parentWindow)
492 }
493}
494
496{
497 auto rect = r;
499 && window()->type() != Qt::ToolTip && window()->type() != Qt::Tool) {
501 }
503
508 else
510 }
511
512 if (mShellSurface)
514
515 if (isOpaque() && mMask.isEmpty())
517
518
519 if (window()->isVisible() && rect.isValid()) {
520 ensureSize();
521 if (auto *dec = decoration())
522 dec->update();
523
525 }
526
527 // Wayland has no concept of areas being exposed or not, only the entire window, when our geometry changes, we need to flag the new area as exposed
528 // On other platforms (X11) the expose event would be received deferred from the X server
529 // we want our behaviour to match, and only run after control has returned to the event loop
531}
532
534{
535 if (!isExposed())
536 return;
539 return;
540
542}
543
545{
546 if (!mSurface)
547 return;
548
550
554
556 return;
557
560
562 mSurface->set_input_region(nullptr);
563 } else {
567 }
568}
569
571{
572 const QSize size = geometry().size();
573 if (!size.isEmpty())
575}
576
591
602
615
617{
618 static bool sQtTestMode = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING");
620
621 if (decoration())
623
624 if (sQtTestMode) {
626 }
628
629 /**
630 * If an expose is not handled by application code, explicitly attach a buffer
631 * This primarily is a workaround for Qt unit tests using QWindow directly and
632 * wanting focus.
633 */
637 commit(&buffer, QRegion());
638 }
639}
640
642{
644 if (mSurface) {
645 if (auto *screen = mSurface->oldestEnteredScreen())
646 return screen;
647 }
648 return QPlatformWindow::screen();
649}
650
652{
653 // Workaround for issue where setVisible may be called with the same value twice
654 if (lastVisible == visible)
655 return;
657
658 if (visible) {
660 initWindow();
662 if (mShellSurface)
664 } else {
665 // make sure isExposed is false during the next event dispatch
666 mExposed = false;
669 mSurface->attach(nullptr, 0, 0);
670 mSurface->commit();
671 }
672}
673
674
676{
677 if (mShellSurface)
679}
680
681
683{
684 if (mShellSurface)
686}
687
689{
691 if (!mSurface)
692 return;
693
694 if (mMask == mask)
695 return;
696
697 mMask = mask;
698
700
701 if (isOpaque()) {
702 if (mMask.isEmpty())
704 else
706 }
707}
708
714
716{
717 if (mShellSurface)
718 return mShellSurface->isAlertState();
719
720 return false;
721}
722
730
732{
734 return;
735
737 "QWaylandWindow::applyConfigure", "not called from main thread");
738
739 // If we're mid paint, use an exposeEvent to flush the current frame.
740 // When this completes we know that no other frames will be rendering.
741 // This could be improved in future as we 're blocking for not just the frame to finish but one additional extra frame.
742 if (mInFrameRender)
744 if (mShellSurface)
746
748 if (mExposed)
750 else
751 // we still need to commit the configured ack for a hidden surface
752 commit();
753}
754
756{
758 if (mSurface == nullptr)
759 return;
760
761 if (buffer) {
763 handleUpdate();
764 buffer->setBusy(true);
766 mSurface->offset(x, y);
767 mSurface->attach(buffer->buffer(), 0, 0);
768 } else {
770 }
771 } else {
772 mSurface->attach(nullptr, 0, 0);
773 }
774}
775
781
783{
785 if (mSurface == nullptr)
786 return;
787
788 const qreal s = scale();
789 if (mSurface->version() >= 4) {
790 const QRect bufferRect =
791 QRectF(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height())
792 .toAlignedRect();
795 } else {
797 }
798}
799
801{
802 if (isExposed()) {
804 } else if (!buffer->committed()) {
805 buffer->setBusy(false);
806 }
807}
808
813
815{
817
819 if (buffer->committed()) {
820 mSurface->commit();
821 qCDebug(lcWaylandBackingstore) << "Buffer already committed, not attaching.";
822 return;
823 }
824
825 if (!mSurface)
826 return;
827
829 if (mSurface->version() >= 4) {
830 const qreal s = scale();
831 for (const QRect &rect : damage) {
832 const QRect bufferRect =
833 QRectF(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height())
834 .toAlignedRect();
837 }
838 } else {
839 for (const QRect &rect: damage)
841 }
844 mSurface->commit();
845}
846
848{
850 if (mSurface != nullptr)
851 mSurface->commit();
852}
853
855 [](void *data, wl_callback *callback, uint32_t time) {
856 Q_UNUSED(time);
857 auto *window = static_cast<QWaylandWindow*>(data);
859 }
860};
861
863{
865 if (mFrameCallback != callback) {
866 // This means the callback is already unset by QWaylandWindow::reset.
867 // The wl_callback object will be destroyed there too.
868 return;
869 }
871 mFrameCallback = nullptr;
873
874 // The rest can wait until we can run it on the correct thread
876 // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
877 // in the single-threaded case.
879 }
881}
882
884{
886 bool wasExposed = isExposed();
888 // Did setting mFrameCallbackTimedOut make the window exposed?
892
893}
894
896{
898
901
902 if (mFrameCallback) {
903 qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
906 }
907
908 return !mFrameCallback;
909}
910
912{
913 if (auto *dec = decoration())
914 return dec->margins();
915 else if (mShellSurface)
917 else
919}
920
922{
923 if (auto *dec = decoration())
924 return dec->margins();
925 return QMargins{};
926}
927
934
947
948/*!
949 * Window geometry as defined by the xdg-shell spec (in wl_surface coordinates)
950 * topLeft is where the shadow stops and the decorations border start.
951 */
958
963
969
971{
973 return mSurface ? mSurface->object() : nullptr;
974}
975
980
982{
984 return mSubSurfaceWindow->object();
985 if (mShellSurface)
986 return mShellSurface->surfaceRole();
987 return {};
988}
989
994
996{
1000 return nullptr;
1001 return static_cast<QWaylandScreen *>(platformScreen);
1002}
1003
1009
1011{
1013 if (mSurface == nullptr || mSurface->version() < 2)
1014 return;
1015
1018
1019 if (mSurface->version() >= 6) {
1021 if (auto screen = waylandScreen())
1023 } else {
1024 if (auto screen = window()->screen())
1026 }
1027
1029
1031 case Qt::PrimaryOrientation:
1033 break;
1036 break;
1037 case Qt::PortraitOrientation:
1039 break;
1042 break;
1045 break;
1046 default:
1047 Q_UNREACHABLE();
1048 }
1050}
1051
1057
1063
1064// Keep in sync with the role decision in QWaylandXdgSurface. Do not use
1065// testFlag(Qt::Popup) here: Qt::Tool and Qt::SplashScreen contain all its bits.
1066static bool hasPopupRole(Qt::WindowFlags flags)
1067{
1068 const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
1069 return type == Qt::Popup || type == Qt::ToolTip;
1070}
1071
1073{
1074 const bool wasPopup = hasPopupRole(mFlags);
1075 const bool isPopup = hasPopupRole(flags);
1076
1077 mFlags = flags;
1078 // changing role is not allowed on XdgShell on the same wl_surface
1079 if (wasPopup != isPopup) {
1080 reset();
1082 if (window()->isVisible()) {
1083 initWindow();
1084 }
1085 } else {
1086 if (mShellSurface)
1088 }
1089
1091
1095 m_cutouts.reset();
1097 }
1098
1101}
1102
1104{
1105 return mFlags;
1106}
1107
1118
1123
1124static QWaylandWindow *closestShellSurfaceWindow(QWindow *window)
1125{
1126 while (window) {
1127 auto w = static_cast<QWaylandWindow *>(window->handle());
1128 if (w && w->shellSurface())
1129 return w;
1130 window = window->transientParent() ? window->transientParent() : window->parent();
1131 }
1132 return nullptr;
1133}
1134
1139
1141{
1142 // Take the closest window with a shell surface, since the transient parent may be a
1143 // QWidgetWindow or some other window without a shell surface, which is then not able to
1144 // get mouse events.
1146 return transientParent;
1147
1148 if (window()->type() == Qt::Popup) {
1149 if (mTopPopup)
1150 return mTopPopup;
1151 }
1152
1153 if (window()->type() == Qt::ToolTip || window()->type() == Qt::Popup) {
1154 if (auto lastInputWindow = display()->lastInputWindow())
1156 }
1157
1158 return nullptr;
1159}
1160
1162{
1163 // There's currently no way to get info about the actual hardware device in use.
1164 // At least we get the correct seat.
1166 if (e.type == QEvent::Leave) {
1168#if QT_CONFIG(cursor)
1170#endif
1171 return;
1172 }
1173
1174#if QT_CONFIG(cursor)
1175 if (e.type == QEvent::Enter) {
1177 }
1178#endif
1179
1180 switch (e.type) {
1181 case QEvent::Enter:
1183#if QT_CONFIG(cursor)
1185#endif
1186 break;
1189 case QEvent::MouseMove:
1191 break;
1192 case QEvent::Wheel:
1195 e.phase, e.source, e.inverted);
1196 break;
1197 default:
1198 Q_UNREACHABLE();
1199 }
1200
1201}
1202
1203#ifndef QT_NO_GESTURES
1206{
1207 switch (e.state) {
1208 case Qt::GestureStarted:
1210 qCWarning(lcQpaWaylandInput) << "Unexpected GestureStarted while already active";
1211
1212
1217 e.local, e.global, e.fingers);
1218 break;
1219 case Qt::GestureUpdated:
1221 return;
1222
1223 if (!e.delta.isNull()) {
1227 0, e.delta, e.local, e.global, e.fingers);
1228 }
1229 break;
1230 case Qt::GestureFinished:
1231 case Qt::GestureCanceled:
1232
1234 qCWarning(lcQpaWaylandInput) << "Unexpected" << (e.state == Qt::GestureFinished ? "GestureFinished" : "GestureCanceled");
1235
1237
1238 // There's currently no way to expose cancelled gestures to the rest of Qt, so
1239 // this part of information is lost.
1243 e.local, e.global, e.fingers);
1244 break;
1245 default:
1246 break;
1247 }
1248}
1249
1252{
1253 switch (e.state) {
1254 case Qt::GestureStarted:
1256 qCWarning(lcQpaWaylandInput) << "Unexpected GestureStarted while already active";
1257
1262 e.local, e.global, e.fingers);
1263 break;
1264 case Qt::GestureUpdated:
1266 return;
1267
1268 if (!e.delta.isNull()) {
1272 0, e.delta, e.local, e.global, e.fingers);
1273 }
1274 if (e.rotation_delta != 0) {
1279 e.local, e.global, e.fingers);
1280 }
1281 if (e.scale_delta != 0) {
1285 e.scale_delta,
1286 e.local, e.global, e.fingers);
1287 }
1288 break;
1289 case Qt::GestureFinished:
1290 case Qt::GestureCanceled:
1292 qCWarning(lcQpaWaylandInput) << "Unexpected" << (e.state == Qt::GestureFinished ? "GestureFinished" : "GestureCanceled");
1293
1295
1296 // There's currently no way to expose cancelled gestures to the rest of Qt, so
1297 // this part of information is lost.
1301 e.local, e.global, e.fingers);
1302 break;
1303 default:
1304 break;
1305 }
1306}
1307
1308#endif // #ifndef QT_NO_GESTURES
1309
1310
1315
1317{
1319
1320 if (!newScreen || newScreen->screen() == window()->screen())
1321 return;
1322
1324
1326 && window()->type() != Qt::ToolTip && window()->type() != Qt::Tool
1327 && geometry().topLeft() != newScreen->geometry().topLeft()) {
1328 auto geometry = this->geometry();
1331 }
1332
1333 updateScale();
1335}
1336
1338{
1339 if (mFractionalScale) {
1344 return;
1345 }
1346
1347 if (mSurface && mSurface->version() >= 6) {
1351 return;
1352 }
1353
1354 int scale = screen()->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(screen())->scale();
1355 setScale(scale);
1356}
1357
1359{
1361 return;
1362 mScale = newScale;
1363
1364 if (mSurface) {
1365 if (mViewport)
1367 else if (mSurface->version() >= 3)
1369 }
1370 ensureSize();
1371
1373 if (isExposed()) {
1374 // redraw at the new DPR
1375 window()->requestUpdate();
1377 }
1378}
1379
1380#if QT_CONFIG(cursor)
1382{
1385 } else if (mHasStoredCursor) {
1387 } else {
1389 }
1390}
1391
1393{
1394 mHasStoredCursor = false;
1395}
1396
1397// Keep track of application set cursors on each window
1400 mHasStoredCursor = true;
1401}
1402
1404 if (!device || !device->pointer() || device->pointer()->focusSurface() != waylandSurface())
1405 return;
1406
1409}
1410#endif
1411
1413{
1414 QWaylandWindow *toplevel = this;
1415 while (auto parent = static_cast<QWaylandWindow *>(toplevel->QPlatformWindow::parent()))
1416 toplevel = parent;
1417
1418 if (toplevel != this) {
1421 return;
1422 }
1423
1426 mDisplay->setActiveSubSurface(nullptr);
1427 return;
1428 }
1429
1430 if (mShellSurface)
1432}
1433
1435{
1436 if (!window()->isVisible())
1437 return false;
1438
1440 return false;
1441
1442 if (mShellSurface)
1443 return mShellSurface->isExposed();
1444
1446 return mSubSurfaceWindow->parent()->isExposed();
1447
1449}
1450
1452{
1453 bool exposed = calculateExposure();
1454 if (exposed == mExposed)
1455 return;
1456
1457 mExposed = exposed;
1458
1459 if (!exposed)
1461 else
1463
1465 auto subWindow = subSurface->window();
1467 }
1468}
1469
1471{
1472 return mExposed;
1473}
1474
1476{
1477 return mDisplay->isWindowActivated(this);
1478}
1479
1481{
1482 return devicePixelRatio();
1483}
1484
1489
1491{
1492 if (window()->type() != Qt::Popup) {
1493 qWarning("This plugin supports grabbing the mouse only for popup windows");
1494 return false;
1495 }
1496
1497 mMouseGrab = grab ? this : nullptr;
1498 return true;
1499}
1500
1505
1510
1515
1525
1535
1543
1545{
1546 return m_properties;
1547}
1548
1553
1558
1559#ifdef QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE
1561{
1562 mBackingStore = dynamic_cast<QWaylandShmBackingStore *>(store);
1563}
1564#endif
1565
1567{
1569 return;
1570
1571 {
1573
1579 }
1581 return;
1582 }
1584 }
1585
1586 qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
1589}
1590
1592{
1593 qCDebug(lcWaylandBackingstore) << "requestUpdate";
1594 Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
1595
1596 // If we have a frame callback all is good and will be taken care of there
1597 {
1599 if (mFrameCallback)
1600 return;
1601 }
1602
1603 // Some applications (such as Qt Quick) depend on updates being delivered asynchronously,
1604 // so use invokeMethod to delay the delivery a bit.
1605 QMetaObject::invokeMethod(this, [this] {
1606 // Things might have changed in the meantime
1607 {
1609 if (mFrameCallback)
1610 return;
1611 }
1614 }, Qt::QueuedConnection);
1615}
1616
1617// Should be called whenever we commit a buffer (directly through wl_surface.commit or indirectly
1618// with eglSwapBuffers) to know when it's time to commit the next one.
1619// Can be called from the render thread (without locking anything) so make sure to not make races in this method.
1621{
1623 qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
1624
1625 // TODO: Should sync subsurfaces avoid requesting frame callbacks?
1627 if (!mSurface)
1628 return;
1629
1631 if (mFrameCallback)
1632 return;
1633
1634 struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
1639
1640 // Start a timer for handling the case when the compositor stops sending frame callbacks.
1641 if (mFrameCallbackTimeout > 0) {
1642 QMetaObject::invokeMethod(this, [this] {
1644
1645 if (mFrameCallback) {
1649 }
1650 }, Qt::QueuedConnection);
1651 }
1652}
1653
1659
1661{
1662 qCDebug(lcWaylandBackingstore) << "deliverUpdateRequest";
1663 if (decoration())
1666
1667 // an update request doesn't always force a commit if the window isn't damaged, so also force it
1669 mPendingForcedUpdate = false;
1672 }
1673}
1674
1676{
1677 mOffset += point;
1678}
1679
1685
1687{
1688 if (auto *seat = display()->lastInputDevice()) {
1691 return rc;
1692 }
1693 return false;
1694}
1695
1697{
1698 if (auto seat = display()->lastInputDevice()) {
1701 return rc;
1702 }
1703 return false;
1704}
1705
1706bool QWaylandWindow::isOpaque() const
1707{
1708 return window()->requestedFormat().alphaBufferSize() <= 0;
1709}
1710
1712{
1713 if (opaqueArea == mOpaqueArea || !mSurface)
1714 return;
1715
1717
1721}
1722
1724{
1725 if (!mShellSurface) {
1726 qCWarning(lcQpaWayland) << "requestXdgActivationToken is called with no surface role created, emitting synthetic signal";
1728 return;
1729 }
1731}
1732
1734{
1735 if (mShellSurface)
1737 else
1738 qCWarning(lcQpaWayland) << "setXdgActivationToken is called with no surface role created, token" << token << "discarded";
1739}
1740
1742{
1743 if (mShellSurface)
1746}
1747
1749{
1750 if (mShellSurface)
1753}
1754
1756 while (!mChildPopups.isEmpty()) {
1757 auto popup = mChildPopups.takeLast();
1759 }
1760}
1761
1763{
1764 if (window()->isVisible()) {
1765 initWindow();
1768 }
1769}
1770
1772{
1775 if (auto *dec = decoration(); dec && window()->isVisible())
1776 dec->update();
1777 } else if (event->type() == QEvent::WindowUnblocked) {
1778 // QtGui sends leave event to window under cursor when modal window opens, so we have
1779 // to send enter event when modal closes and window has cursor and gets unblocked.
1781 const auto pos = mDisplay->waylandCursor()->pos();
1783 }
1784 }
1785
1787}
1788
1790{
1791 return mSurfaceFormat;
1792}
1793
1798
1803
1807
1812
1819
1824
1826{
1827 if (!window() || window()->flags() & Qt::WindowDoesNotAcceptFocus)
1828 return;
1829
1831 const bool isSubsurface = !!subSurfaceWindow();
1832
1833 auto toplevelIsActive = [&](QWaylandWindow *w) -> bool {
1834 while (w && w->subSurfaceWindow())
1835 w = static_cast<QWaylandWindow *>(w->QPlatformWindow::parent());
1836 return mDisplay->isWindowActivated(w);
1837 };
1838
1842 mDisplay->setActiveSubSurface(nullptr);
1843}
1844
1845}
1846
1847QT_END_NAMESPACE
1848
1849#include "moc_qwaylandwindow_p.cpp"
Combined button and popup list for selecting options.
Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland")
static bool hasPopupRole(Qt::WindowFlags flags)
static QWaylandWindow * closestShellSurfaceWindow(QWindow *window)