Qt: Fix selecting fullscreen mode breaking other backend borderless

This commit is contained in:
Connor McLaughlin 2020-11-02 19:52:01 +10:00
parent 863f84e3f6
commit d102b2facd
10 changed files with 43 additions and 4 deletions

View file

@ -66,6 +66,7 @@ public:
virtual void DestroyRenderDevice() = 0; virtual void DestroyRenderDevice() = 0;
virtual void DestroyRenderSurface() = 0; virtual void DestroyRenderSurface() = 0;
virtual bool ChangeRenderWindow(const WindowInfo& wi) = 0; virtual bool ChangeRenderWindow(const WindowInfo& wi) = 0;
virtual bool SupportsFullscreen() const = 0;
virtual bool IsFullscreen() = 0; virtual bool IsFullscreen() = 0;
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) = 0; virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) = 0;
virtual bool CreateResources() = 0; virtual bool CreateResources() = 0;

View file

@ -156,6 +156,11 @@ void LibretroHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_windo
m_window_info.surface_height = new_window_height; m_window_info.surface_height = new_window_height;
} }
bool LibretroHostDisplay::SupportsFullscreen() const
{
return false;
}
bool LibretroHostDisplay::IsFullscreen() bool LibretroHostDisplay::IsFullscreen()
{ {
return false; return false;

View file

@ -23,6 +23,7 @@ public:
bool ChangeRenderWindow(const WindowInfo& wi) override; bool ChangeRenderWindow(const WindowInfo& wi) override;
void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override; void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
bool SupportsFullscreen() const override;
bool IsFullscreen() override; bool IsFullscreen() override;
bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override; bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
void DestroyRenderSurface() override; void DestroyRenderSurface() override;

View file

@ -87,8 +87,15 @@ QtDisplayWidget* MainWindow::createDisplay(QThread* worker_thread, const QString
Assert(!m_host_display && !m_display_widget); Assert(!m_host_display && !m_display_widget);
Assert(!fullscreen || !render_to_main); Assert(!fullscreen || !render_to_main);
m_host_display = m_host_interface->createHostDisplay();
if (!m_host_display)
{
reportError(tr("Failed to create host display."));
return nullptr;
}
const std::string fullscreen_mode = m_host_interface->GetStringSettingValue("GPU", "FullscreenMode", ""); const std::string fullscreen_mode = m_host_interface->GetStringSettingValue("GPU", "FullscreenMode", "");
const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty()); const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty() && m_host_display->SupportsFullscreen());
m_display_widget = new QtDisplayWidget((!fullscreen && render_to_main) ? m_ui.mainContainer : nullptr); m_display_widget = new QtDisplayWidget((!fullscreen && render_to_main) ? m_ui.mainContainer : nullptr);
m_display_widget->setWindowTitle(windowTitle()); m_display_widget->setWindowTitle(windowTitle());
@ -122,14 +129,17 @@ QtDisplayWidget* MainWindow::createDisplay(QThread* worker_thread, const QString
{ {
reportError(QStringLiteral("Failed to get window info from widget")); reportError(QStringLiteral("Failed to get window info from widget"));
destroyDisplayWidget(); destroyDisplayWidget();
delete m_host_display;
m_host_display = nullptr;
return nullptr; return nullptr;
} }
m_host_display = m_host_interface->createHostDisplay(); if (!m_host_display->CreateRenderDevice(wi.value(), adapter_name.toStdString(), use_debug_device))
if (!m_host_display || !m_host_display->CreateRenderDevice(wi.value(), adapter_name.toStdString(), use_debug_device))
{ {
reportError(tr("Failed to create host display device context.")); reportError(tr("Failed to create host display device context."));
destroyDisplayWidget(); destroyDisplayWidget();
delete m_host_display;
m_host_display = nullptr;
return nullptr; return nullptr;
} }
@ -145,7 +155,7 @@ QtDisplayWidget* MainWindow::updateDisplay(QThread* worker_thread, bool fullscre
const bool is_fullscreen = m_display_widget->isFullScreen(); const bool is_fullscreen = m_display_widget->isFullScreen();
const bool is_rendering_to_main = (!is_fullscreen && m_display_widget->parent()); const bool is_rendering_to_main = (!is_fullscreen && m_display_widget->parent());
const std::string fullscreen_mode = m_host_interface->GetStringSettingValue("GPU", "FullscreenMode", ""); const std::string fullscreen_mode = m_host_interface->GetStringSettingValue("GPU", "FullscreenMode", "");
const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty()); const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty() && m_host_display->SupportsFullscreen());
if (fullscreen == is_fullscreen && is_rendering_to_main == render_to_main) if (fullscreen == is_fullscreen && is_rendering_to_main == render_to_main)
return m_display_widget; return m_display_widget;

View file

@ -476,6 +476,15 @@ void D3D11HostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_h
#endif #endif
} }
bool D3D11HostDisplay::SupportsFullscreen() const
{
#ifndef LIBRETRO
return true;
#else
return false;
#endif
}
bool D3D11HostDisplay::IsFullscreen() bool D3D11HostDisplay::IsFullscreen()
{ {
#ifndef LIBRETRO #ifndef LIBRETRO

View file

@ -44,6 +44,7 @@ public:
virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override; virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override;
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override; virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
virtual bool SupportsFullscreen() const override;
virtual bool IsFullscreen() override; virtual bool IsFullscreen() override;
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override; virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
virtual void DestroyRenderSurface() override; virtual void DestroyRenderSurface() override;

View file

@ -315,6 +315,11 @@ void OpenGLHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
#endif #endif
} }
bool OpenGLHostDisplay::SupportsFullscreen() const
{
return false;
}
bool OpenGLHostDisplay::IsFullscreen() bool OpenGLHostDisplay::IsFullscreen()
{ {
return false; return false;

View file

@ -44,6 +44,7 @@ public:
virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override; virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override;
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override; virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
virtual bool SupportsFullscreen() const override;
virtual bool IsFullscreen() override; virtual bool IsFullscreen() override;
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override; virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
virtual void DestroyRenderSurface() override; virtual void DestroyRenderSurface() override;

View file

@ -174,6 +174,11 @@ void VulkanHostDisplay::ResizeRenderWindow(s32 new_window_width, s32 new_window_
#endif #endif
} }
bool VulkanHostDisplay::SupportsFullscreen() const
{
return false;
}
bool VulkanHostDisplay::IsFullscreen() bool VulkanHostDisplay::IsFullscreen()
{ {
return false; return false;

View file

@ -41,6 +41,7 @@ public:
virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override; virtual bool ChangeRenderWindow(const WindowInfo& new_wi) override;
virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override; virtual void ResizeRenderWindow(s32 new_window_width, s32 new_window_height) override;
virtual bool SupportsFullscreen() const override;
virtual bool IsFullscreen() override; virtual bool IsFullscreen() override;
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override; virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
virtual void DestroyRenderSurface() override; virtual void DestroyRenderSurface() override;