diff --git a/QuickView/main.cpp b/QuickView/main.cpp index ad60691..4058bc9 100644 --- a/QuickView/main.cpp +++ b/QuickView/main.cpp @@ -236,6 +236,8 @@ static EditState g_editState; AppConfig g_config; RuntimeConfig g_runtime; ViewState g_viewState; // Non-static for extern access from UIRenderer +bool g_preserveViewStateOnNextLoad = false; +ViewState g_preservedViewState; static int g_renderExifOrientation = 1; // Exif orientation baked into the bitmap surface FileNavigator g_navigator; // New Navigator (Non-static for extern access from SettingsOverlay) static ThumbnailManager g_thumbMgr; @@ -8586,6 +8588,8 @@ SKIP_EDGE_NAV:; g_imageEngine->UpdateConfig(g_runtime); // [Fix] Push config to engine g_imageEngine->SetForceRefresh(true); } + g_preservedViewState = g_viewState; + g_preserveViewStateOnNextLoad = true; ReleaseImageResources(); LoadImageAsync(hwnd, contextPath.c_str()); } @@ -8613,6 +8617,8 @@ SKIP_EDGE_NAV:; g_imageEngine->UpdateConfig(g_runtime); g_imageEngine->SetForceRefresh(true); } + g_preservedViewState = g_viewState; + g_preserveViewStateOnNextLoad = true; ReleaseImageResources(); LoadImageAsync(hwnd, g_imagePath, false, QuickView::BrowseDirection::IDLE); } @@ -9204,11 +9210,20 @@ void ProcessEngineEvents(HWND hwnd) { // [Fix] Update Window Size AFTER RenderImageToDComp // This ensures g_lastSurfaceSize is updated with the NEW image dimensions. - AdjustWindowToImage(hwnd); - - // [Feature] Apply Fullscreen Zoom Mode if active - if (g_isFullScreen || IsZoomed(hwnd)) { - ApplyFullScreenZoomMode(hwnd); + // If we are preserving view state (e.g., Color Space switch), we DO NOT resize the window + // and we bypass the Fullscreen zoom mode reset, ensuring exact visual continuity. + if (g_preserveViewStateOnNextLoad) { + g_viewState.Zoom = g_preservedViewState.Zoom; + g_viewState.PanX = g_preservedViewState.PanX; + g_viewState.PanY = g_preservedViewState.PanY; + g_preserveViewStateOnNextLoad = false; // Consume it + } else { + AdjustWindowToImage(hwnd); + + // [Feature] Apply Fullscreen Zoom Mode if active + if (g_isFullScreen || IsZoomed(hwnd)) { + ApplyFullScreenZoomMode(hwnd); + } } // [Fix] Explicitly Sync DComp State immediately after Window Adjustment