diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index 6032d79566..76dfc4e1c9 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -314,7 +314,7 @@ static bool gfx_ctx_set_video_mode( x11_set_window_attr(g_dpy, g_win); if (fullscreen) - x11_hide_mouse(g_dpy, g_win); + x11_show_mouse(g_dpy, g_win, false); if (true_full) { @@ -505,6 +505,11 @@ static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned return false; } +static void gfx_ctx_show_mouse(bool state) +{ + x11_show_mouse(g_dpy, g_win, state); +} + const gfx_ctx_driver_t gfx_ctx_glx = { gfx_ctx_init, gfx_ctx_destroy, @@ -522,7 +527,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, - NULL, + gfx_ctx_show_mouse, "glx", }; diff --git a/gfx/context/sdl_ctx.c b/gfx/context/sdl_ctx.c index 1c052c873a..316e094f72 100644 --- a/gfx/context/sdl_ctx.c +++ b/gfx/context/sdl_ctx.c @@ -187,7 +187,8 @@ static bool gfx_ctx_set_video_mode( RARCH_WARN("GL double buffer has not been enabled.\n"); // Remove that ugly mouse :D - SDL_ShowCursor(SDL_DISABLE); + if (fullscreen) + SDL_ShowCursor(SDL_DISABLE); sdl_set_handles(); @@ -354,6 +355,11 @@ static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned return false; } +static void gfx_ctx_show_mouse(bool state) +{ + SDL_ShowCursor(state ? SDL_ENABLE : SDL_DISABLE); +} + const gfx_ctx_driver_t gfx_ctx_sdl_gl = { gfx_ctx_init, gfx_ctx_destroy, @@ -371,7 +377,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, - NULL, + gfx_ctx_show_mouse, "sdl-gl", }; diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 16e3353e5c..e300fd06ca 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -439,6 +439,11 @@ static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned return false; } +static void gfx_ctx_show_mouse(bool state) +{ + show_cursor(state); +} + const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_init, gfx_ctx_destroy, @@ -456,7 +461,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, - NULL, + gfx_ctx_show_mouse, "wgl", }; diff --git a/gfx/context/x11_common.c b/gfx/context/x11_common.c index ad48b6c0fb..332bee23cd 100644 --- a/gfx/context/x11_common.c +++ b/gfx/context/x11_common.c @@ -22,7 +22,7 @@ #include "../../general.h" #include "../../input/input_common.h" -void x11_hide_mouse(Display *dpy, Window win) +static void x11_hide_mouse(Display *dpy, Window win) { Cursor no_ptr; Pixmap bm_no; @@ -47,6 +47,14 @@ void x11_hide_mouse(Display *dpy, Window win) XFreeColors(dpy, colormap, &black.pixel, 1, 0); } +void x11_show_mouse(Display *dpy, Window win, bool state) +{ + if (state) + XUndefineCursor(dpy, win); + else + x11_hide_mouse(dpy, win); +} + static Atom XA_NET_WM_STATE; static Atom XA_NET_WM_STATE_FULLSCREEN; static Atom XA_NET_MOVERESIZE_WINDOW; diff --git a/gfx/context/x11_common.h b/gfx/context/x11_common.h index aa725dde63..f39c8cc31c 100644 --- a/gfx/context/x11_common.h +++ b/gfx/context/x11_common.h @@ -31,7 +31,7 @@ #include "../../boolean.h" -void x11_hide_mouse(Display *dpy, Window win); +void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); void x11_suspend_screensaver(Window win); bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode); diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index bea4ce2fa2..f26aee2c23 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -374,7 +374,7 @@ static bool gfx_ctx_set_video_mode( x11_set_window_attr(g_dpy, g_win); if (fullscreen) - x11_hide_mouse(g_dpy, g_win); + x11_show_mouse(g_dpy, g_win, false); if (true_full) { @@ -548,6 +548,11 @@ static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned return false; } +static void gfx_ctx_show_mouse(bool state) +{ + x11_show_mouse(g_dpy, g_win, state); +} + const gfx_ctx_driver_t gfx_ctx_x_egl = { gfx_ctx_init, gfx_ctx_destroy, @@ -565,7 +570,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, - NULL, + gfx_ctx_show_mouse, "x-egl", }; diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index 5f66342239..260924ea93 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -110,9 +110,8 @@ typedef struct gfx_ctx_driver // Always returns true the first time it's called for a new index. The graphics core must handle a change in the handle correctly. bool (*write_egl_image)(const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle); - // Called after frame is rendered, but before swap. - // Can be used to render context-specific overlays and stuff. - bool (*post_render)(void *gl); + // Shows or hides mouse. Can be NULL if context doesn't have a concept of mouse pointer. + void (*show_mouse)(bool state); // Human readable string. const char *ident; diff --git a/gfx/gl.c b/gfx/gl.c index c5949b515c..4376be76de 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1553,10 +1553,8 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (msg && gl->font_ctx) gl->font_ctx->render_msg(gl, msg, NULL); - if (gl->ctx_driver->post_render) - context_post_render_func(gl); #ifdef HAVE_OVERLAY - else if (gl->overlay_enable) + if (gl->overlay_enable) gl_render_overlay(gl); #endif @@ -2354,6 +2352,8 @@ static void gl_overlay_enable(void *data, bool state) { gl_t *gl = (gl_t*)data; gl->overlay_enable = state; + if (gl->ctx_driver->show_mouse && gl->fullscreen) + gl->ctx_driver->show_mouse(state); } static void gl_overlay_full_screen(void *data, bool enable) diff --git a/gfx/xvideo.c b/gfx/xvideo.c index 87b85cbc22..8b6b44fde0 100644 --- a/gfx/xvideo.c +++ b/gfx/xvideo.c @@ -415,7 +415,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo if (video->fullscreen) { x11_windowed_fullscreen(xv->display, xv->window); - x11_hide_mouse(xv->display, xv->window); + x11_show_mouse(xv->display, xv->window, false); } xv->gc = XCreateGC(xv->display, xv->window, 0, 0);