summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMai M <mathew1800@gmail.com>2022-06-11 19:20:36 +0200
committerGitHub <noreply@github.com>2022-06-11 19:20:36 +0200
commit89e00c442dc82167a66b964e4a1e65b5b06fe08b (patch)
tree0ff186fcee22ffd9e78aa659fa5b7fcf8efda830 /src
parentMerge pull request #8449 from Docteh/translate_placeholder (diff)
parentdeprecate usage of QDesktopWidget for going fullscreen (diff)
downloadyuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar.gz
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar.bz2
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar.lz
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar.xz
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.tar.zst
yuzu-89e00c442dc82167a66b964e4a1e65b5b06fe08b.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 4d7634184..89b1d9824 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -52,7 +52,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#define QT_NO_OPENGL
#include <QClipboard>
#include <QDesktopServices>
-#include <QDesktopWidget>
#include <QFile>
#include <QFileDialog>
#include <QInputDialog>
@@ -60,6 +59,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include <QProgressBar>
#include <QProgressDialog>
#include <QPushButton>
+#include <QScreen>
#include <QShortcut>
#include <QStatusBar>
#include <QString>
@@ -1044,7 +1044,7 @@ void GMainWindow::InitializeHotkeys() {
void GMainWindow::SetDefaultUIGeometry() {
// geometry: 53% of the window contents are in the upper screen half, 47% in the lower half
- const QRect screenRect = QApplication::desktop()->screenGeometry(this);
+ const QRect screenRect = QGuiApplication::primaryScreen()->geometry();
const int w = screenRect.width() * 2 / 3;
const int h = screenRect.height() * 2 / 3;
@@ -2627,6 +2627,18 @@ void GMainWindow::ToggleFullscreen() {
}
}
+// We're going to return the screen that the given window has the most pixels on
+static QScreen* GuessCurrentScreen(QWidget* window) {
+ const QList<QScreen*> screens = QGuiApplication::screens();
+ return *std::max_element(
+ screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) {
+ const QSize left_size = left->geometry().intersected(window->geometry()).size();
+ const QSize right_size = right->geometry().intersected(window->geometry()).size();
+ return (left_size.height() * left_size.width()) <
+ (right_size.height() * right_size.width());
+ });
+}
+
void GMainWindow::ShowFullscreen() {
const auto show_fullscreen = [](QWidget* window) {
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
@@ -2635,7 +2647,7 @@ void GMainWindow::ShowFullscreen() {
}
window->hide();
window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint);
- const auto screen_geometry = QApplication::desktop()->screenGeometry(window);
+ const auto screen_geometry = GuessCurrentScreen(window)->geometry();
window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(),
screen_geometry.height() + 1);
window->raise();