diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 759ee781b7..1b2ddbc15b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -772,3 +772,15 @@ bool video_driver_read_viewport(uint8_t *buffer) buffer); } +bool video_driver_focus(void) +{ + driver_t *driver = driver_get_ptr(); + + if (!driver) + return false; + if (!driver->video) + return false; + if (!driver->video->focus) + return false; + return driver->video->focus(driver->video_data); +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 51569a6863..42b4beb67e 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -303,6 +303,8 @@ bool video_driver_read_viewport(uint8_t *buffer); bool video_driver_set_shader(enum rarch_shader_type type, const char *path); +bool video_driver_focus(void); + #ifdef __cplusplus } #endif diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 8977c693b8..70900da320 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -271,10 +271,9 @@ static void x_input_free(void *data) static void x_input_poll_mouse(x11_input_t *x11) { - Window root_win, child_win; - int root_x, root_y, win_x, win_y; unsigned mask; - driver_t *driver = driver_get_ptr(); + int root_x, root_y, win_x, win_y; + Window root_win, child_win; x11->mouse_last_x = x11->mouse_x; x11->mouse_last_y = x11->mouse_y; @@ -293,7 +292,7 @@ static void x_input_poll_mouse(x11_input_t *x11) x11->mouse_r = mask & Button3Mask; /* Somewhat hacky, but seem to do the job. */ - if (x11->grab_mouse && driver->video->focus(driver->video_data)) + if (x11->grab_mouse && video_driver_focus()) { int mid_w, mid_h; struct video_viewport vp = {0}; @@ -335,9 +334,8 @@ void x_input_poll_wheel(void *data, XButtonEvent *event, bool latch) static void x_input_poll(void *data) { x11_input_t *x11 = (x11_input_t*)data; - driver_t *driver = driver_get_ptr(); - if (driver->video->focus(driver->video_data)) + if (video_driver_focus()) XQueryKeymap(x11->display, x11->state); else memset(x11->state, 0, sizeof(x11->state));