From e3aba24e42c6ab1f6964fa9ddafb7fecb9872465 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 12:05:32 +0100 Subject: [PATCH] (X11) Code de-duplication --- gfx/common/x11_common.c | 10 ++++++++-- gfx/common/x11_common.h | 3 +-- gfx/drivers/xvideo.c | 6 +----- gfx/drivers_context/glx_ctx.c | 7 +------ gfx/drivers_context/xegl_ctx.c | 7 +------ 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 8ef28ef19e..f279bbdf4f 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -38,7 +38,7 @@ Window g_x11_win; static XIM g_x11_xim; static XIC g_x11_xic; Display *g_x11_dpy; -bool g_x11_true_full; +static bool g_x11_true_full; #define XA_INIT(x) XA##x = XInternAtom(dpy, #x, False) #define _NET_WM_STATE_ADD 1 @@ -538,10 +538,16 @@ void x11_update_window_title(void *data) rarch_main_msg_queue_push(buf_fps, 1, 1, false); } -bool x11_input_ctx_new(void) +bool x11_input_ctx_new(bool true_full) { + driver_t *driver = driver_get_ptr(); if (!x11_create_input_context(g_x11_dpy, g_x11_win, &g_x11_xim, &g_x11_xic)) return false; + + driver->display_type = RARCH_DISPLAY_X11; + driver->video_display = (uintptr_t)g_x11_dpy; + driver->video_window = (uintptr_t)g_x11_win; + g_x11_true_full = true_full; return true; } diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 5d49ddd451..ea0538fe04 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -39,7 +39,6 @@ extern Atom g_x11_quit_atom; extern bool g_x11_has_focus; extern Window g_x11_win; extern Display *g_x11_dpy; -extern bool g_x11_true_full; extern Colormap g_x11_cmap; void x11_show_mouse(Display *dpy, Window win, bool state); @@ -82,7 +81,7 @@ bool x11_connect(void); void x11_update_window_title(void *data); -bool x11_input_ctx_new(void); +bool x11_input_ctx_new(bool true_full); void x11_input_ctx_destroy(void); diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 74deb257c6..bf5cbf2c7f 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -556,10 +556,6 @@ static void *xv_init(const video_info_t *video, xv_set_nonblock_state(xv, !video->vsync); - driver->display_type = RARCH_DISPLAY_X11; - driver->video_display = (uintptr_t)g_x11_dpy; - driver->video_window = (Window)g_x11_win; - if (input && input_data) { xinput = input_x.init(); @@ -575,7 +571,7 @@ static void *xv_init(const video_info_t *video, init_yuv_tables(xv); xv_init_font(xv, settings->video.font_path, settings->video.font_size); - if (!x11_input_ctx_new()) + if (!x11_input_ctx_new(true)) goto error; XGetWindowAttributes(g_x11_dpy, g_x11_win, &target); diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index fb650a8237..36ccd4ee90 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -511,14 +511,9 @@ static bool gfx_ctx_glx_set_video_mode(void *data, XFree(vi); - if (!x11_input_ctx_new()) + if (!x11_input_ctx_new(true_full)) goto error; - driver->display_type = RARCH_DISPLAY_X11; - driver->video_display = (uintptr_t)g_x11_dpy; - driver->video_window = (uintptr_t)g_x11_win; - g_x11_true_full = true_full; - return true; error: diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 67def61972..23c8d2a787 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -467,14 +467,9 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, XFree(vi); g_inited = true; - if (!x11_input_ctx_new()) + if (!x11_input_ctx_new(true_full)) goto error; - driver->display_type = RARCH_DISPLAY_X11; - driver->video_display = (uintptr_t)g_x11_dpy; - driver->video_window = (uintptr_t)g_x11_win; - g_x11_true_full = true_full; - return true; error: