f8d415afbe
This hooks the platform specific events in order to close the obs display more accurately. Earlier attempts on hooking visiblity, but Qt does not ensure that visibility is changed before the surface is destroyed. So we ended up racing with the EGL driver and on some drivers if you lose the race they hang. Also only force display creation if the display is actually visible. When a source type is not video/drawable (or is missing) this would force the display to be created for the blank window and also hang. Finally force closure of the preview displays during scene cleanup to avoid similar ordering issues in Qt. Qt has even less order guarentees during close and we are sure that displays are no longer needed at this point in the UI.
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <obs.hpp>
|
|
|
|
#define GREY_COLOR_BACKGROUND 0xFF4C4C4C
|
|
|
|
class OBSQTDisplay : public QWidget {
|
|
Q_OBJECT
|
|
Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor READ
|
|
GetDisplayBackgroundColor WRITE
|
|
SetDisplayBackgroundColor)
|
|
|
|
OBSDisplay display;
|
|
|
|
virtual void paintEvent(QPaintEvent *event) override;
|
|
virtual void moveEvent(QMoveEvent *event) override;
|
|
virtual void resizeEvent(QResizeEvent *event) override;
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
virtual bool nativeEvent(const QByteArray &eventType, void *message,
|
|
qintptr *result) override;
|
|
#else
|
|
virtual bool nativeEvent(const QByteArray &eventType, void *message,
|
|
long *result) override;
|
|
#endif
|
|
|
|
signals:
|
|
void DisplayCreated(OBSQTDisplay *window);
|
|
void DisplayResized();
|
|
|
|
public:
|
|
OBSQTDisplay(QWidget *parent = nullptr,
|
|
Qt::WindowFlags flags = Qt::WindowFlags());
|
|
~OBSQTDisplay() { display = nullptr; }
|
|
|
|
virtual QPaintEngine *paintEngine() const override;
|
|
|
|
inline obs_display_t *GetDisplay() const { return display; }
|
|
|
|
uint32_t backgroundColor = GREY_COLOR_BACKGROUND;
|
|
|
|
QColor GetDisplayBackgroundColor() const;
|
|
void SetDisplayBackgroundColor(const QColor &color);
|
|
void UpdateDisplayBackgroundColor();
|
|
void CreateDisplay(bool force = false);
|
|
void DestroyDisplay() { display = nullptr; };
|
|
|
|
void OnMove();
|
|
void OnDisplayChange();
|
|
};
|