diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/main.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f4a9a7171..574e2d263 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -52,7 +52,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual | |||
| 52 | #define QT_NO_OPENGL | 52 | #define QT_NO_OPENGL |
| 53 | #include <QClipboard> | 53 | #include <QClipboard> |
| 54 | #include <QDesktopServices> | 54 | #include <QDesktopServices> |
| 55 | #include <QDesktopWidget> | ||
| 56 | #include <QFile> | 55 | #include <QFile> |
| 57 | #include <QFileDialog> | 56 | #include <QFileDialog> |
| 58 | #include <QInputDialog> | 57 | #include <QInputDialog> |
| @@ -60,6 +59,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual | |||
| 60 | #include <QProgressBar> | 59 | #include <QProgressBar> |
| 61 | #include <QProgressDialog> | 60 | #include <QProgressDialog> |
| 62 | #include <QPushButton> | 61 | #include <QPushButton> |
| 62 | #include <QScreen> | ||
| 63 | #include <QShortcut> | 63 | #include <QShortcut> |
| 64 | #include <QStatusBar> | 64 | #include <QStatusBar> |
| 65 | #include <QString> | 65 | #include <QString> |
| @@ -1002,7 +1002,7 @@ void GMainWindow::InitializeHotkeys() { | |||
| 1002 | 1002 | ||
| 1003 | void GMainWindow::SetDefaultUIGeometry() { | 1003 | void GMainWindow::SetDefaultUIGeometry() { |
| 1004 | // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half | 1004 | // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half |
| 1005 | const QRect screenRect = QApplication::desktop()->screenGeometry(this); | 1005 | const QRect screenRect = QGuiApplication::primaryScreen()->geometry(); |
| 1006 | 1006 | ||
| 1007 | const int w = screenRect.width() * 2 / 3; | 1007 | const int w = screenRect.width() * 2 / 3; |
| 1008 | const int h = screenRect.height() * 2 / 3; | 1008 | const int h = screenRect.height() * 2 / 3; |
| @@ -2581,6 +2581,18 @@ void GMainWindow::ToggleFullscreen() { | |||
| 2581 | } | 2581 | } |
| 2582 | } | 2582 | } |
| 2583 | 2583 | ||
| 2584 | // We're going to return the screen that the given window has the most pixels on | ||
| 2585 | static QScreen* GuessCurrentScreen(QWidget* window) { | ||
| 2586 | const QList<QScreen*> screens = QGuiApplication::screens(); | ||
| 2587 | return *std::max_element( | ||
| 2588 | screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) { | ||
| 2589 | const QSize left_size = left->geometry().intersected(window->geometry()).size(); | ||
| 2590 | const QSize right_size = right->geometry().intersected(window->geometry()).size(); | ||
| 2591 | return (left_size.height() * left_size.width()) < | ||
| 2592 | (right_size.height() * right_size.width()); | ||
| 2593 | }); | ||
| 2594 | } | ||
| 2595 | |||
| 2584 | void GMainWindow::ShowFullscreen() { | 2596 | void GMainWindow::ShowFullscreen() { |
| 2585 | const auto show_fullscreen = [](QWidget* window) { | 2597 | const auto show_fullscreen = [](QWidget* window) { |
| 2586 | if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { | 2598 | if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { |
| @@ -2589,7 +2601,7 @@ void GMainWindow::ShowFullscreen() { | |||
| 2589 | } | 2601 | } |
| 2590 | window->hide(); | 2602 | window->hide(); |
| 2591 | window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); | 2603 | window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); |
| 2592 | const auto screen_geometry = QApplication::desktop()->screenGeometry(window); | 2604 | const auto screen_geometry = GuessCurrentScreen(window)->geometry(); |
| 2593 | window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), | 2605 | window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), |
| 2594 | screen_geometry.height() + 1); | 2606 | screen_geometry.height() + 1); |
| 2595 | window->raise(); | 2607 | window->raise(); |