2020-09-19 07:38:13 +00:00
|
|
|
From 656c0b68892d1ab455979c59dfef529924c57bff Mon Sep 17 00:00:00 2001
|
2020-08-23 10:56:49 +00:00
|
|
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
|
|
Date: Thu, 20 Aug 2020 11:58:45 -0300
|
2020-09-01 10:47:53 +00:00
|
|
|
Subject: [PATCH 20/24] UI: Check for Expose and PlatformSurface events to
|
2020-08-23 10:56:49 +00:00
|
|
|
create display
|
|
|
|
|
|
|
|
This is a workaround for QWaylandWindow never becoming exposed, or
|
|
|
|
receiving the QEvent::Expose [1].
|
|
|
|
|
|
|
|
[1] https://bugreports.qt.io/browse/QTBUG-86176
|
|
|
|
---
|
2020-08-29 08:04:30 +00:00
|
|
|
UI/qt-display.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 58 insertions(+)
|
2020-08-23 10:56:49 +00:00
|
|
|
|
|
|
|
diff --git a/UI/qt-display.cpp b/UI/qt-display.cpp
|
2020-08-29 08:04:30 +00:00
|
|
|
index b230ab4e..4487d460 100644
|
2020-08-23 10:56:49 +00:00
|
|
|
--- a/UI/qt-display.cpp
|
|
|
|
+++ b/UI/qt-display.cpp
|
2020-08-29 08:04:30 +00:00
|
|
|
@@ -10,6 +10,58 @@
|
2020-08-23 10:56:49 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_WAYLAND
|
|
|
|
#include <obs-nix-platform.h>
|
|
|
|
+
|
|
|
|
+class SurfaceEventFilter : public QObject {
|
|
|
|
+ OBSQTDisplay *display;
|
|
|
|
+ int mTimerId;
|
|
|
|
+
|
|
|
|
+public:
|
|
|
|
+ SurfaceEventFilter(OBSQTDisplay *src) : display(src), mTimerId(0) {}
|
|
|
|
+
|
|
|
|
+protected:
|
|
|
|
+ bool eventFilter(QObject *obj, QEvent *event) override
|
|
|
|
+ {
|
|
|
|
+ bool result = QObject::eventFilter(obj, event);
|
|
|
|
+ QPlatformSurfaceEvent *surfaceEvent;
|
|
|
|
+
|
|
|
|
+ switch (event->type()) {
|
2020-08-29 08:04:30 +00:00
|
|
|
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1)
|
2020-08-23 10:56:49 +00:00
|
|
|
+ case QEvent::PlatformSurface:
|
|
|
|
+ surfaceEvent =
|
|
|
|
+ static_cast<QPlatformSurfaceEvent *>(event);
|
|
|
|
+ if (surfaceEvent->surfaceEventType() !=
|
|
|
|
+ QPlatformSurfaceEvent::SurfaceCreated)
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ if (display->windowHandle()->isExposed())
|
|
|
|
+ createOBSDisplay();
|
|
|
|
+ else
|
|
|
|
+ mTimerId = startTimer(67); // Arbitrary
|
|
|
|
+ break;
|
2020-08-29 08:04:30 +00:00
|
|
|
+#endif
|
2020-08-23 10:56:49 +00:00
|
|
|
+ case QEvent::Expose:
|
|
|
|
+ createOBSDisplay();
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void timerEvent(QTimerEvent *) { createOBSDisplay(true); }
|
|
|
|
+
|
|
|
|
+private:
|
|
|
|
+ void createOBSDisplay(bool force = false)
|
|
|
|
+ {
|
|
|
|
+ display->CreateDisplay(force);
|
|
|
|
+ if (mTimerId > 0) {
|
|
|
|
+ killTimer(mTimerId);
|
|
|
|
+ mTimerId = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline long long color_to_int(const QColor &color)
|
2020-08-29 08:04:30 +00:00
|
|
|
@@ -65,6 +117,12 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
2020-08-23 10:56:49 +00:00
|
|
|
|
|
|
|
connect(windowHandle(), &QWindow::visibleChanged, windowVisible);
|
|
|
|
connect(windowHandle(), &QWindow::screenChanged, screenChanged);
|
|
|
|
+
|
|
|
|
+#ifdef ENABLE_WAYLAND
|
|
|
|
+ if (obs_get_nix_platform() == OBS_NIX_PLATFORM_WAYLAND)
|
|
|
|
+ windowHandle()->installEventFilter(
|
|
|
|
+ new SurfaceEventFilter(this));
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor OBSQTDisplay::GetDisplayBackgroundColor() const
|
|
|
|
--
|
|
|
|
2.28.0
|
|
|
|
|