diff --git a/main/gui/source/window/platform/web.cpp b/main/gui/source/window/platform/web.cpp index 5fc4f63ca..03ae02f17 100644 --- a/main/gui/source/window/platform/web.cpp +++ b/main/gui/source/window/platform/web.cpp @@ -135,7 +135,30 @@ namespace hex { } void Window::beginNativeWindowFrame() { - static i32 prevWidth = 0; + + } + + void Window::endNativeWindowFrame() { + static float prevScaleFactor = 0; + + const float currScaleFactor = MAIN_THREAD_EM_ASM_DOUBLE({ + try { + return window.devicePixelRatio; + } catch (e) { + return 1.0; + } + }); + + if (prevScaleFactor != 0 && prevScaleFactor != currScaleFactor) { + EventDPIChanged::post(prevScaleFactor, currScaleFactor); + resizeCanvas(); + + ImHexApi::System::impl::setNativeScale(currScaleFactor); + + ThemeManager::reapplyCurrentTheme(); + } + + static i32 prevWidth = 0; static i32 prevHeight = 0; auto width = canvas_get_width(); @@ -149,26 +172,6 @@ namespace hex { this->resize(width, height); resizeCanvas(); } - } - - void Window::endNativeWindowFrame() { - static float prevScaleFactor = 0; - - const float currScaleFactor = MAIN_THREAD_EM_ASM_DOUBLE({ - try { - return window.devicePixelRatio; - } catch (e) { - return 1.0; - } - }); - if (prevScaleFactor != 0 && prevScaleFactor != currScaleFactor) { - EventDPIChanged::post(prevScaleFactor, currScaleFactor); - resizeCanvas(); - - ImHexApi::System::impl::setNativeScale(currScaleFactor); - - ThemeManager::reapplyCurrentTheme(); - } prevScaleFactor = currScaleFactor; }