fix(fullscreen): preservar zoom_factor_ de windowed durant transicions a fullscreen

Quan arribava un SDL_EVENT_WINDOW_RESIZED en fullscreen, recalculàvem
zoom_factor_ a partir de la mida física i el clampàvem a max_zoom_. Això
"consumia" el zoom_factor_ que tenia l'usuari en windowed, així que en
tornar a windowed (F3) la mida quedava la del clamp, no la prèvia.

Ara, en fullscreen, zoom_factor_ i windowed_*_ es deixen intactes (no
participen del càlcul del viewport, que ja és aspect-fit sobre la mida
física). En windowed, comportament inalterat.
This commit is contained in:
2026-05-20 20:15:28 +02:00
parent e0f8cf78ee
commit 7c2499cd91
+6 -4
View File
@@ -277,11 +277,13 @@ auto SDLManager::handleWindowEvent(const SDL_Event& event) -> bool {
if (event.type == SDL_EVENT_WINDOW_RESIZED) { if (event.type == SDL_EVENT_WINDOW_RESIZED) {
SDL_GetWindowSize(finestra_, &current_width_, &current_height_); SDL_GetWindowSize(finestra_, &current_width_, &current_height_);
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH; // En fullscreen el zoom_factor_ no participa del viewport (aspect-fit
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM, // sobre la mida física), així que el preservem amb el valor de
std::min(new_zoom, max_zoom_)); // windowed per no perdre'l en tornar a windowed.
if (!is_fullscreen_) { if (!is_fullscreen_) {
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH;
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM,
std::min(new_zoom, max_zoom_));
windowed_width_ = current_width_; windowed_width_ = current_width_;
windowed_height_ = current_height_; windowed_height_ = current_height_;
} }