mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
web: Make sure canvas gets resized after the first frame
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user