Просмотр исходного кода

UI: Fix window start pos when not inside a monitor

Commit 8932bd39 attempted to fix the starting position when the program
started up inside of a monitor that no longer exists, but it was
incorrectly assumed that it would cause the program to automatically
center its position.  Instead it set its position to {0,0}, which is a
really awkward position.

This fixes that commit and ensures the window starts up centered to the
primary display when its saved starting position is invalid.
jp9000 9 лет назад
Родитель
Сommit
e9087cfdc9
1 измененных файлов с 10 добавлено и 4 удалено
  1. 10 4
      obs/window-basic-main.cpp

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

@@ -23,6 +23,7 @@
 #include <QShowEvent>
 #include <QDesktopServices>
 #include <QFileDialog>
+#include <QDesktopWidget>
 
 #include <util/dstr.h>
 #include <util/util.hpp>
@@ -132,10 +133,15 @@ OBSBasic::OBSBasic(QWidget *parent)
 		int posy = config_get_int(App()->GlobalConfig(), "BasicWindow",
 				"posy");
 
-		if (!WindowPositionValid(posx, posy))
-			posx = posy = 0;
-
-		setGeometry(posx, posy, width, height);
+		if (!WindowPositionValid(posx, posy)) {
+			QRect rect = App()->desktop()->availableGeometry();
+			setGeometry(QStyle::alignedRect(
+						Qt::LeftToRight,
+						Qt::AlignCenter,
+						size(), rect));
+		} else {
+			setGeometry(posx, posy, width, height);
+		}
 	}
 
 	char styleSheetPath[512];