CommonHostInterface: Simplify fullscreen toggle

This commit is contained in:
Connor McLaughlin 2020-04-05 22:58:54 +10:00
parent bf6c1c4866
commit 11e8a91e30
4 changed files with 23 additions and 22 deletions

View File

@ -278,7 +278,7 @@ void QtHostInterface::toggleFullscreen()
return; return;
} }
ToggleFullscreen(); SetFullscreen(!m_is_fullscreen);
} }
bool QtHostInterface::AcquireHostDisplay() bool QtHostInterface::AcquireHostDisplay()
@ -317,19 +317,19 @@ void QtHostInterface::ReleaseHostDisplay()
emit destroyDisplayWindowRequested(); emit destroyDisplayWindowRequested();
} }
void QtHostInterface::SetFullscreen(bool enabled) bool QtHostInterface::IsFullscreen() const
{
return m_is_fullscreen;
}
bool QtHostInterface::SetFullscreen(bool enabled)
{ {
if (m_is_fullscreen == enabled) if (m_is_fullscreen == enabled)
return; return true;
m_is_fullscreen = enabled; m_is_fullscreen = enabled;
emit updateDisplayWindowRequested(m_is_fullscreen, m_is_rendering_to_main); emit updateDisplayWindowRequested(m_is_fullscreen, m_is_rendering_to_main);
} return true;
void QtHostInterface::ToggleFullscreen()
{
m_is_fullscreen = !m_is_fullscreen;
emit updateDisplayWindowRequested(m_is_fullscreen, m_is_rendering_to_main);
} }
std::optional<CommonHostInterface::HostKeyCode> QtHostInterface::GetHostKeyCode(const std::string_view key_code) const std::optional<CommonHostInterface::HostKeyCode> QtHostInterface::GetHostKeyCode(const std::string_view key_code) const

View File

@ -120,8 +120,8 @@ private Q_SLOTS:
protected: protected:
bool AcquireHostDisplay() override; bool AcquireHostDisplay() override;
void ReleaseHostDisplay() override; void ReleaseHostDisplay() override;
void SetFullscreen(bool enabled) override; bool IsFullscreen() const override;
void ToggleFullscreen() override; bool SetFullscreen(bool enabled) override;
std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const override; std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const override;

View File

@ -51,9 +51,15 @@ void CommonHostInterface::Shutdown()
} }
} }
void CommonHostInterface::SetFullscreen(bool enabled) {} bool CommonHostInterface::IsFullscreen() const
{
return false;
}
void CommonHostInterface::ToggleFullscreen() {} bool CommonHostInterface::SetFullscreen(bool enabled)
{
return false;
}
std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend backend) std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend backend)
{ {
@ -88,19 +94,14 @@ std::unique_ptr<ControllerInterface> CommonHostInterface::CreateControllerInterf
void CommonHostInterface::OnSystemCreated() void CommonHostInterface::OnSystemCreated()
{ {
HostInterface::OnSystemCreated(); HostInterface::OnSystemCreated();
if (m_settings.start_fullscreen)
SetFullscreen(true);
} }
void CommonHostInterface::OnSystemPaused(bool paused) void CommonHostInterface::OnSystemPaused(bool paused)
{ {
HostInterface::OnSystemPaused(paused); HostInterface::OnSystemPaused(paused);
if (paused) if (paused && IsFullscreen())
SetFullscreen(false); SetFullscreen(false);
else if (m_settings.start_fullscreen)
SetFullscreen(true);
} }
void CommonHostInterface::OnControllerTypeChanged(u32 slot) void CommonHostInterface::OnControllerTypeChanged(u32 slot)
@ -375,7 +376,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
RegisterHotkey(StaticString("General"), StaticString("ToggleFullscreen"), StaticString("Toggle Fullscreen"), RegisterHotkey(StaticString("General"), StaticString("ToggleFullscreen"), StaticString("Toggle Fullscreen"),
[this](bool pressed) { [this](bool pressed) {
if (!pressed) if (!pressed)
ToggleFullscreen(); SetFullscreen(!IsFullscreen());
}); });
RegisterHotkey(StaticString("General"), StaticString("TogglePause"), StaticString("Toggle Pause"), RegisterHotkey(StaticString("General"), StaticString("TogglePause"), StaticString("Toggle Pause"),

View File

@ -46,8 +46,8 @@ protected:
CommonHostInterface(); CommonHostInterface();
~CommonHostInterface(); ~CommonHostInterface();
virtual void SetFullscreen(bool enabled); virtual bool IsFullscreen() const;
virtual void ToggleFullscreen(); virtual bool SetFullscreen(bool enabled);
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override; virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override;
virtual std::unique_ptr<ControllerInterface> CreateControllerInterface(); virtual std::unique_ptr<ControllerInterface> CreateControllerInterface();