mirror of https://git.suyu.dev/suyu/suyu
qt_common: Move window info function out of bootmanager
Function is useful outside of bootmanager, so put it in a common place. qt_common: Add missing include qt_common: Add some newlines qt_common: Add trailing newline qt_common: Add trainline newline
This commit is contained in:
parent
c6c11c1553
commit
cbd79df233
|
@ -189,6 +189,8 @@ add_executable(yuzu
|
||||||
multiplayer/state.h
|
multiplayer/state.h
|
||||||
multiplayer/validation.h
|
multiplayer/validation.h
|
||||||
precompiled_headers.h
|
precompiled_headers.h
|
||||||
|
qt_common.cpp
|
||||||
|
qt_common.h
|
||||||
startup_checks.cpp
|
startup_checks.cpp
|
||||||
startup_checks.h
|
startup_checks.h
|
||||||
uisettings.cpp
|
uisettings.cpp
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
#include "yuzu/bootmanager.h"
|
#include "yuzu/bootmanager.h"
|
||||||
#include "yuzu/main.h"
|
#include "yuzu/main.h"
|
||||||
|
#include "yuzu/qt_common.h"
|
||||||
static Core::Frontend::WindowSystemType GetWindowSystemType();
|
|
||||||
|
|
||||||
EmuThread::EmuThread(Core::System& system) : m_system{system} {}
|
EmuThread::EmuThread(Core::System& system) : m_system{system} {}
|
||||||
|
|
||||||
|
@ -233,7 +232,7 @@ public:
|
||||||
explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) {
|
explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) {
|
||||||
setAttribute(Qt::WA_NativeWindow);
|
setAttribute(Qt::WA_NativeWindow);
|
||||||
setAttribute(Qt::WA_PaintOnScreen);
|
setAttribute(Qt::WA_PaintOnScreen);
|
||||||
if (GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) {
|
if (YuzuQtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) {
|
||||||
setAttribute(Qt::WA_DontCreateNativeAncestors);
|
setAttribute(Qt::WA_DontCreateNativeAncestors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,46 +270,6 @@ struct NullRenderWidget : public RenderWidget {
|
||||||
explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {}
|
explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Core::Frontend::WindowSystemType GetWindowSystemType() {
|
|
||||||
// Determine WSI type based on Qt platform.
|
|
||||||
QString platform_name = QGuiApplication::platformName();
|
|
||||||
if (platform_name == QStringLiteral("windows"))
|
|
||||||
return Core::Frontend::WindowSystemType::Windows;
|
|
||||||
else if (platform_name == QStringLiteral("xcb"))
|
|
||||||
return Core::Frontend::WindowSystemType::X11;
|
|
||||||
else if (platform_name == QStringLiteral("wayland"))
|
|
||||||
return Core::Frontend::WindowSystemType::Wayland;
|
|
||||||
else if (platform_name == QStringLiteral("wayland-egl"))
|
|
||||||
return Core::Frontend::WindowSystemType::Wayland;
|
|
||||||
else if (platform_name == QStringLiteral("cocoa"))
|
|
||||||
return Core::Frontend::WindowSystemType::Cocoa;
|
|
||||||
else if (platform_name == QStringLiteral("android"))
|
|
||||||
return Core::Frontend::WindowSystemType::Android;
|
|
||||||
|
|
||||||
LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString());
|
|
||||||
return Core::Frontend::WindowSystemType::Windows;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
|
|
||||||
Core::Frontend::EmuWindow::WindowSystemInfo wsi;
|
|
||||||
wsi.type = GetWindowSystemType();
|
|
||||||
|
|
||||||
// Our Win32 Qt external doesn't have the private API.
|
|
||||||
#if defined(WIN32) || defined(__APPLE__)
|
|
||||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
|
||||||
#else
|
|
||||||
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
|
||||||
wsi.display_connection = pni->nativeResourceForWindow("display", window);
|
|
||||||
if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
|
|
||||||
wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
|
|
||||||
else
|
|
||||||
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
|
||||||
#endif
|
|
||||||
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
|
|
||||||
|
|
||||||
return wsi;
|
|
||||||
}
|
|
||||||
|
|
||||||
GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
|
GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_,
|
||||||
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
|
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_,
|
||||||
Core::System& system_)
|
Core::System& system_)
|
||||||
|
@ -916,7 +875,7 @@ bool GRenderWindow::InitRenderTarget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the Window System information with the new render target
|
// Update the Window System information with the new render target
|
||||||
window_info = GetWindowSystemInfo(child_widget->windowHandle());
|
window_info = YuzuQtCommon::GetWindowSystemInfo(child_widget->windowHandle());
|
||||||
|
|
||||||
child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
|
child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
|
||||||
layout()->addWidget(child_widget);
|
layout()->addWidget(child_widget);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QStringLiteral>
|
||||||
|
#include <QWindow>
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
#include "core/frontend/emu_window.h"
|
||||||
|
#include "yuzu/qt_common.h"
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace YuzuQtCommon {
|
||||||
|
Core::Frontend::WindowSystemType GetWindowSystemType() {
|
||||||
|
// Determine WSI type based on Qt platform.
|
||||||
|
QString platform_name = QGuiApplication::platformName();
|
||||||
|
if (platform_name == QStringLiteral("windows"))
|
||||||
|
return Core::Frontend::WindowSystemType::Windows;
|
||||||
|
else if (platform_name == QStringLiteral("xcb"))
|
||||||
|
return Core::Frontend::WindowSystemType::X11;
|
||||||
|
else if (platform_name == QStringLiteral("wayland"))
|
||||||
|
return Core::Frontend::WindowSystemType::Wayland;
|
||||||
|
else if (platform_name == QStringLiteral("wayland-egl"))
|
||||||
|
return Core::Frontend::WindowSystemType::Wayland;
|
||||||
|
else if (platform_name == QStringLiteral("cocoa"))
|
||||||
|
return Core::Frontend::WindowSystemType::Cocoa;
|
||||||
|
else if (platform_name == QStringLiteral("android"))
|
||||||
|
return Core::Frontend::WindowSystemType::Android;
|
||||||
|
|
||||||
|
LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString());
|
||||||
|
return Core::Frontend::WindowSystemType::Windows;
|
||||||
|
} // namespace Core::Frontend::WindowSystemType
|
||||||
|
|
||||||
|
Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
|
||||||
|
Core::Frontend::EmuWindow::WindowSystemInfo wsi;
|
||||||
|
wsi.type = GetWindowSystemType();
|
||||||
|
|
||||||
|
// Our Win32 Qt external doesn't have the private API.
|
||||||
|
#if defined(WIN32) || defined(__APPLE__)
|
||||||
|
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||||
|
#else
|
||||||
|
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
||||||
|
wsi.display_connection = pni->nativeResourceForWindow("display", window);
|
||||||
|
if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
|
||||||
|
wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
|
||||||
|
else
|
||||||
|
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
|
||||||
|
#endif
|
||||||
|
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
|
||||||
|
|
||||||
|
return wsi;
|
||||||
|
}
|
||||||
|
} // namespace YuzuQtCommon
|
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWindow>
|
||||||
|
#include "core/frontend/emu_window.h"
|
||||||
|
|
||||||
|
namespace YuzuQtCommon {
|
||||||
|
|
||||||
|
Core::Frontend::WindowSystemType GetWindowSystemType();
|
||||||
|
|
||||||
|
Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window);
|
||||||
|
|
||||||
|
} // namespace YuzuQtCommon
|
Loading…
Reference in New Issue