From 56756fb7196af91213d60a326ac69f038b5859fa Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jul 31 2024 17:10:38 +0000 Subject: fix screen resize --- diff --git a/app.c b/app.c index ca1fa79..1e46579 100644 --- a/app.c +++ b/app.c @@ -39,8 +39,8 @@ int appInit(App *app) { #if defined(WIDTH_SCALE_P) && defined(HEIGHT_SCALE_P) if (app->sw < app->sh) { - app->w = app->sw * WIDTH_SCALE; - app->h = app->sh * HEIGHT_SCALE; + app->w = app->sw * WIDTH_SCALE_P; + app->h = app->sh * HEIGHT_SCALE_P; } #endif @@ -352,6 +352,26 @@ void appUpdateScreenSize(App *app, int sw, int sh) { if (sw == app->sw && sh == app->sh) return; LOGDBG("app: update screen size: w=%d, h=%d", sw, sh); + #if defined(LOCK_SIZE) || defined(DOCK) + // static size case + int w = sw * WIDTH_SCALE; + int h = sh * HEIGHT_SCALE; + #if defined(WIDTH_SCALE_P) && defined(HEIGHT_SCALE_P) + if (sw < sh) { + w = sw * WIDTH_SCALE_P; + h = sh * HEIGHT_SCALE_P; + } + #endif + + int x0 = 0; + #ifdef TOP + int y0 = 0; + #else + int y0 = sh - h; + #endif + + #else + // dynamic size case double kx = sw/(double)app->sw; double ky = sh/(double)app->sh; @@ -374,10 +394,13 @@ void appUpdateScreenSize(App *app, int sw, int sh) { int y0 = (int)round( app->y*ky ); int x1 = (int)round( (app->x + app->w)*kx ); int y1 = (int)round( (app->y + app->h)*ky ); + int w = x1 - x0; + int h = y1 - y0; + #endif app->sw = sw; app->sh = sh; - appMove(app, x0, y0, x1 - x0, y1 - y0); + appMove(app, x0, y0, w, h); }