From dec304c00b54f4a2fbd62ec5c9cff4b2bfad61b8 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 18 May 2025 03:25:13 +0200 Subject: [PATCH] Prevent bad window position when starting in fullscreen mode --- include/frontend.hpp | 1 + source/WindowScreen.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/frontend.hpp b/include/frontend.hpp index 3d00339..0766314 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -126,6 +126,7 @@ private: sf::RenderWindow m_win; bool is_window_windowed; sf::Vector2i saved_windowed_pos; + bool was_windowed_pos_saved; int m_width, m_height; int m_width_no_manip, m_height_no_manip; int m_window_width, m_window_height; diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index 30301dd..e7b2b23 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -160,6 +160,7 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp this->created_proper_folder = created_proper_folder; this->is_window_windowed = false; this->saved_windowed_pos = sf::Vector2i(0, 0); + this->was_windowed_pos_saved = false; } WindowScreen::~WindowScreen() { @@ -510,7 +511,8 @@ void WindowScreen::window_factory(bool is_main_thread) { // Regardless of how it will change... if(previously_open && this->is_window_windowed) { prev_pos = this->m_win.getPosition(); - saved_windowed_pos = prev_pos; + this->saved_windowed_pos = prev_pos; + this->was_windowed_pos_saved = true; } if((this->loaded_info.initial_pos_x != DEFAULT_NO_POS_WINDOW_VALUE) && (this->loaded_info.initial_pos_y != DEFAULT_NO_POS_WINDOW_VALUE)) prev_pos = sf::Vector2i(this->loaded_info.initial_pos_x, this->loaded_info.initial_pos_y); @@ -533,7 +535,7 @@ void WindowScreen::window_factory(bool is_main_thread) { else this->m_win.create(this->curr_desk_mode, this->title_factory(), sf::Style::None); } - if(previously_open && (!this->loaded_info.is_fullscreen)) + if(previously_open && (!this->loaded_info.is_fullscreen) && this->was_windowed_pos_saved) this->m_win.setPosition(saved_windowed_pos); if((this->loaded_info.initial_pos_x != DEFAULT_NO_POS_WINDOW_VALUE) && (this->loaded_info.initial_pos_y != DEFAULT_NO_POS_WINDOW_VALUE) && (!this->loaded_info.is_fullscreen)) this->m_win.setPosition(prev_pos);