Should make sizes right after startup ...

This commit is contained in:
Themaister 2011-08-11 05:59:32 +02:00
parent 3f5b6a450e
commit 4496ed3c13
3 changed files with 32 additions and 8 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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())
{