From f868cbab312557d8d536d2b15ca272c13fc5c340 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 11:18:57 +0100 Subject: [PATCH] Create x11_update_window_title --- gfx/common/x11_common.c | 14 ++++++++++++++ gfx/common/x11_common.h | 2 ++ gfx/drivers/xvideo.c | 4 +--- gfx/drivers_context/glx_ctx.c | 18 +----------------- gfx/drivers_context/xegl_ctx.c | 19 +------------------ 5 files changed, 19 insertions(+), 38 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index cc5f52c38c..659da15818 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -25,6 +25,7 @@ #include "x11_common.h" #include "../../general.h" +#include "../video_monitor.h" static Atom XA_NET_WM_STATE; static Atom XA_NET_WM_STATE_FULLSCREEN; @@ -521,3 +522,16 @@ bool x11_connect(void) return true; } + +void x11_update_window_title(void *data) +{ + char buf[128] = {0}; + char buf_fps[128] = {0}; + settings_t *settings = config_get_ptr(); + + if (video_monitor_get_fps(buf, sizeof(buf), + buf_fps, sizeof(buf_fps))) + XStoreName(g_x11_dpy, g_x11_win, buf); + if (settings->fps_show) + rarch_main_msg_queue_push(buf_fps, 1, 1, false); +} diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 64d4f7a4fc..febd9227ba 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -80,5 +80,7 @@ void x11_install_sighandlers(void); bool x11_connect(void); +void x11_update_window_title(void *data); + #endif diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 13feb18e3f..54dda347ba 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -755,7 +755,6 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned pitch, const char *msg) { XWindowAttributes target; - char buf[128] = {0}; xv_t *xv = (xv_t*)data; if (!frame) @@ -780,8 +779,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, true); XSync(g_x11_dpy, False); - if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) - XStoreName(g_x11_dpy, g_x11_win, buf); + x11_update_window_title(NULL); return true; } diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index e4c615409a..233c1a4106 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -21,7 +21,6 @@ #include "../../driver.h" #include "../../runloop.h" -#include "../video_monitor.h" #include "../common/gl_common.h" #include "../common/x11_common.h" @@ -218,21 +217,6 @@ static void gfx_ctx_glx_set_resize(void *data, (void)height; } -static void gfx_ctx_glx_update_window_title(void *data) -{ - char buf[128] = {0}; - char buf_fps[128] = {0}; - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); - gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; - - if (video_monitor_get_fps(buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) - XStoreName(g_x11_dpy, g_x11_win, buf); - if (settings->fps_show) - rarch_main_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_glx_init(void *data) { static const int visual_attribs[] = { @@ -655,7 +639,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = { NULL, /* get_video_output_next */ x11_get_metrics, NULL, - gfx_ctx_glx_update_window_title, + x11_update_window_title, x11_check_window, gfx_ctx_glx_set_resize, x11_has_focus, diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index c541bc69a0..6b3246bbdb 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -26,7 +26,6 @@ #include "../../driver.h" #include "../../runloop.h" -#include "../video_monitor.h" #include "../common/gl_common.h" #include "../common/x11_common.h" @@ -133,22 +132,6 @@ static void gfx_ctx_xegl_set_resize(void *data, (void)height; } -static void gfx_ctx_xegl_update_window_title(void *data) -{ - char buf[128] = {0}; - char buf_fps[128] = {0}; - settings_t *settings = config_get_ptr(); - - (void)data; - - if (video_monitor_get_fps(buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) - XStoreName(g_x11_dpy, g_x11_win, buf); - if (settings->fps_show) - rarch_main_msg_queue_push(buf_fps, 1, 1, false); -} - - #define XEGL_ATTRIBS_BASE \ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \ EGL_RED_SIZE, 1, \ @@ -687,7 +670,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = NULL, /* get_video_output_next */ x11_get_metrics, NULL, - gfx_ctx_xegl_update_window_title, + x11_update_window_title, x11_check_window, gfx_ctx_xegl_set_resize, gfx_ctx_xegl_has_focus,