UI: Add OBSQTDisplay::OnMove()/OnDisplayChange()
This plumbing will be useful when handling color space changes. Currently does nothing, and only Windows is wired for now.
This commit is contained in:
parent
5d1261eddb
commit
61ffb5c4d8
@ -8,6 +8,11 @@
|
||||
|
||||
#include <obs-config.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WAYLAND
|
||||
#include <obs-nix-platform.h>
|
||||
|
||||
@ -166,6 +171,37 @@ void OBSQTDisplay::CreateDisplay(bool force)
|
||||
emit DisplayCreated(this);
|
||||
}
|
||||
|
||||
void OBSQTDisplay::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
CreateDisplay();
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void OBSQTDisplay::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
QWidget::moveEvent(event);
|
||||
|
||||
OnMove();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool OBSQTDisplay::nativeEvent(const QByteArray &, void *message, qintptr *)
|
||||
#else
|
||||
bool OBSQTDisplay::nativeEvent(const QByteArray &, void *message, long *)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const MSG &msg = *static_cast<MSG *>(message);
|
||||
switch (msg.message) {
|
||||
case WM_DISPLAYCHANGE:
|
||||
OnDisplayChange();
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OBSQTDisplay::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
@ -180,14 +216,11 @@ void OBSQTDisplay::resizeEvent(QResizeEvent *event)
|
||||
emit DisplayResized();
|
||||
}
|
||||
|
||||
void OBSQTDisplay::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
CreateDisplay();
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
QPaintEngine *OBSQTDisplay::paintEngine() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void OBSQTDisplay::OnMove() {}
|
||||
|
||||
void OBSQTDisplay::OnDisplayChange() {}
|
||||
|
@ -13,8 +13,16 @@ class OBSQTDisplay : public QWidget {
|
||||
|
||||
OBSDisplay display;
|
||||
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
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);
|
||||
@ -35,4 +43,7 @@ public:
|
||||
void SetDisplayBackgroundColor(const QColor &color);
|
||||
void UpdateDisplayBackgroundColor();
|
||||
void CreateDisplay(bool force = false);
|
||||
|
||||
void OnMove();
|
||||
void OnDisplayChange();
|
||||
};
|
||||
|
@ -36,6 +36,11 @@
|
||||
#include <QMenu>
|
||||
#include <QVariant>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
Q_DECLARE_METATYPE(OBSSource);
|
||||
@ -686,6 +691,32 @@ void OBSBasicFilters::closeEvent(QCloseEvent *event)
|
||||
main->SaveProject();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool OBSBasicFilters::nativeEvent(const QByteArray &, void *message, qintptr *)
|
||||
#else
|
||||
bool OBSBasicFilters::nativeEvent(const QByteArray &, void *message, long *)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const MSG &msg = *static_cast<MSG *>(message);
|
||||
switch (msg.message) {
|
||||
case WM_MOVE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnMove();
|
||||
}
|
||||
break;
|
||||
case WM_DISPLAYCHANGE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnDisplayChange();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* OBS Signals */
|
||||
|
||||
void OBSBasicFilters::OBSSourceFilterAdded(void *param, calldata_t *data)
|
||||
|
@ -135,4 +135,11 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *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
|
||||
};
|
||||
|
@ -26,6 +26,11 @@
|
||||
#include <QScreen>
|
||||
#include <QWindow>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
OBSBasicInteraction::OBSBasicInteraction(QWidget *parent, OBSSource source_)
|
||||
@ -175,6 +180,33 @@ void OBSBasicInteraction::closeEvent(QCloseEvent *event)
|
||||
this);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool OBSBasicInteraction::nativeEvent(const QByteArray &, void *message,
|
||||
qintptr *)
|
||||
#else
|
||||
bool OBSBasicInteraction::nativeEvent(const QByteArray &, void *message, long *)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const MSG &msg = *static_cast<MSG *>(message);
|
||||
switch (msg.message) {
|
||||
case WM_MOVE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnMove();
|
||||
}
|
||||
break;
|
||||
case WM_DISPLAYCHANGE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnDisplayChange();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int TranslateQtKeyboardEventModifiers(QInputEvent *event,
|
||||
bool mouseEvent)
|
||||
{
|
||||
|
@ -65,6 +65,13 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *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
|
||||
};
|
||||
|
||||
typedef std::function<bool(QObject *, QEvent *)> EventFilterFunc;
|
||||
|
@ -4680,6 +4680,32 @@ void OBSBasic::closeEvent(QCloseEvent *event)
|
||||
QMetaObject::invokeMethod(App(), "quit", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool OBSBasic::nativeEvent(const QByteArray &, void *message, qintptr *)
|
||||
#else
|
||||
bool OBSBasic::nativeEvent(const QByteArray &, void *message, long *)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const MSG &msg = *static_cast<MSG *>(message);
|
||||
switch (msg.message) {
|
||||
case WM_MOVE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnMove();
|
||||
}
|
||||
break;
|
||||
case WM_DISPLAYCHANGE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnDisplayChange();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OBSBasic::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowStateChange) {
|
||||
|
@ -947,6 +947,13 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *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
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
|
@ -31,6 +31,11 @@
|
||||
#include <qpointer.h>
|
||||
#include <util/c99defs.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void CreateTransitionScene(OBSSource scene, const char *text,
|
||||
@ -512,6 +517,33 @@ void OBSBasicProperties::closeEvent(QCloseEvent *event)
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool OBSBasicProperties::nativeEvent(const QByteArray &, void *message,
|
||||
qintptr *)
|
||||
#else
|
||||
bool OBSBasicProperties::nativeEvent(const QByteArray &, void *message, long *)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const MSG &msg = *static_cast<MSG *>(message);
|
||||
switch (msg.message) {
|
||||
case WM_MOVE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnMove();
|
||||
}
|
||||
break;
|
||||
case WM_DISPLAYCHANGE:
|
||||
for (OBSQTDisplay *const display :
|
||||
findChildren<OBSQTDisplay *>()) {
|
||||
display->OnDisplayChange();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OBSBasicProperties::Init()
|
||||
{
|
||||
show();
|
||||
|
@ -72,5 +72,12 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *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
|
||||
virtual void reject() override;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user