From 386909f322e9dc136512955038c556503976b97d Mon Sep 17 00:00:00 2001 From: MatusGuy Date: Sun, 8 Sep 2024 23:27:18 +0100 Subject: [PATCH 1/2] Fix TextScrollerScreen becoming unresponsive when alt-tabbing --- src/supertux/textscroller_screen.cpp | 8 ++++++++ src/supertux/textscroller_screen.hpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/supertux/textscroller_screen.cpp b/src/supertux/textscroller_screen.cpp index c438275130c..f17e6abea1e 100644 --- a/src/supertux/textscroller_screen.cpp +++ b/src/supertux/textscroller_screen.cpp @@ -25,6 +25,7 @@ #include "supertux/fadetoblack.hpp" #include "supertux/globals.hpp" #include "supertux/info_box_line.hpp" +#include "supertux/level.hpp" #include "supertux/screen_manager.hpp" #include "util/log.hpp" #include "util/reader.hpp" @@ -87,6 +88,7 @@ TextScrollerScreen::~TextScrollerScreen() void TextScrollerScreen::setup() { + Level::current()->m_suppress_pause_menu = true; SoundManager::current()->play_music(m_music); ScreenManager::current()->set_screen_fade(std::make_unique(FadeToBlack::FADEIN, 0.5f)); } @@ -135,6 +137,12 @@ TextScrollerScreen::draw(Compositor& compositor) m_text_scroller->draw(context); } +void +TextScrollerScreen::leave() +{ + Level::current()->m_suppress_pause_menu = false; +} + IntegrationStatus TextScrollerScreen::get_status() const { diff --git a/src/supertux/textscroller_screen.hpp b/src/supertux/textscroller_screen.hpp index 760ea083a5c..5caf595fd3c 100644 --- a/src/supertux/textscroller_screen.hpp +++ b/src/supertux/textscroller_screen.hpp @@ -38,6 +38,7 @@ class TextScrollerScreen final : public Screen virtual void setup() override; virtual void draw(Compositor& compositor) override; + virtual void leave() override; virtual void update(float dt_sec, const Controller& controller) override; virtual IntegrationStatus get_status() const override; @@ -50,6 +51,7 @@ class TextScrollerScreen final : public Screen private: TextScrollerScreen(const TextScrollerScreen&) = delete; TextScrollerScreen& operator=(const TextScrollerScreen&) = delete; + }; #endif From 151b3e25730a81dec0ebd8fc3712a36f0adb3d30 Mon Sep 17 00:00:00 2001 From: MatusGuy Date: Sat, 9 Nov 2024 19:03:06 +0000 Subject: [PATCH 2/2] better way of doing this --- src/supertux/game_session.cpp | 12 ++++++------ src/supertux/textscroller_screen.cpp | 7 ------- src/supertux/textscroller_screen.hpp | 1 - 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 3a602556e7b..32ccd3ebf8b 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -404,7 +404,10 @@ GameSession::abort_level() bool GameSession::is_active() const { - return !m_game_pause && m_active && !(m_end_sequence && m_end_sequence->is_running()); + return !m_game_pause && + m_active && + !(m_end_sequence && m_end_sequence->is_running()) && + ScreenManager::current()->get_screen_stack().front().get() == static_cast(this); } void @@ -496,12 +499,9 @@ void GameSession::update(float dt_sec, const Controller& controller) { // Set active flag. - if (!m_active) - { - m_active = true; - } - // Handle controller. + m_active = true; + // Handle controller. if (controller.pressed_any(Control::ESCAPE, Control::START)) { on_escape_press(controller.hold(Control::LEFT) diff --git a/src/supertux/textscroller_screen.cpp b/src/supertux/textscroller_screen.cpp index f17e6abea1e..22c3bfd2fad 100644 --- a/src/supertux/textscroller_screen.cpp +++ b/src/supertux/textscroller_screen.cpp @@ -88,7 +88,6 @@ TextScrollerScreen::~TextScrollerScreen() void TextScrollerScreen::setup() { - Level::current()->m_suppress_pause_menu = true; SoundManager::current()->play_music(m_music); ScreenManager::current()->set_screen_fade(std::make_unique(FadeToBlack::FADEIN, 0.5f)); } @@ -137,12 +136,6 @@ TextScrollerScreen::draw(Compositor& compositor) m_text_scroller->draw(context); } -void -TextScrollerScreen::leave() -{ - Level::current()->m_suppress_pause_menu = false; -} - IntegrationStatus TextScrollerScreen::get_status() const { diff --git a/src/supertux/textscroller_screen.hpp b/src/supertux/textscroller_screen.hpp index 5caf595fd3c..4d02d51a03a 100644 --- a/src/supertux/textscroller_screen.hpp +++ b/src/supertux/textscroller_screen.hpp @@ -38,7 +38,6 @@ class TextScrollerScreen final : public Screen virtual void setup() override; virtual void draw(Compositor& compositor) override; - virtual void leave() override; virtual void update(float dt_sec, const Controller& controller) override; virtual IntegrationStatus get_status() const override;