From 31a46d8a00dced85e79ea6c29fa1201f19c6ac7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Fri, 9 Jun 2023 18:21:22 -0400 Subject: [PATCH] Fix issue with bitmap_drv_init_mode() Because bitmap_get_scaled_win_size() was being clamped to maxsize, no matter how much mult was incremented, w and h would never be larger than maxwidth/maxheight and only under exceptional circumstances would the be equal, which would result in an infinite loop. While we're here, set the integer scaling value so we're not chasing ulps all over the place with floating point math/scaling when we don't need to. --- src/conio/bitmap_con.c | 3 ++- src/conio/win32gdi.c | 1 + src/conio/x_events.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index fd8e565951..2e180ec812 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -1876,7 +1876,7 @@ int bitmap_drv_init_mode(int mode, int *width, int *height, int maxwidth, int ma ns = bs; while (ns < os) { mult++; - bitmap_get_scaled_win_size(mult, &w, &h, maxwidth, maxheight); + bitmap_get_scaled_win_size(mult, &w, &h, 0, 0); if ((maxwidth > 0) && (w > maxwidth)) { mult--; ns = ls; @@ -1902,6 +1902,7 @@ int bitmap_drv_init_mode(int mode, int *width, int *height, int maxwidth, int ma bitmap_get_scaled_win_size(mult, &w, &h, maxwidth, maxheight); vstat.winwidth = w; vstat.winheight = h; + vstat.scaling = mult; return(0); } diff --git a/src/conio/win32gdi.c b/src/conio/win32gdi.c index 7b5b5d216a..50b12a7844 100644 --- a/src/conio/win32gdi.c +++ b/src/conio/win32gdi.c @@ -926,6 +926,7 @@ gdi_textmode(int mode) if (fullscreen) { vstat.winwidth = mw; vstat.winheight = mh; + vstat.scaling = bitmap_double_mult_inside(mw, mh); } gdi_setwinsize(vstat.winwidth, vstat.winheight); pthread_mutex_unlock(&vstatlock); diff --git a/src/conio/x_events.c b/src/conio/x_events.c index d9a51e8251..3c2bfe57a6 100644 --- a/src/conio/x_events.c +++ b/src/conio/x_events.c @@ -1169,7 +1169,8 @@ static void resize_window() pthread_mutex_unlock(&vstatlock); return; } - resize = new_scaling != vstat.scaling; + bitmap_get_scaled_win_size(new_scaling, &width, &height, 0, 0); + resize = new_scaling != vstat.scaling || width != vstat.winwidth || height != vstat.winheight; x_cvstat.scaling = vstat.scaling; if (resize) x11.XResizeWindow(dpy, win, width, height); @@ -1195,7 +1196,6 @@ static void init_mode_internal(int mode) os = vstat.scaling; bitmap_drv_init_mode(mode, NULL, NULL, mw, mh); x_cvstat = vstat; - x_cvstat.scaling = bitmap_double_mult_inside(vstat.winwidth, vstat.winheight); vstat.winwidth = ow; vstat.winheight = oh; vstat.scaling = os; -- GitLab