|
|
@@ -828,10 +828,15 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
|
|
|
SLOT(OpenFullScreenProjector()));
|
|
|
popup.addMenu(projectorMenu);
|
|
|
|
|
|
- if (GetMonitor() > -1)
|
|
|
+ if (GetMonitor() > -1) {
|
|
|
popup.addAction(QTStr("Windowed"), this,
|
|
|
SLOT(OpenWindowedProjector()));
|
|
|
|
|
|
+ } else if (!this->isMaximized()) {
|
|
|
+ popup.addAction(QTStr("ResizeProjectorWindowToContent"),
|
|
|
+ this, SLOT(ResizeToContent()));
|
|
|
+ }
|
|
|
+
|
|
|
popup.addAction(QTStr("Close"), this, SLOT(EscapeTriggered()));
|
|
|
popup.exec(QCursor::pos());
|
|
|
}
|
|
|
@@ -1055,6 +1060,33 @@ void OBSProjector::OpenWindowedProjector()
|
|
|
UpdateProjectorTitle(QT_UTF8(obs_source_get_name(source)));
|
|
|
}
|
|
|
|
|
|
+void OBSProjector::ResizeToContent()
|
|
|
+{
|
|
|
+ OBSSource source = GetSource();
|
|
|
+ uint32_t targetCX;
|
|
|
+ uint32_t targetCY;
|
|
|
+ int x, y, newX, newY;
|
|
|
+ float scale;
|
|
|
+
|
|
|
+ if (source) {
|
|
|
+ targetCX = std::max(obs_source_get_width(source), 1u);
|
|
|
+ targetCY = std::max(obs_source_get_height(source), 1u);
|
|
|
+ } else {
|
|
|
+ struct obs_video_info ovi;
|
|
|
+ obs_get_video_info(&ovi);
|
|
|
+ targetCX = ovi.base_width;
|
|
|
+ targetCY = ovi.base_height;
|
|
|
+ }
|
|
|
+
|
|
|
+ QSize size = this->size();
|
|
|
+ GetScaleAndCenterPos(targetCX, targetCY, size.width(), size.height(), x,
|
|
|
+ y, scale);
|
|
|
+
|
|
|
+ newX = size.width() - (x * 2);
|
|
|
+ newY = size.height() - (y * 2);
|
|
|
+ resize(newX, newY);
|
|
|
+}
|
|
|
+
|
|
|
void OBSProjector::closeEvent(QCloseEvent *event)
|
|
|
{
|
|
|
EscapeTriggered();
|