From c9dc5cf71d4bf3df99ec49f56b8deb5dc0479df8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 09:49:37 +0100 Subject: [PATCH] Start moving some global variables for X11 context drivers to x11_common.c --- gfx/common/x11_common.c | 2 ++ gfx/common/x11_common.h | 7 ++++++- gfx/drivers_context/glx_ctx.c | 20 +++++++++----------- gfx/drivers_context/xegl_ctx.c | 20 +++++++++----------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 6887762c9d..161a83b752 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -29,6 +29,8 @@ static Atom XA_NET_WM_STATE; static Atom XA_NET_WM_STATE_FULLSCREEN; static Atom XA_NET_MOVERESIZE_WINDOW; +Atom g_quit_atom; +volatile sig_atomic_t g_quit; #define XA_INIT(x) XA##x = XInternAtom(dpy, #x, False) #define _NET_WM_STATE_ADD 1 diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 12d7def1da..6ee144b73e 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -21,7 +21,7 @@ #include "../../config.h" #endif -#include "../video_context_driver.h" +#include #include #include @@ -33,6 +33,11 @@ #include +#include "../video_context_driver.h" + +Atom g_x11_quit_atom; +volatile sig_atomic_t g_x11_quit; + void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); void x11_suspend_screensaver(Window win); diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index 2d81d94ff0..a05153fa5e 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -59,8 +59,6 @@ typedef struct gfx_ctx_glx_data } gfx_ctx_glx_data_t; -static Atom g_quit_atom; -static volatile sig_atomic_t g_quit; static unsigned g_major; static unsigned g_minor; @@ -69,7 +67,7 @@ static PFNGLXCREATECONTEXTATTRIBSARBPROC glx_create_context_attribs; static void glx_sighandler(int sig) { (void)sig; - g_quit = 1; + g_x11_quit = 1; } static Bool glx_wait_notify(Display *d, XEvent *e, char *arg) @@ -279,13 +277,13 @@ static void gfx_ctx_glx_check_window(void *data, bool *quit, { case ClientMessage: if (event.xclient.window == glx->g_win && - (Atom)event.xclient.data.l[0] == g_quit_atom) - g_quit = true; + (Atom)event.xclient.data.l[0] == g_x11_quit_atom) + g_x11_quit = true; break; case DestroyNotify: if (event.xdestroywindow.window == glx->g_win) - g_quit = true; + g_x11_quit = true; break; case MapNotify: @@ -309,7 +307,7 @@ static void gfx_ctx_glx_check_window(void *data, bool *quit, } } - *quit = g_quit; + *quit = g_x11_quit; } static void gfx_ctx_glx_swap_buffers(void *data) @@ -372,7 +370,7 @@ static bool gfx_ctx_glx_init(void *data) XInitThreads(); - g_quit = 0; + g_x11_quit = 0; if (!glx->g_dpy) glx->g_dpy = XOpenDisplay(NULL); @@ -618,9 +616,9 @@ static bool gfx_ctx_glx_set_video_mode(void *data, glXMakeContextCurrent(glx->g_dpy, glx->g_glx_win, glx->g_glx_win, glx->g_ctx); XSync(glx->g_dpy, False); - g_quit_atom = XInternAtom(glx->g_dpy, "WM_DELETE_WINDOW", False); - if (g_quit_atom) - XSetWMProtocols(glx->g_dpy, glx->g_win, &g_quit_atom, 1); + g_x11_quit_atom = XInternAtom(glx->g_dpy, "WM_DELETE_WINDOW", False); + if (g_x11_quit_atom) + XSetWMProtocols(glx->g_dpy, glx->g_win, &g_x11_quit_atom, 1); glXGetConfig(glx->g_dpy, vi, GLX_DOUBLEBUFFER, &val); glx->g_is_double = val; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index c446610b60..a5f1829789 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -37,7 +37,6 @@ static Display *g_dpy; static Window g_win; static Colormap g_cmap; -static Atom g_quit_atom; static bool g_has_focus; static bool g_true_full; static unsigned g_screen; @@ -55,7 +54,6 @@ static EGLConfig g_egl_config; static XF86VidModeModeInfo g_desktop_mode; static bool g_should_reset_mode; -static volatile sig_atomic_t g_quit; static bool g_inited; static unsigned g_interval; static enum gfx_ctx_api g_api; @@ -65,7 +63,7 @@ static unsigned g_minor; static void egl_sighandler(int sig) { (void)sig; - g_quit = 1; + g_x11_quit = 1; } static Bool egl_wait_notify(Display *d, XEvent *e, char *arg) @@ -167,13 +165,13 @@ static void gfx_ctx_xegl_check_window(void *data, bool *quit, switch (event.type) { case ClientMessage: - if (event.xclient.window == g_win && (Atom)event.xclient.data.l[0] == g_quit_atom) - g_quit = true; + if (event.xclient.window == g_win && (Atom)event.xclient.data.l[0] == g_x11_quit_atom) + g_x11_quit = true; break; case DestroyNotify: if (event.xdestroywindow.window == g_win) - g_quit = true; + g_x11_quit = true; break; case MapNotify: @@ -201,7 +199,7 @@ static void gfx_ctx_xegl_check_window(void *data, bool *quit, } } - *quit = g_quit; + *quit = g_x11_quit; } static void gfx_ctx_xegl_swap_buffers(void *data) @@ -330,7 +328,7 @@ static bool gfx_ctx_xegl_init(void *data) attrib_ptr = NULL; } - g_quit = 0; + g_x11_quit = 0; /* Keep one g_dpy alive the entire process lifetime. * This is necessary for nVidia's EGL implementation for now. */ @@ -599,9 +597,9 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, XIfEvent(g_dpy, &event, egl_wait_notify, NULL); - g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); - if (g_quit_atom) - XSetWMProtocols(g_dpy, g_win, &g_quit_atom, 1); + g_x11_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False); + if (g_x11_quit_atom) + XSetWMProtocols(g_dpy, g_win, &g_x11_quit_atom, 1); gfx_ctx_xegl_swap_interval(data, g_interval);