diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 47602f600673a5f84933ac98b08a406a073e1d9b..6af6844c8c1ae83fc545ce2a8bf74cfa780c1cfb 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -458,7 +458,7 @@ static void internal_setwinsize(struct video_stats *vs, bool force) } else { pthread_mutex_lock(&win_mutex); - sdl.GetWindowSize(win, &w, &h); + sdl.GetWindowSizeInPixels(win, &w, &h); pthread_mutex_unlock(&win_mutex); if (w != vs->winwidth || h != vs->winheight) changed = true; @@ -633,7 +633,7 @@ static void setup_surfaces(struct video_stats *vs) // 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); + sdl.GetWindowSizeInPixels(win, &idealw, &idealh); vs->winwidth = idealw; vs->winheight = idealh; sdl.RenderClear(renderer); @@ -655,8 +655,11 @@ static void setup_surfaces(struct video_stats *vs) } else { sdl_bughack_minsize(idealmw, idealmh, false); - sdl.SetWindowSize(win, idealw, idealh); - sdl.GetWindowSize(win, &idealw, &idealh); + // Don't change window size when maximized... + if ((sdl.GetWindowFlags(win) & SDL_WINDOW_MAXIMIZED) == 0) { + sdl.SetWindowSize(win, idealw, idealh); + } + sdl.GetWindowSizeInPixels(win, &idealw, &idealh); vs->winwidth = idealw; vs->winheight = idealh; if (internal_scaling) { @@ -704,7 +707,7 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs) int w, h; // Get current window size - sdl.GetWindowSize(win, &w, &h); + sdl.GetWindowSizeInPixels(win, &w, &h); // Limit to max window size if available SDL_Rect r; if (sdl.GetDisplayUsableBounds(0, &r) == 0) { @@ -1038,6 +1041,8 @@ void sdl_video_event_thread(void *data) switch(ev.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: // SDL2: User resized window + case SDL_WINDOWEVENT_MAXIMIZED: + case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_RESIZED: pthread_mutex_lock(&sdl_mode_mutex); if (sdl_mode) { diff --git a/src/conio/sdlfuncs.c b/src/conio/sdlfuncs.c index 889212eef9dd2a5a116054f6097b532bc4d68ff1..eb2fcf61ea589ee87475656eca03b0c647b091c0 100644 --- a/src/conio/sdlfuncs.c +++ b/src/conio/sdlfuncs.c @@ -78,6 +78,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf) xp_dlclose(sdl_dll); return(-1); } + if((sdlf->GetWindowSizeInPixels=xp_dlsym(sdl_dll, SDL_GetWindowSizeInPixels))==NULL) { + xp_dlclose(sdl_dll); + return(-1); + } if((sdlf->SetWindowIcon=xp_dlsym(sdl_dll, SDL_SetWindowIcon))==NULL) { xp_dlclose(sdl_dll); return(-1); diff --git a/src/conio/sdlfuncs.h b/src/conio/sdlfuncs.h index bf52c2b7f705e5811be9197041e478b10e688ae7..8ad0b3b92ab21419c8638895c64b4f6cbf6c5e6f 100644 --- a/src/conio/sdlfuncs.h +++ b/src/conio/sdlfuncs.h @@ -25,6 +25,7 @@ struct sdlfuncs { void (HACK_HACK_HACK *FreeSurface) (SDL_Surface *surface); void (HACK_HACK_HACK *SetWindowTitle) (SDL_Window *window, const char *title); void (HACK_HACK_HACK *GetWindowSize) (SDL_Window *window, int *w, int *h); + void (HACK_HACK_HACK *GetWindowSizeInPixels) (SDL_Window *window, int *w, int *h); void (HACK_HACK_HACK *SetWindowIcon) (SDL_Window *win, SDL_Surface *icon); int (HACK_HACK_HACK *ShowCursor) (int toggle); Uint32 (HACK_HACK_HACK *WasInit) (Uint32 flags);