web: Make sure canvas gets resized after the first frame

This commit is contained in:
WerWolv
2026-01-12 22:53:51 +01:00
parent d004eb3048
commit b052cb001c

View File

@@ -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;
}