diff --git a/driver.h b/driver.h index 92e796bf9e..1f3bda1bc3 100644 --- a/driver.h +++ b/driver.h @@ -271,14 +271,6 @@ typedef struct driver bool flushing_input; bool nonblock_state; - /* Opaque handles to currently running window. - * Used by e.g. input drivers which bind to a window. - * Drivers are responsible for setting these if an input driver - * could potentially make use of this. */ - uintptr_t video_display; - uintptr_t video_window; - enum rarch_display_type display_type; - /* Last message given to the video driver */ char current_msg[PATH_MAX_LENGTH]; } driver_t; diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 48df5a87d9..e9e07cc09f 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -279,7 +279,6 @@ bool win32_window_create(void *data, unsigned style, unsigned height, bool fullscreen) { #ifndef _XBOX - driver_t *driver = driver_get_ptr(); g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, fullscreen ? mon_rect->left : g_pos_x, @@ -289,9 +288,9 @@ bool win32_window_create(void *data, unsigned style, if (!g_hwnd) return false; - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)g_hwnd; + video_driver_display_type_set(RARCH_DISPLAY_WIN32); + video_driver_display_set(0); + video_driver_window_set((uintptr_t)g_hwnd); #endif return true; } diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 160b4a79f4..e4dc55e831 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -547,13 +547,12 @@ void x11_update_window_title(void *data) 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; + video_driver_display_type_set(RARCH_DISPLAY_X11); + video_driver_display_set((uintptr_t)g_x11_dpy); + video_driver_window_set((uintptr_t)g_x11_win); g_x11_true_full = true_full; return true; } diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index f70468f626..e030b0ca9b 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -210,8 +210,6 @@ static void sdl2_gfx_set_handles(sdl2_video_t *vid) { /* SysWMinfo headers are broken on OSX. */ #if defined(_WIN32) || defined(HAVE_X11) - driver_t *driver = driver_get_ptr(); - SDL_SysWMinfo info; SDL_VERSION(&info.version); @@ -219,13 +217,13 @@ static void sdl2_gfx_set_handles(sdl2_video_t *vid) return; #if defined(_WIN32) - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)info.info.win.window; + video_driver_display_type_set(RARCH_DISPLAY_WIN32); + video_driver_display_set(0); + video_driver_window_set((uintptr_t)info.info.win.window); #elif defined(HAVE_X11) - driver->display_type = RARCH_DISPLAY_X11; - driver->video_display = (uintptr_t)info.info.x11.display; - driver->video_window = (uintptr_t)info.info.x11.window; + video_driver_display_type_set(RARCH_DISPLAY_X11); + video_driver_display_set((uintptr_t)info.info.x11.display); + video_driver_window_set((uintptr_t)info.info.x11.window); #endif #endif } @@ -560,15 +558,13 @@ static bool sdl2_gfx_focus(void *data) static bool sdl2_gfx_suppress_screensaver(void *data, bool enable) { - driver_t *driver = driver_get_ptr(); - (void)data; (void)enable; - if (driver->display_type == RARCH_DISPLAY_X11) + if (video_driver_display_type_get() == RARCH_DISPLAY_X11) { #ifdef HAVE_X11 - x11_suspend_screensaver(driver->video_window); + x11_suspend_screensaver(video_driver_window_get()); #endif return true; } diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index e6c6e979c5..19c4bc718c 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -221,7 +221,6 @@ static void sdl_gfx_set_handles(void) { /* SysWMinfo headers are broken on OSX. */ #if defined(_WIN32) || defined(HAVE_X11) - driver_t *driver = driver_get_ptr(); SDL_SysWMinfo info; SDL_VERSION(&info.version); @@ -229,13 +228,13 @@ static void sdl_gfx_set_handles(void) return; #if defined(_WIN32) - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)info.window; + video_driver_display_type_set(RARCH_DISPLAY_WIN32); + video_driver_display_set(0); + video_driver_window_set((uintptr_t)info.window); #elif defined(HAVE_X11) - driver->display_type = RARCH_DISPLAY_X11; - driver->video_display = (uintptr_t)info.info.x11.display; - driver->video_window = (uintptr_t)info.info.x11.window; + video_driver_display_type_set(RARCH_DISPLAY_X11); + video_driver_display_set((uintptr_t)info.info.x11.display); + video_driver_window_set((uintptr_t)info.info.x11.window); #endif #endif } @@ -404,19 +403,16 @@ static bool sdl_gfx_focus(void *data) static bool sdl_gfx_suppress_screensaver(void *data, bool enable) { + (void)data; + (void)enable; #ifdef HAVE_X11 - driver_t *driver = driver_get_ptr(); - - if (driver->display_type == RARCH_DISPLAY_X11) + if (video_driver_display_type_get() == RARCH_DISPLAY_X11) { x11_suspend_screensaver(driver->video_window); return true; } #endif - (void)data; - (void)enable; - return false; } diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 546eaf50c8..d586644561 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -775,12 +775,10 @@ static bool xv_frame(void *data, const void *frame, unsigned width, static bool xv_suppress_screensaver(void *data, bool enable) { - driver_t *driver = driver_get_ptr(); - - if (driver->display_type != RARCH_DISPLAY_X11) + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(driver->video_window); + x11_suspend_screensaver(video_driver_window_get()); return true; } diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index 04ed16524a..39e24a38f6 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -522,11 +522,10 @@ static void gfx_ctx_glx_input_driver(void *data, static bool gfx_ctx_glx_suppress_screensaver(void *data, bool enable) { - driver_t *driver = driver_get_ptr(); - if (driver->display_type != RARCH_DISPLAY_X11) + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(driver->video_window); + x11_suspend_screensaver(video_driver_window_get()); return true; } diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 70252aea4e..8a1601cafd 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -423,15 +423,13 @@ static bool gfx_ctx_xegl_has_focus(void *data) static bool gfx_ctx_xegl_suppress_screensaver(void *data, bool enable) { - driver_t *driver = driver_get_ptr(); - (void)data; (void)enable; - if (driver->display_type != RARCH_DISPLAY_X11) + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(driver->video_window); + x11_suspend_screensaver(video_driver_window_get()); return true; } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4566a8c59b..93357385c6 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -69,6 +69,14 @@ typedef struct video_driver_state } filter; } video_driver_state_t; +/* Opaque handles to currently running window. + * Used by e.g. input drivers which bind to a window. + * Drivers are responsible for setting these if an input driver + * could potentially make use of this. */ +static uintptr_t video_display; +static uintptr_t video_window; +static enum rarch_display_type display_type; + /* Graphics driver requires RGBA byte order data (ABGR on little-endian) * for 32-bit. * This takes effect for overlay and shader cores that wants to load @@ -671,9 +679,9 @@ static bool init_video(void) else RARCH_LOG("Video @ fullscreen\n"); - driver->display_type = RARCH_DISPLAY_NONE; - driver->video_display = 0; - driver->video_window = 0; + video_driver_display_type_set(RARCH_DISPLAY_NONE); + video_driver_display_set(0); + video_driver_window_set(0); if (!init_video_pixel_converter(RARCH_SCALE_BASE * scale)) { @@ -1816,3 +1824,33 @@ void video_frame(const void *data, unsigned width, *frame_count = *frame_count + 1; } + +void video_driver_display_type_set(enum rarch_display_type type) +{ + display_type = type; +} + +uintptr_t video_driver_display_get(void) +{ + return video_display; +} + +void video_driver_display_set(uintptr_t idx) +{ + video_display = idx; +} + +enum rarch_display_type video_driver_display_type_get(void) +{ + return display_type; +} + +void video_driver_window_set(uintptr_t idx) +{ + video_window = idx; +} + +uintptr_t video_driver_window_get(void) +{ + return video_window; +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 1a877cb535..f89d5a9b2a 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -270,7 +270,6 @@ struct aspect_ratio_elem extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; - enum rarch_display_type { /* Non-bindable types like consoles, KMS, VideoCore, etc. */ @@ -531,6 +530,19 @@ const video_poke_interface_t *video_driver_get_poke(void); void video_frame(const void *data, unsigned width, unsigned height, size_t pitch); +uintptr_t video_driver_display_get(void); + +enum rarch_display_type video_driver_display_type_get(void); + +uintptr_t video_driver_window_get(void); + +void video_driver_display_type_set(enum rarch_display_type type); + +void video_driver_display_set(uintptr_t idx); + +void video_driver_window_set(uintptr_t idx); + + extern video_driver_t video_gl; extern video_driver_t video_psp1; extern video_driver_t video_vita2d; diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 96b030fb53..d5be3ef89d 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -26,6 +26,8 @@ #include "../input_joypad_driver.h" #include "../input_keymaps.h" +#include "../../gfx/video_driver.h" + #include "../../driver.h" #include "../../general.h" #include "../../verbosity.h" @@ -49,11 +51,10 @@ typedef struct x11_input static void *x_input_init(void) { - driver_t *driver = driver_get_ptr(); - settings_t *settings = config_get_ptr(); x11_input_t *x11; + settings_t *settings = config_get_ptr(); - if (driver->display_type != RARCH_DISPLAY_X11) + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) { RARCH_ERR("Currently active window is not an X11 window. Cannot use this driver.\n"); return NULL; @@ -64,8 +65,8 @@ static void *x_input_init(void) return NULL; /* Borrow the active X window ... */ - x11->display = (Display*)driver->video_display; - x11->win = (Window)driver->video_window; + x11->display = (Display*)video_driver_display_get(); + x11->win = (Window)video_driver_window_get(); x11->joypad = input_joypad_init_driver(settings->input.joypad_driver, x11); input_keymaps_init_keyboard_lut(rarch_key_map_x11);