Kaynağa Gözat

UI: Removes the workaround of not receiving expose event

The commit e67fdbca79 is a workaround for QtWayland bug that the
`QEvent::Expose` was never received on a certain condition.
The bugfix was introduced to QtWayland 6.1.0 so that the workaround is
not necessary for now.
Norihiro Kamae 2 yıl önce
ebeveyn
işleme
fa17168ba2
2 değiştirilmiş dosya ile 3 ekleme ve 73 silme
  1. 2 72
      UI/qt-display.cpp
  2. 1 1
      UI/qt-display.hpp

+ 2 - 72
UI/qt-display.cpp

@@ -13,70 +13,6 @@
 #include <Windows.h>
 #endif
 
-#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()) {
-		case QEvent::PlatformSurface:
-			surfaceEvent =
-				static_cast<QPlatformSurfaceEvent *>(event);
-
-			switch (surfaceEvent->surfaceEventType()) {
-			case QPlatformSurfaceEvent::SurfaceCreated:
-				if (display->windowHandle()->isExposed())
-					createOBSDisplay();
-				else
-					mTimerId = startTimer(67); // Arbitrary
-				break;
-			case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
-				display->DestroyDisplay();
-				break;
-			default:
-				break;
-			}
-
-			break;
-		case QEvent::Expose:
-			createOBSDisplay();
-			break;
-		default:
-			break;
-		}
-
-		return result;
-	}
-
-	void timerEvent(QTimerEvent *) override
-	{
-		createOBSDisplay(display->isVisible());
-	}
-
-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)
 {
 	auto shift = [&](unsigned val, int shift) {
@@ -129,12 +65,6 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
 
 	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
@@ -157,12 +87,12 @@ void OBSQTDisplay::UpdateDisplayBackgroundColor()
 	obs_display_set_background_color(display, backgroundColor);
 }
 
-void OBSQTDisplay::CreateDisplay(bool force)
+void OBSQTDisplay::CreateDisplay()
 {
 	if (display)
 		return;
 
-	if (!windowHandle()->isExposed() && !force)
+	if (!windowHandle()->isExposed())
 		return;
 
 	QSize size = GetPixelSize(this);

+ 1 - 1
UI/qt-display.hpp

@@ -37,7 +37,7 @@ public:
 	QColor GetDisplayBackgroundColor() const;
 	void SetDisplayBackgroundColor(const QColor &color);
 	void UpdateDisplayBackgroundColor();
-	void CreateDisplay(bool force = false);
+	void CreateDisplay();
 	void DestroyDisplay() { display = nullptr; };
 
 	void OnMove();