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 4d7634184..89b1d9824 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> |
| @@ -1044,7 +1044,7 @@ void GMainWindow::InitializeHotkeys() { | |||
| 1044 | 1044 | ||
| 1045 | void GMainWindow::SetDefaultUIGeometry() { | 1045 | void GMainWindow::SetDefaultUIGeometry() { |
| 1046 | // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half | 1046 | // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half |
| 1047 | const QRect screenRect = QApplication::desktop()->screenGeometry(this); | 1047 | const QRect screenRect = QGuiApplication::primaryScreen()->geometry(); |
| 1048 | 1048 | ||
| 1049 | const int w = screenRect.width() * 2 / 3; | 1049 | const int w = screenRect.width() * 2 / 3; |
| 1050 | const int h = screenRect.height() * 2 / 3; | 1050 | const int h = screenRect.height() * 2 / 3; |
| @@ -2627,6 +2627,18 @@ void GMainWindow::ToggleFullscreen() { | |||
| 2627 | } | 2627 | } |
| 2628 | } | 2628 | } |
| 2629 | 2629 | ||
| 2630 | // We're going to return the screen that the given window has the most pixels on | ||
| 2631 | static QScreen* GuessCurrentScreen(QWidget* window) { | ||
| 2632 | const QList<QScreen*> screens = QGuiApplication::screens(); | ||
| 2633 | return *std::max_element( | ||
| 2634 | screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) { | ||
| 2635 | const QSize left_size = left->geometry().intersected(window->geometry()).size(); | ||
| 2636 | const QSize right_size = right->geometry().intersected(window->geometry()).size(); | ||
| 2637 | return (left_size.height() * left_size.width()) < | ||
| 2638 | (right_size.height() * right_size.width()); | ||
| 2639 | }); | ||
| 2640 | } | ||
| 2641 | |||
| 2630 | void GMainWindow::ShowFullscreen() { | 2642 | void GMainWindow::ShowFullscreen() { |
| 2631 | const auto show_fullscreen = [](QWidget* window) { | 2643 | const auto show_fullscreen = [](QWidget* window) { |
| 2632 | if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { | 2644 | if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { |
| @@ -2635,7 +2647,7 @@ void GMainWindow::ShowFullscreen() { | |||
| 2635 | } | 2647 | } |
| 2636 | window->hide(); | 2648 | window->hide(); |
| 2637 | window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); | 2649 | window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); |
| 2638 | const auto screen_geometry = QApplication::desktop()->screenGeometry(window); | 2650 | const auto screen_geometry = GuessCurrentScreen(window)->geometry(); |
| 2639 | window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), | 2651 | window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), |
| 2640 | screen_geometry.height() + 1); | 2652 | screen_geometry.height() + 1); |
| 2641 | window->raise(); | 2653 | window->raise(); |