diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 89c47243aa..d90c1e1ce8 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -110,6 +110,33 @@ void gfx_set_dwm(void) if (FAILED(ret)) SSNES_ERR("Failed to set composition state ...\n"); } - #endif + +#include "SDL_syswm.h" + +void gfx_get_window_size(unsigned *width, unsigned *height) +{ +#if defined(__APPLE__) || defined(_WIN32) + SDL_Event evnt; + while (SDL_PollEvent(&evnt)); + const SDL_VideoInfo *info = SDL_GetVideoInfo(); + *width = info->current_w; + *height = info->current_h; +#else + // It seems that we need to go hardcore to get the actual + // window sizes properly right after startup ... :D + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + SDL_GetWMInfo(&info); + XWindowAttributes target; + info.info.x11.lock_func(); + XGetWindowAttributes(info.info.x11.display, info.info.x11.window, + &target); + info.info.x11.unlock_func(); + + *width = target.width; + *height = target.height; +#endif +} + diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index e73f757f02..5ffe52ea8a 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -28,4 +28,6 @@ void gfx_window_title_reset(void); void gfx_set_dwm(void); #endif +void gfx_get_window_size(unsigned *width, unsigned *height); + #endif diff --git a/gfx/gl.c b/gfx/gl.c index 6da4f8c1f5..f615648128 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1109,13 +1109,8 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo } SSNES_LOG("GL: Using resolution %ux%u\n", gl->win_width, gl->win_height); - video_info = SDL_GetVideoInfo(); - if (gl->win_width != video_info->current_w || gl->win_height != video_info->current_h) - { - gl->win_width = video_info->current_w; - gl->win_height = video_info->current_h; - SSNES_WARN("GL: Did not get requested resolution, got %ux%u ...\n", gl->win_width, gl->win_height); - } + gfx_get_window_size(&gl->win_width, &gl->win_height); + SSNES_LOG("GL: Got resolution %ux%u\n", gl->win_width, gl->win_height); if (!gl_shader_init()) {