diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 231d4c1df4..066a30bf38 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -429,3 +429,29 @@ void x11_check_window(bool *quit) *quit = g_x11_quit; } + +void x11_get_video_size(unsigned *width, unsigned *height) +{ + if (!g_x11_dpy || g_x11_win == None) + { + Display *dpy = (Display*)XOpenDisplay(NULL); + *width = 0; + *height = 0; + + if (dpy) + { + int screen = DefaultScreen(dpy); + *width = DisplayWidth(dpy, screen); + *height = DisplayHeight(dpy, screen); + XCloseDisplay(dpy); + } + } + else + { + XWindowAttributes target; + XGetWindowAttributes(g_x11_dpy, g_x11_win, &target); + + *width = target.width; + *height = target.height; + } +} diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 0bbff8ea7c..f60d047deb 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -69,5 +69,7 @@ bool x11_get_metrics(void *data, void x11_check_window(bool *quit); +void x11_get_video_size(unsigned *width, unsigned *height); + #endif diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index ccbb642204..d849d629d5 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -86,39 +86,11 @@ static int glx_nul_handler(Display *dpy, XErrorEvent *event) return 0; } + static void gfx_ctx_glx_get_video_size(void *data, unsigned *width, unsigned *height) { - driver_t *driver = driver_get_ptr(); - gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; - - if (!glx) - return; - - (void)data; - - if (!g_x11_dpy || g_x11_win == None) - { - Display *dpy = (Display*)XOpenDisplay(NULL); - *width = 0; - *height = 0; - - if (dpy) - { - int screen = DefaultScreen(dpy); - *width = DisplayWidth(dpy, screen); - *height = DisplayHeight(dpy, screen); - XCloseDisplay(dpy); - } - } - else - { - XWindowAttributes target; - XGetWindowAttributes(g_x11_dpy, g_x11_win, &target); - - *width = target.width; - *height = target.height; - } + x11_get_video_size(width, height); } static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx) diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 1ab329a992..263de25cff 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -76,9 +76,6 @@ static int egl_nul_handler(Display *dpy, XErrorEvent *event) return 0; } -static void gfx_ctx_xegl_get_video_size(void *data, - unsigned *width, unsigned *height); - static void gfx_ctx_xegl_destroy(void *data); static void egl_report_error(void) @@ -129,6 +126,12 @@ static void gfx_ctx_xegl_swap_interval(void *data, unsigned interval) } } +static void gfx_ctx_xegl_get_video_size(void *data, + unsigned *width, unsigned *height) +{ + x11_get_video_size(width, height); +} + static void gfx_ctx_xegl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count) { @@ -176,36 +179,6 @@ static void gfx_ctx_xegl_update_window_title(void *data) rarch_main_msg_queue_push(buf_fps, 1, 1, false); } -static void gfx_ctx_xegl_get_video_size(void *data, - unsigned *width, unsigned *height) -{ - (void)data; - - if (!g_x11_dpy || g_x11_win == None) - { - Display *dpy = XOpenDisplay(NULL); - if (dpy) - { - int screen = DefaultScreen(dpy); - *width = DisplayWidth(dpy, screen); - *height = DisplayHeight(dpy, screen); - XCloseDisplay(dpy); - } - else - { - *width = 0; - *height = 0; - } - } - else - { - XWindowAttributes target; - XGetWindowAttributes(g_x11_dpy, g_x11_win, &target); - - *width = target.width; - *height = target.height; - } -} #define XEGL_ATTRIBS_BASE \ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \