Skip to content
Snippets Groups Projects
Commit 64f21b53 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Work around marco or SDL bug in SDL_SetWindowMinimumSize()

When using the marco WM, and resizing using ALT-Right-drag, calls to
SDL_SetWindowMinimumSize() result in the top-left corner of the
window moving up and to the left (appears to be by the border size).

To prevent this from being a maddening issue under marco, ensure
we only call SDL_SetWindowMinimumSize() once when the minimum size
changes on the window.

Fixes SF ticket 115, thanks Ragnarok!

While we're hear, ensure the minimium maximum window size holds
the original sized window... we're not interested in downscaling.
parent 4bd7abd0
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4458 passed
......@@ -1726,7 +1726,13 @@ bitmap_get_scaled_win_size(double scale, int *w, int *h, int maxwidth, int maxhe
if (maxwidth == 0 && maxheight == 0)
return bitmap_get_scaled_win_size_nomax(scale, w, h);
if (maxwidth < vstat.scrnwidth)
maxwidth = vstat.scrnwidth;
if (maxheight < vstat.scrnheight)
maxheight = vstat.scrnheight;
max = bitmap_double_mult_inside(maxwidth, maxheight);
if (max < 1.0)
max = 1.0;
if (scale < 1.0)
scale = 1.0;
if (scale > max)
......
......@@ -572,6 +572,19 @@ int sdl_get_window_info(int *width, int *height, int *xpos, int *ypos)
return(1);
}
static void
sdl_bughack_minsize(int w, int h, bool new)
{
static int lw = -1;
static int lh = -1;
if ((!new) && w == lw && h == lh)
return;
lw = w;
lh = h;
sdl.SetWindowMinimumSize(win, w, h);
}
static void setup_surfaces(struct video_stats *vs)
{
int flags=0;
......@@ -581,6 +594,7 @@ static void setup_surfaces(struct video_stats *vs)
int idealh;
int idealmw;
int idealmh;
int new_win = false;
if(fullscreen)
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
......@@ -599,6 +613,7 @@ static void setup_surfaces(struct video_stats *vs)
if (win == NULL) {
// SDL2: This is slow sometimes... not sure why.
new_win = true;
if (sdl.CreateWindowAndRenderer(vs->winwidth, vs->winheight, flags, &win, &renderer) == 0) {
sdl.GetWindowSize(win, &idealw, &idealh);
vs->winwidth = idealw;
......@@ -621,7 +636,7 @@ static void setup_surfaces(struct video_stats *vs)
}
}
else {
sdl.SetWindowMinimumSize(win, idealmw, idealmh);
sdl_bughack_minsize(idealmw, idealmh, false);
sdl.SetWindowSize(win, idealw, idealh);
sdl.GetWindowSize(win, &idealw, &idealh);
vs->winwidth = idealw;
......@@ -643,7 +658,7 @@ static void setup_surfaces(struct video_stats *vs)
vstat.winheight = vs->winheight;
pthread_mutex_unlock(&vstatlock);
}
sdl.SetWindowMinimumSize(win, idealmw, idealmh);
sdl_bughack_minsize(idealmw, idealmh, new_win);
if(win!=NULL) {
bitmap_drv_request_pixels();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment