mirror of
https://github.com/stenzek/duckstation.git
synced 2026-04-20 21:16:12 +00:00
WindowInfo: Extract type into global namespace
This commit is contained in:
@@ -3483,8 +3483,7 @@ void Achievements::FinishLoadRAIntegration()
|
||||
|
||||
const char* error_message = nullptr;
|
||||
const int res = rc_client_finish_load_raintegration(
|
||||
s_state.client,
|
||||
(wi.has_value() && wi->type == WindowInfo::Type::Win32) ? static_cast<HWND>(wi->window_handle) : NULL,
|
||||
s_state.client, (wi.has_value() && wi->type == WindowInfoType::Win32) ? static_cast<HWND>(wi->window_handle) : NULL,
|
||||
"DuckStation", g_scm_tag_str, &error_message);
|
||||
if (res != RC_OK)
|
||||
{
|
||||
|
||||
@@ -514,7 +514,7 @@ std::optional<WindowInfo> MiniHost::TranslateSDLWindowInfo(SDL_Window* win, Erro
|
||||
}
|
||||
|
||||
#if defined(SDL_PLATFORM_WINDOWS)
|
||||
wi.type = WindowInfo::Type::Win32;
|
||||
wi.type = WindowInfoType::Win32;
|
||||
wi.window_handle = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
||||
if (!wi.window_handle)
|
||||
{
|
||||
@@ -522,7 +522,7 @@ std::optional<WindowInfo> MiniHost::TranslateSDLWindowInfo(SDL_Window* win, Erro
|
||||
return std::nullopt;
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_MACOS)
|
||||
wi.type = WindowInfo::Type::MacOS;
|
||||
wi.type = WindowInfoType::MacOS;
|
||||
wi.window_handle = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
|
||||
if (!wi.window_handle)
|
||||
{
|
||||
@@ -574,7 +574,7 @@ std::optional<WindowInfo> MiniHost::TranslateSDLWindowInfo(SDL_Window* win, Erro
|
||||
else
|
||||
{
|
||||
// nothing handled, fall back to SDL abstraction
|
||||
wi.type = WindowInfo::Type::SDL;
|
||||
wi.type = WindowInfoType::SDL;
|
||||
wi.window_handle = win;
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ void MiniHost::ProcessCoreThreadEvents(bool block)
|
||||
ProcessCoreThreadPlatformMessages();
|
||||
InputManager::PollSources();
|
||||
} while (!s_state.core_thread_event_posted.wait_for(lock, CORE_THREAD_POLL_INTERVAL,
|
||||
[]() { return !s_state.core_thread_events.empty(); }));
|
||||
[]() { return !s_state.core_thread_events.empty(); }));
|
||||
}
|
||||
|
||||
// return after processing all events if we had one
|
||||
|
||||
@@ -67,10 +67,10 @@ std::optional<WindowInfo> QtUtils::GetWindowInfoForWidget(QWidget* widget, Rende
|
||||
|
||||
// Windows and Apple are easy here since there's no display connection.
|
||||
#if defined(_WIN32)
|
||||
wi.type = WindowInfo::Type::Win32;
|
||||
wi.type = WindowInfoType::Win32;
|
||||
wi.window_handle = reinterpret_cast<void*>(widget->winId());
|
||||
#elif defined(__APPLE__)
|
||||
wi.type = WindowInfo::Type::MacOS;
|
||||
wi.type = WindowInfoType::MacOS;
|
||||
wi.window_handle = reinterpret_cast<void*>(widget->winId());
|
||||
#else
|
||||
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
|
||||
@@ -83,19 +83,19 @@ std::optional<WindowInfo> QtUtils::GetWindowInfoForWidget(QWidget* widget, Rende
|
||||
const bool is_running_on_xwayland = (xdg_session_type && std::strstr(xdg_session_type, "wayland"));
|
||||
if (is_running_on_xwayland || render_api == RenderAPI::Vulkan)
|
||||
{
|
||||
wi.type = WindowInfo::Type::XCB;
|
||||
wi.type = WindowInfoType::XCB;
|
||||
wi.display_connection = pni->nativeResourceForWindow("connection", widget->windowHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
wi.type = WindowInfo::Type::Xlib;
|
||||
wi.type = WindowInfoType::Xlib;
|
||||
wi.display_connection = pni->nativeResourceForWindow("display", widget->windowHandle());
|
||||
}
|
||||
wi.window_handle = reinterpret_cast<void*>(widget->winId());
|
||||
}
|
||||
else if (platform_name == QStringLiteral("wayland"))
|
||||
{
|
||||
wi.type = WindowInfo::Type::Wayland;
|
||||
wi.type = WindowInfoType::Wayland;
|
||||
wi.display_connection = pni->nativeResourceForWindow("display", widget->windowHandle());
|
||||
wi.window_handle = pni->nativeResourceForWindow("surface", widget->windowHandle());
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ bool D3D11SwapChain::CreateRTV(Error* error)
|
||||
m_window_info.surface_format = s_swap_chain_format;
|
||||
VERBOSE_LOG("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||
|
||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||
if (m_window_info.type == WindowInfoType::Win32)
|
||||
{
|
||||
BOOL fullscreen = FALSE;
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
@@ -470,7 +470,7 @@ std::unique_ptr<GPUSwapChain> D3D11Device::CreateSwapChain(const WindowInfo& wi,
|
||||
Error* error)
|
||||
{
|
||||
std::unique_ptr<D3D11SwapChain> ret;
|
||||
if (wi.type != WindowInfo::Type::Win32)
|
||||
if (wi.type != WindowInfoType::Win32)
|
||||
{
|
||||
Error::SetStringView(error, "Cannot create a swap chain on non-win32 window.");
|
||||
return ret;
|
||||
|
||||
@@ -1100,7 +1100,7 @@ std::unique_ptr<GPUSwapChain> D3D12Device::CreateSwapChain(const WindowInfo& wi,
|
||||
Error* error)
|
||||
{
|
||||
std::unique_ptr<D3D12SwapChain> ret;
|
||||
if (wi.type != WindowInfo::Type::Win32)
|
||||
if (wi.type != WindowInfoType::Win32)
|
||||
{
|
||||
Error::SetStringView(error, "Cannot create a swap chain on non-win32 window.");
|
||||
return ret;
|
||||
|
||||
@@ -94,7 +94,7 @@ bool DInputSource::Initialize(const SettingsInterface& si, std::unique_lock<std:
|
||||
const std::optional<WindowInfo> toplevel_wi(Host::GetTopLevelWindowInfo());
|
||||
settings_lock.lock();
|
||||
|
||||
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfo::Type::Win32)
|
||||
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfoType::Win32)
|
||||
{
|
||||
ERROR_LOG("Missing top level window, cannot add DInput devices.");
|
||||
return false;
|
||||
|
||||
@@ -153,20 +153,20 @@ std::unique_ptr<OpenGLContext> OpenGLContext::Create(WindowInfo& wi, SurfaceHand
|
||||
context = OpenGLContextEGLAndroid::Create(wi, surface, versions_to_try, error);
|
||||
#else
|
||||
#if defined(ENABLE_X11)
|
||||
if (wi.type == WindowInfo::Type::Xlib)
|
||||
if (wi.type == WindowInfoType::Xlib)
|
||||
context = OpenGLContextEGLXlib::Create(wi, surface, versions_to_try, error);
|
||||
else if (wi.type == WindowInfo::Type::XCB)
|
||||
else if (wi.type == WindowInfoType::XCB)
|
||||
context = OpenGLContextEGLXCB::Create(wi, surface, versions_to_try, error);
|
||||
#endif
|
||||
#if defined(ENABLE_WAYLAND)
|
||||
if (wi.type == WindowInfo::Type::Wayland)
|
||||
if (wi.type == WindowInfoType::Wayland)
|
||||
context = OpenGLContextEGLWayland::Create(wi, surface, versions_to_try, error);
|
||||
#endif
|
||||
if (wi.type == WindowInfo::Type::Surfaceless)
|
||||
if (wi.type == WindowInfoType::Surfaceless)
|
||||
context = OpenGLContextEGL::Create(wi, surface, versions_to_try, error);
|
||||
#endif
|
||||
#ifdef ENABLE_SDL
|
||||
if (wi.type == WindowInfo::Type::SDL)
|
||||
if (wi.type == WindowInfoType::SDL)
|
||||
context = OpenGLContextSDL::Create(wi, surface, versions_to_try, error);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ bool OpenGLContextSDL::Initialize(WindowInfo& wi, SurfaceHandle* surface, std::s
|
||||
Error::SetStringView(error, "Surfaceless is not supported with OpenGLContextSDL.");
|
||||
return false;
|
||||
}
|
||||
else if (wi.type != WindowInfo::Type::SDL)
|
||||
else if (wi.type != WindowInfoType::SDL)
|
||||
{
|
||||
Error::SetStringView(error, "Incompatible window type.");
|
||||
return false;
|
||||
@@ -92,7 +92,7 @@ OpenGLContext::SurfaceHandle OpenGLContextSDL::CreateSurface(WindowInfo& wi, Err
|
||||
Error::SetStringView(error, "Trying to create a surfaceless surface.");
|
||||
return nullptr;
|
||||
}
|
||||
else if (wi.type != WindowInfo::Type::SDL)
|
||||
else if (wi.type != WindowInfoType::SDL)
|
||||
{
|
||||
Error::SetStringView(error, "Incompatible window type.");
|
||||
return nullptr;
|
||||
|
||||
@@ -279,7 +279,7 @@ std::unique_ptr<OpenGLContext> OpenGLContextWGL::CreateSharedContext(WindowInfo&
|
||||
|
||||
HDC OpenGLContextWGL::CreateDCAndSetPixelFormat(WindowInfo& wi, Error* error)
|
||||
{
|
||||
if (wi.type != WindowInfo::Type::Win32)
|
||||
if (wi.type != WindowInfoType::Win32)
|
||||
{
|
||||
Error::SetStringFmt(error, "Unknown window info type {}", static_cast<unsigned>(wi.type));
|
||||
return NULL;
|
||||
@@ -374,7 +374,7 @@ HDC OpenGLContextWGL::GetPBufferDC(Error* error)
|
||||
ScopedGuard hwnd_guard([hwnd]() { DestroyWindow(hwnd); });
|
||||
|
||||
WindowInfo wi;
|
||||
wi.type = WindowInfo::Type::Win32;
|
||||
wi.type = WindowInfoType::Win32;
|
||||
wi.window_handle = hwnd;
|
||||
HDC hdc = CreateDCAndSetPixelFormat(wi, error);
|
||||
if (!hdc)
|
||||
|
||||
@@ -253,37 +253,37 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
};
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
if (wi.type == WindowInfo::Type::Win32 && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, true)))
|
||||
if (wi.type == WindowInfoType::Win32 && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, true)))
|
||||
return false;
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
if (wi.type == WindowInfo::Type::XCB && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME, true)))
|
||||
if (wi.type == WindowInfoType::XCB && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME, true)))
|
||||
return false;
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
if (wi.type == WindowInfo::Type::Wayland && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, true)))
|
||||
if (wi.type == WindowInfoType::Wayland && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, true)))
|
||||
return false;
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
if (wi.type == WindowInfo::Type::MacOS && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_EXT_METAL_SURFACE_EXTENSION_NAME, true)))
|
||||
if (wi.type == WindowInfoType::MacOS && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_EXT_METAL_SURFACE_EXTENSION_NAME, true)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
if (wi.type == WindowInfo::Type::Android && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, true)))
|
||||
if (wi.type == WindowInfoType::Android && (!SupportsExtension(VK_KHR_SURFACE_EXTENSION_NAME, true) ||
|
||||
!SupportsExtension(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, true)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SDL)
|
||||
if (wi.type == WindowInfo::Type::SDL)
|
||||
if (wi.type == WindowInfoType::SDL)
|
||||
{
|
||||
Uint32 sdl_extension_count = 0;
|
||||
const char* const* sdl_extensions = SDL_Vulkan_GetInstanceExtensions(&sdl_extension_count);
|
||||
@@ -308,12 +308,12 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
// Needed for exclusive fullscreen control.
|
||||
SupportsExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false);
|
||||
|
||||
oe->vk_khr_get_surface_capabilities2 = (wi.type != WindowInfo::Type::Surfaceless &&
|
||||
oe->vk_khr_get_surface_capabilities2 = (wi.type != WindowInfoType::Surfaceless &&
|
||||
SupportsExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false));
|
||||
oe->vk_ext_surface_maintenance1 =
|
||||
(wi.type != WindowInfo::Type::Surfaceless && SupportsExtension(VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, false));
|
||||
oe->vk_ext_swapchain_maintenance1 = (wi.type != WindowInfo::Type::Surfaceless &&
|
||||
SupportsExtension(VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, false));
|
||||
(wi.type != WindowInfoType::Surfaceless && SupportsExtension(VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, false));
|
||||
oe->vk_ext_swapchain_maintenance1 =
|
||||
(wi.type != WindowInfoType::Surfaceless && SupportsExtension(VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, false));
|
||||
oe->vk_khr_get_physical_device_properties2 =
|
||||
SupportsExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, false);
|
||||
|
||||
@@ -1991,7 +1991,7 @@ bool VulkanDevice::CreateDeviceAndMainSwapChain(std::string_view adapter, Create
|
||||
|
||||
#ifdef ENABLE_SDL
|
||||
const bool library_loaded =
|
||||
(wi.type == WindowInfo::Type::SDL) ? Vulkan::LoadVulkanLibraryFromSDL(error) : Vulkan::LoadVulkanLibrary(error);
|
||||
(wi.type == WindowInfoType::SDL) ? Vulkan::LoadVulkanLibraryFromSDL(error) : Vulkan::LoadVulkanLibrary(error);
|
||||
#else
|
||||
const bool library_loaded = Vulkan::LoadVulkanLibrary(error);
|
||||
#endif
|
||||
|
||||
@@ -85,7 +85,7 @@ VulkanSwapChain::~VulkanSwapChain()
|
||||
bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physical_device, Error* error)
|
||||
{
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||
if (m_window_info.type == WindowInfoType::Win32)
|
||||
{
|
||||
const VkWin32SurfaceCreateInfoKHR surface_create_info = {.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
|
||||
.pNext = nullptr,
|
||||
@@ -104,7 +104,7 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
if (m_window_info.type == WindowInfo::Type::MacOS)
|
||||
if (m_window_info.type == WindowInfoType::MacOS)
|
||||
{
|
||||
m_metal_layer = CocoaTools::CreateMetalLayer(m_window_info, error);
|
||||
if (!m_metal_layer)
|
||||
@@ -126,7 +126,7 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
if (m_window_info.type == WindowInfo::Type::Android)
|
||||
if (m_window_info.type == WindowInfoType::Android)
|
||||
{
|
||||
const VkAndroidSurfaceCreateInfoKHR surface_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
|
||||
@@ -145,7 +145,7 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
if (m_window_info.type == WindowInfo::Type::XCB)
|
||||
if (m_window_info.type == WindowInfoType::XCB)
|
||||
{
|
||||
const VkXcbSurfaceCreateInfoKHR surface_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
|
||||
@@ -165,7 +165,7 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
if (m_window_info.type == WindowInfo::Type::Wayland)
|
||||
if (m_window_info.type == WindowInfoType::Wayland)
|
||||
{
|
||||
const VkWaylandSurfaceCreateInfoKHR surface_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
|
||||
@@ -185,7 +185,7 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SDL)
|
||||
if (m_window_info.type == WindowInfo::Type::SDL)
|
||||
if (m_window_info.type == WindowInfoType::SDL)
|
||||
{
|
||||
if (!SDL_Vulkan_CreateSurface(static_cast<SDL_Window*>(m_window_info.window_handle), instance, nullptr, &m_surface))
|
||||
{
|
||||
|
||||
@@ -433,8 +433,7 @@ bool Win32RawInputSource::ProcessRawInputEvent(const RAWINPUT* event)
|
||||
|
||||
// This is truely awful. But for something that isn't used much, it's the easiest way to get the render rect...
|
||||
const WindowInfo& render_wi = GPUThread::GetRenderWindowInfo();
|
||||
if (render_wi.type == WindowInfo::Type::Win32 &&
|
||||
GetWindowRect(static_cast<HWND>(render_wi.window_handle), &rect))
|
||||
if (render_wi.type == WindowInfoType::Win32 && GetWindowRect(static_cast<HWND>(render_wi.window_handle), &rect))
|
||||
{
|
||||
absolute_x -= rect.left;
|
||||
absolute_y -= rect.top;
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
LOG_CHANNEL(WindowInfo);
|
||||
|
||||
WindowInfo::WindowInfo()
|
||||
: type(Type::Surfaceless), surface_format(GPUTextureFormat::Unknown), surface_prerotation(PreRotation::Identity),
|
||||
surface_width(0), surface_height(0), surface_refresh_rate(0.0f), surface_scale(1.0f), display_connection(nullptr),
|
||||
window_handle(nullptr)
|
||||
: type(WindowInfoType::Surfaceless), surface_format(GPUTextureFormat::Unknown),
|
||||
surface_prerotation(PreRotation::Identity), surface_width(0), surface_height(0), surface_refresh_rate(0.0f),
|
||||
surface_scale(1.0f), display_connection(nullptr), window_handle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ static std::optional<float> GetRefreshRateFromMonitor(HWND hwnd, Error* error)
|
||||
std::optional<float> WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, Error* error)
|
||||
{
|
||||
std::optional<float> ret;
|
||||
if (wi.type != Type::Win32 || !wi.window_handle)
|
||||
if (wi.type != WindowInfoType::Win32 || !wi.window_handle)
|
||||
{
|
||||
Error::SetStringView(error, "Invalid window type.");
|
||||
return ret;
|
||||
@@ -213,7 +213,7 @@ std::optional<float> WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi,
|
||||
|
||||
std::optional<float> WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, Error* error)
|
||||
{
|
||||
if (wi.type == WindowInfo::Type::MacOS)
|
||||
if (wi.type == WindowInfoType::MacOS)
|
||||
return CocoaTools::GetViewRefreshRate(wi, error);
|
||||
|
||||
Error::SetStringView(error, "Invalid window type.");
|
||||
@@ -229,7 +229,7 @@ std::optional<float> WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi,
|
||||
std::optional<float> WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, Error* error)
|
||||
{
|
||||
#if defined(ENABLE_X11)
|
||||
if (wi.type == WindowInfo::Type::Xlib || wi.type == WindowInfo::Type::XCB)
|
||||
if (wi.type == WindowInfoType::Xlib || wi.type == WindowInfoType::XCB)
|
||||
return GetRefreshRateFromXRandR(wi, error);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,21 +11,21 @@ class Error;
|
||||
|
||||
enum class GPUTextureFormat : u8;
|
||||
|
||||
enum class WindowInfoType : u8
|
||||
{
|
||||
Surfaceless,
|
||||
Win32,
|
||||
Xlib,
|
||||
XCB,
|
||||
Wayland,
|
||||
MacOS,
|
||||
Android,
|
||||
SDL,
|
||||
};
|
||||
|
||||
// Contains the information required to create a graphics context in a window.
|
||||
struct WindowInfo
|
||||
{
|
||||
enum class Type : u8
|
||||
{
|
||||
Surfaceless,
|
||||
Win32,
|
||||
Xlib,
|
||||
XCB,
|
||||
Wayland,
|
||||
MacOS,
|
||||
Android,
|
||||
SDL,
|
||||
};
|
||||
|
||||
enum class PreRotation : u8
|
||||
{
|
||||
Identity,
|
||||
@@ -36,7 +36,7 @@ struct WindowInfo
|
||||
|
||||
WindowInfo();
|
||||
|
||||
Type type;
|
||||
WindowInfoType type;
|
||||
GPUTextureFormat surface_format;
|
||||
PreRotation surface_prerotation;
|
||||
u16 surface_width;
|
||||
@@ -46,7 +46,7 @@ struct WindowInfo
|
||||
void* display_connection;
|
||||
void* window_handle;
|
||||
|
||||
ALWAYS_INLINE bool IsSurfaceless() const { return type == Type::Surfaceless; }
|
||||
ALWAYS_INLINE bool IsSurfaceless() const { return type == WindowInfoType::Surfaceless; }
|
||||
|
||||
ALWAYS_INLINE u32 GetPostRotatedWidth() const
|
||||
{
|
||||
|
||||
@@ -431,14 +431,14 @@ void X11Window::Resize(u16 width, u16 height)
|
||||
std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi, Error* error)
|
||||
{
|
||||
xcb_connection_t* connection = nullptr;
|
||||
if (wi.type == WindowInfo::Type::Xlib)
|
||||
if (wi.type == WindowInfoType::Xlib)
|
||||
{
|
||||
if (!dyn_libs::OpenX11Xcb(error))
|
||||
return std::nullopt;
|
||||
|
||||
connection = dyn_libs::XGetXCBConnection(static_cast<Display*>(wi.display_connection));
|
||||
}
|
||||
else if (wi.type == WindowInfo::Type::XCB)
|
||||
else if (wi.type == WindowInfoType::XCB)
|
||||
{
|
||||
connection = static_cast<xcb_connection_t*>(wi.display_connection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user