diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 47 | ||||
| -rw-r--r-- | src/yuzu/qt_common.cpp | 55 | ||||
| -rw-r--r-- | src/yuzu/qt_common.h | 15 |
4 files changed, 75 insertions, 44 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 0f8c1e6a6..2d7b9ab65 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -189,6 +189,8 @@ add_executable(yuzu | |||
| 189 | multiplayer/state.h | 189 | multiplayer/state.h |
| 190 | multiplayer/validation.h | 190 | multiplayer/validation.h |
| 191 | precompiled_headers.h | 191 | precompiled_headers.h |
| 192 | qt_common.cpp | ||
| 193 | qt_common.h | ||
| 192 | startup_checks.cpp | 194 | startup_checks.cpp |
| 193 | startup_checks.h | 195 | startup_checks.h |
| 194 | uisettings.cpp | 196 | uisettings.cpp |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1cf239496..98161cc27 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -43,8 +43,7 @@ | |||
| 43 | #include "video_core/renderer_base.h" | 43 | #include "video_core/renderer_base.h" |
| 44 | #include "yuzu/bootmanager.h" | 44 | #include "yuzu/bootmanager.h" |
| 45 | #include "yuzu/main.h" | 45 | #include "yuzu/main.h" |
| 46 | 46 | #include "yuzu/qt_common.h" | |
| 47 | static Core::Frontend::WindowSystemType GetWindowSystemType(); | ||
| 48 | 47 | ||
| 49 | EmuThread::EmuThread(Core::System& system) : m_system{system} {} | 48 | EmuThread::EmuThread(Core::System& system) : m_system{system} {} |
| 50 | 49 | ||
| @@ -233,7 +232,7 @@ public: | |||
| 233 | explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { | 232 | explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { |
| 234 | setAttribute(Qt::WA_NativeWindow); | 233 | setAttribute(Qt::WA_NativeWindow); |
| 235 | setAttribute(Qt::WA_PaintOnScreen); | 234 | setAttribute(Qt::WA_PaintOnScreen); |
| 236 | if (GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { | 235 | if (YuzuQtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { |
| 237 | setAttribute(Qt::WA_DontCreateNativeAncestors); | 236 | setAttribute(Qt::WA_DontCreateNativeAncestors); |
| 238 | } | 237 | } |
| 239 | } | 238 | } |
| @@ -271,46 +270,6 @@ struct NullRenderWidget : public RenderWidget { | |||
| 271 | explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {} | 270 | explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {} |
| 272 | }; | 271 | }; |
| 273 | 272 | ||
| 274 | static Core::Frontend::WindowSystemType GetWindowSystemType() { | ||
| 275 | // Determine WSI type based on Qt platform. | ||
| 276 | QString platform_name = QGuiApplication::platformName(); | ||
| 277 | if (platform_name == QStringLiteral("windows")) | ||
| 278 | return Core::Frontend::WindowSystemType::Windows; | ||
| 279 | else if (platform_name == QStringLiteral("xcb")) | ||
| 280 | return Core::Frontend::WindowSystemType::X11; | ||
| 281 | else if (platform_name == QStringLiteral("wayland")) | ||
| 282 | return Core::Frontend::WindowSystemType::Wayland; | ||
| 283 | else if (platform_name == QStringLiteral("wayland-egl")) | ||
| 284 | return Core::Frontend::WindowSystemType::Wayland; | ||
| 285 | else if (platform_name == QStringLiteral("cocoa")) | ||
| 286 | return Core::Frontend::WindowSystemType::Cocoa; | ||
| 287 | else if (platform_name == QStringLiteral("android")) | ||
| 288 | return Core::Frontend::WindowSystemType::Android; | ||
| 289 | |||
| 290 | LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString()); | ||
| 291 | return Core::Frontend::WindowSystemType::Windows; | ||
| 292 | } | ||
| 293 | |||
| 294 | static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) { | ||
| 295 | Core::Frontend::EmuWindow::WindowSystemInfo wsi; | ||
| 296 | wsi.type = GetWindowSystemType(); | ||
| 297 | |||
| 298 | // Our Win32 Qt external doesn't have the private API. | ||
| 299 | #if defined(WIN32) || defined(__APPLE__) | ||
| 300 | wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; | ||
| 301 | #else | ||
| 302 | QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); | ||
| 303 | wsi.display_connection = pni->nativeResourceForWindow("display", window); | ||
| 304 | if (wsi.type == Core::Frontend::WindowSystemType::Wayland) | ||
| 305 | wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr; | ||
| 306 | else | ||
| 307 | wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; | ||
| 308 | #endif | ||
| 309 | wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f; | ||
| 310 | |||
| 311 | return wsi; | ||
| 312 | } | ||
| 313 | |||
| 314 | GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, | 273 | GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, |
| 315 | std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, | 274 | std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, |
| 316 | Core::System& system_) | 275 | Core::System& system_) |
| @@ -916,7 +875,7 @@ bool GRenderWindow::InitRenderTarget() { | |||
| 916 | } | 875 | } |
| 917 | 876 | ||
| 918 | // Update the Window System information with the new render target | 877 | // Update the Window System information with the new render target |
| 919 | window_info = GetWindowSystemInfo(child_widget->windowHandle()); | 878 | window_info = YuzuQtCommon::GetWindowSystemInfo(child_widget->windowHandle()); |
| 920 | 879 | ||
| 921 | child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); | 880 | child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); |
| 922 | layout()->addWidget(child_widget); | 881 | layout()->addWidget(child_widget); |
diff --git a/src/yuzu/qt_common.cpp b/src/yuzu/qt_common.cpp new file mode 100644 index 000000000..1b533ee40 --- /dev/null +++ b/src/yuzu/qt_common.cpp | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <QGuiApplication> | ||
| 5 | #include <QStringLiteral> | ||
| 6 | #include <QWindow> | ||
| 7 | #include "common/logging/log.h" | ||
| 8 | #include "core/frontend/emu_window.h" | ||
| 9 | #include "yuzu/qt_common.h" | ||
| 10 | |||
| 11 | #ifdef __linux__ | ||
| 12 | #include <qpa/qplatformnativeinterface.h> | ||
| 13 | #endif | ||
| 14 | |||
| 15 | namespace YuzuQtCommon { | ||
| 16 | Core::Frontend::WindowSystemType GetWindowSystemType() { | ||
| 17 | // Determine WSI type based on Qt platform. | ||
| 18 | QString platform_name = QGuiApplication::platformName(); | ||
| 19 | if (platform_name == QStringLiteral("windows")) | ||
| 20 | return Core::Frontend::WindowSystemType::Windows; | ||
| 21 | else if (platform_name == QStringLiteral("xcb")) | ||
| 22 | return Core::Frontend::WindowSystemType::X11; | ||
| 23 | else if (platform_name == QStringLiteral("wayland")) | ||
| 24 | return Core::Frontend::WindowSystemType::Wayland; | ||
| 25 | else if (platform_name == QStringLiteral("wayland-egl")) | ||
| 26 | return Core::Frontend::WindowSystemType::Wayland; | ||
| 27 | else if (platform_name == QStringLiteral("cocoa")) | ||
| 28 | return Core::Frontend::WindowSystemType::Cocoa; | ||
| 29 | else if (platform_name == QStringLiteral("android")) | ||
| 30 | return Core::Frontend::WindowSystemType::Android; | ||
| 31 | |||
| 32 | LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString()); | ||
| 33 | return Core::Frontend::WindowSystemType::Windows; | ||
| 34 | } // namespace Core::Frontend::WindowSystemType | ||
| 35 | |||
| 36 | Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) { | ||
| 37 | Core::Frontend::EmuWindow::WindowSystemInfo wsi; | ||
| 38 | wsi.type = GetWindowSystemType(); | ||
| 39 | |||
| 40 | // Our Win32 Qt external doesn't have the private API. | ||
| 41 | #if defined(WIN32) || defined(__APPLE__) | ||
| 42 | wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; | ||
| 43 | #else | ||
| 44 | QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); | ||
| 45 | wsi.display_connection = pni->nativeResourceForWindow("display", window); | ||
| 46 | if (wsi.type == Core::Frontend::WindowSystemType::Wayland) | ||
| 47 | wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr; | ||
| 48 | else | ||
| 49 | wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; | ||
| 50 | #endif | ||
| 51 | wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f; | ||
| 52 | |||
| 53 | return wsi; | ||
| 54 | } | ||
| 55 | } // namespace YuzuQtCommon | ||
diff --git a/src/yuzu/qt_common.h b/src/yuzu/qt_common.h new file mode 100644 index 000000000..b366adee6 --- /dev/null +++ b/src/yuzu/qt_common.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <QWindow> | ||
| 7 | #include "core/frontend/emu_window.h" | ||
| 8 | |||
| 9 | namespace YuzuQtCommon { | ||
| 10 | |||
| 11 | Core::Frontend::WindowSystemType GetWindowSystemType(); | ||
| 12 | |||
| 13 | Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window); | ||
| 14 | |||
| 15 | } // namespace YuzuQtCommon | ||