diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index a1ae858b18e58c56378e21993caf822ab867a14d..5ff88585dfcedc22c90f405c5aa1de9e2fca29bf 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -1711,13 +1711,27 @@ bitmap_double_mult_inside(int maxwidth, int maxheight) double mult = 1.0; double wmult = 1.0; double hmult = 1.0; + int wmw, wmh; + int hmw, hmh; int w, h; bitmap_get_scaled_win_size_nomax(1.0, &w, &h); wmult = (double)maxwidth / w; hmult = (double)maxheight / h; - if (wmult < hmult) - mult = wmult; + bitmap_get_scaled_win_size_nomax(wmult, &wmw, &wmh); + bitmap_get_scaled_win_size_nomax(hmult, &hmw, &hmh); + if (wmult < hmult) { + if (hmw <= maxwidth && hmh <= maxheight) + mult = hmult; + else + mult = wmult; + } + else if(hmult < wmult) { + if (wmw <= maxwidth && wmh <= maxheight) + mult = wmult; + else + mult = hmult; + } else mult = hmult; // TODO: Allow below 1.0? diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index aedbaa6d4ba39c4c19060081a5cb7fb399bf144a..d92788fb071476c3117142121cb6f73c6cd1fa4a 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -372,20 +372,9 @@ static int sdl_init_mode(int mode, bool init) } bitmap_drv_init_mode(mode, &bitmap_width, &bitmap_height, w, h); if (ciolib_initial_scaling < 1.0) { - if (w != 0 && h != 0) { - w *= ciolib_initial_scaling; - h *= ciolib_initial_scaling; - ciolib_initial_scaling = bitmap_double_mult_inside(w, h); - } - if (ciolib_initial_scaling < 1.0) { + ciolib_initial_scaling = vstat.scaling; + if (ciolib_initial_scaling < 1.0) ciolib_initial_scaling = 1.0; - } - } - if (init) { - internal_scaling = (ciolib_initial_scaling_type == CIOLIB_SCALING_INTERNAL); - if (ciolib_initial_scaling) { - bitmap_get_scaled_win_size(ciolib_initial_scaling, &vstat.winwidth, &vstat.winheight, 0, 0); - } } pthread_mutex_lock(&sdl_mode_mutex); sdl_mode = true; diff --git a/src/conio/x_events.c b/src/conio/x_events.c index e526793d0049b2cd936b470092c5fd4b48caf2cb..8cd43e61984eb3aebe3c523147424d6d4f90f4ea 100644 --- a/src/conio/x_events.c +++ b/src/conio/x_events.c @@ -1227,17 +1227,19 @@ static void resize_window() static void init_mode_internal(int mode) { int mw, mh; - int ow, oh; x11_get_maxsize(&mw, &mh); free_last(); pthread_mutex_lock(&vstatlock); - ow = vstat.winwidth; - oh = vstat.winheight; + double os = vstat.scaling; + int ow = vstat.winwidth; + int oh = vstat.winheight; bitmap_drv_init_mode(mode, NULL, NULL, mw, mh); + // TODO: This hacks the right values into the wrong places so resize_window() fixes them. + x_cvstat.scaling = vstat.scaling; + vstat.scaling = os; vstat.winwidth = ow; vstat.winheight = oh; - vstat.scaling = bitmap_double_mult_inside(ow, oh); pthread_mutex_unlock(&vstatlock); resize_window(); pthread_mutex_lock(&vstatlock);