From ba1dd319957f790c87f49cf9f31328ad510eec3c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 10:13:09 +0100 Subject: [PATCH] Create x11_has_focus --- gfx/common/x11_common.c | 11 +++++++++++ gfx/common/x11_common.h | 3 +++ gfx/drivers_context/glx_ctx.c | 14 ++------------ gfx/drivers_context/xegl_ctx.c | 12 ++---------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 066a30bf38..09a3d3aeb2 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -35,6 +35,7 @@ bool g_x11_has_focus; Window g_x11_win; XIC g_x11_xic; Display *g_x11_dpy; +bool g_x11_true_full; #define XA_INIT(x) XA##x = XInternAtom(dpy, #x, False) #define _NET_WM_STATE_ADD 1 @@ -455,3 +456,13 @@ void x11_get_video_size(unsigned *width, unsigned *height) *height = target.height; } } + +bool x11_has_focus(void) +{ + Window win; + int rev; + + XGetInputFocus(g_x11_dpy, &win, &rev); + + return (win == g_x11_win && g_x11_has_focus) || g_x11_true_full; +} diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index f60d047deb..cdc8960bda 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -41,6 +41,7 @@ extern bool g_x11_has_focus; extern Window g_x11_win; extern XIC g_x11_xic; extern Display *g_x11_dpy; +extern bool g_x11_true_full; void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); @@ -71,5 +72,7 @@ void x11_check_window(bool *quit); void x11_get_video_size(unsigned *width, unsigned *height); +bool x11_has_focus(void); + #endif diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index c9118203f4..8ccd0f200e 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -32,7 +32,6 @@ static void (*g_pglSwapIntervalEXT)(Display*, GLXDrawable, int); typedef struct gfx_ctx_glx_data { - bool g_true_full; bool g_use_hw_ctx; bool g_core_es; bool g_core_es_core; @@ -584,7 +583,7 @@ static bool gfx_ctx_glx_set_video_mode(void *data, driver->display_type = RARCH_DISPLAY_X11; driver->video_display = (uintptr_t)g_x11_dpy; driver->video_window = (uintptr_t)g_x11_win; - glx->g_true_full = true_full; + g_x11_true_full = true_full; return true; @@ -614,16 +613,7 @@ static void gfx_ctx_glx_input_driver(void *data, static bool gfx_ctx_glx_has_focus(void *data) { - Window win; - int rev; - driver_t *driver = driver_get_ptr(); - gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; - - (void)data; - - XGetInputFocus(g_x11_dpy, &win, &rev); - - return (win == g_x11_win && g_x11_has_focus) || glx->g_true_full; + return x11_has_focus(); } static bool gfx_ctx_glx_suppress_screensaver(void *data, bool enable) diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 263de25cff..8696d8e6e9 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -35,7 +35,6 @@ #endif static Colormap g_cmap; -static bool g_true_full; static unsigned g_screen; static XIM g_xim; @@ -539,7 +538,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, driver->display_type = RARCH_DISPLAY_X11; driver->video_display = (uintptr_t)g_x11_dpy; driver->video_window = (uintptr_t)g_x11_win; - g_true_full = true_full; + g_x11_true_full = true_full; return true; @@ -634,17 +633,10 @@ static void gfx_ctx_xegl_input_driver(void *data, static bool gfx_ctx_xegl_has_focus(void *data) { - Window win; - int rev; - - (void)data; - if (!g_inited) return false; - XGetInputFocus(g_x11_dpy, &win, &rev); - - return (win == g_x11_win && g_x11_has_focus) || g_true_full; + return x11_has_focus(); } static bool gfx_ctx_xegl_suppress_screensaver(void *data, bool enable)