From c5ba20173ba641f5b780fec919ad7e95f12abb0f Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Sun, 23 Nov 2025 20:51:14 +0300 Subject: [PATCH] Emscripten version doesnt take display scaling into account anymore --- src/MainProgram.cpp | 4 ++++ src/MainProgram.hpp | 4 +++- src/Toolbar.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/MainProgram.cpp b/src/MainProgram.cpp index 56e3063..31f4cf5 100755 --- a/src/MainProgram.cpp +++ b/src/MainProgram.cpp @@ -266,7 +266,11 @@ void MainProgram::set_vsync_value(int vsyncValue) { } void MainProgram::update_scale_and_density() { +#ifdef __EMSCRIPTEN__ + window.scale = 1.0f; +#else window.scale = window.applyDisplayScale ? SDL_GetWindowDisplayScale(window.sdlWindow) : 1.0f; +#endif window.density = SDL_GetWindowPixelDensity(window.sdlWindow); } diff --git a/src/MainProgram.hpp b/src/MainProgram.hpp index f049f42..9553176 100644 --- a/src/MainProgram.hpp +++ b/src/MainProgram.hpp @@ -45,7 +45,9 @@ class MainProgram { float density = 1.0f; float scale = 1.0f; - bool applyDisplayScale = true; + #ifndef __EMSCRIPTEN__ + bool applyDisplayScale = true; + #endif int defaultMSAASampleCount = 0; SkSurfaceProps defaultMSAASurfaceProps; diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index dffd59d..869fbf2 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -254,7 +254,9 @@ nlohmann::json Toolbar::get_config_json() { toRet["dragZoomSpeed"] = dragZoomSpeed; toRet["scrollZoomSpeed"] = scrollZoomSpeed; toRet["vsync"] = main.window.vsyncValue; +#ifndef __EMSCRIPTEN__ toRet["applyDisplayScale"] = main.window.applyDisplayScale; +#endif toRet["showPerformance"] = showPerformance; toRet["displayName"] = main.displayName; toRet["useNativeFilePicker"] = useNativeFilePicker; @@ -314,7 +316,9 @@ void Toolbar::set_config_json(const nlohmann::json& j, VersionNumber version) { catch(...) { main.set_vsync_value(1); } +#ifndef __EMSCRIPTEN__ try{j.at("applyDisplayScale").get_to(main.window.applyDisplayScale);} catch(...) {} +#endif try{j.at("guiScale").get_to(guiScale);} catch(...) {} try{j.at("showPerformance").get_to(showPerformance);} catch(...) {} try{j.at("useNativeFilePicker").get_to(useNativeFilePicker);} catch(...) {} @@ -1462,7 +1466,9 @@ void Toolbar::options_menu() { if(gui.radio_button_field("Vsync Adaptive", "Adaptive", main.window.vsyncValue == -1)) main.set_vsync_value(-1); + #ifndef __EMSCRIPTEN__ gui.checkbox_field("apply display scale", "Apply display scale", &main.window.applyDisplayScale); + #endif gui.pop_id(); break;