Create x11_has_focus

This commit is contained in:
twinaphex 2015-11-19 10:13:09 +01:00
parent 4be8f14618
commit ba1dd31995
4 changed files with 18 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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