Преглед изворни кода

Resize preview when OBS windows are moved between monitors

This should fix the previews in most cases when moving between monitors
with differing pixel ratios
Palana пре 11 година
родитељ
комит
9894bb4357
2 измењених фајлова са 19 додато и 0 уклоњено
  1. 10 0
      obs/window-basic-main.cpp
  2. 9 0
      obs/window-basic-properties.cpp

+ 10 - 0
obs/window-basic-main.cpp

@@ -37,6 +37,9 @@
 
 #include <sstream>
 
+#include <QScreen>
+#include <QWindow>
+
 using namespace std;
 
 Q_DECLARE_METATYPE(OBSScene);
@@ -53,6 +56,13 @@ OBSBasic::OBSBasic(QWidget *parent)
 	  ui            (new Ui::OBSBasic)
 {
 	ui->setupUi(this);
+
+	connect(windowHandle(), &QWindow::screenChanged, [this]() {
+		struct obs_video_info ovi;
+
+		if (obs_get_video_info(&ovi))
+			ResizePreview(ovi.base_width, ovi.base_height);
+	});
 }
 
 static inline bool HasAudioDevices(const char *source_id)

+ 9 - 0
obs/window-basic-properties.cpp

@@ -21,6 +21,9 @@
 #include "qt-wrappers.hpp"
 #include "display-helpers.hpp"
 
+#include <QScreen>
+#include <QWindow>
+
 using namespace std;
 
 OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
@@ -46,6 +49,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
 	layout()->addWidget(view);
 	layout()->setAlignment(view, Qt::AlignRight);
 	view->show();
+
+	connect(windowHandle(), &QWindow::screenChanged, [this]() {
+		if (resizeTimer)
+			killTimer(resizeTimer);
+		resizeTimer = startTimer(100);
+	});
 }
 
 void OBSBasicProperties::SourceRemoved(void *data, calldata_t params)