From 5e755671dad603219daaa21a706eef046b392734 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 29 Mar 2013 13:46:11 +0100 Subject: [PATCH] Add show_mouse() context callback. --- gfx/context/androidegl_ctx.c | 1 + gfx/context/bbqnx_ctx.c | 1 + gfx/context/drm_egl_ctx.c | 1 + gfx/context/glx_ctx.c | 8 +++++++- gfx/context/ioseagl_ctx.c | 1 + gfx/context/ps3_ctx.c | 1 + gfx/context/sdl_ctx.c | 9 ++++++++- gfx/context/vc_egl_ctx.c | 1 + gfx/context/wgl_ctx.c | 6 ++++++ gfx/context/x11_common.c | 10 +++++++++- gfx/context/x11_common.h | 2 +- gfx/context/xdk_ctx.c | 1 + gfx/context/xegl_ctx.c | 8 +++++++- gfx/gfx_context.h | 3 +++ gfx/gl.c | 2 ++ gfx/xvideo.c | 2 +- 16 files changed, 51 insertions(+), 6 deletions(-) diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index eb76b8ab8e..8ad0e45c4d 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -282,5 +282,6 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "android", }; diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c index 80c2d0a5f3..1b32be974f 100644 --- a/gfx/context/bbqnx_ctx.c +++ b/gfx/context/bbqnx_ctx.c @@ -404,5 +404,6 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = { NULL, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "blackberry_qnx", }; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 2f93a1760f..0fd295240f 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -629,6 +629,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "kms-egl", }; diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index 116400ba96..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,6 +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, + gfx_ctx_show_mouse, "glx", }; diff --git a/gfx/context/ioseagl_ctx.c b/gfx/context/ioseagl_ctx.c index 4b8515e462..1932e1e9d4 100644 --- a/gfx/context/ioseagl_ctx.c +++ b/gfx/context/ioseagl_ctx.c @@ -136,5 +136,6 @@ const gfx_ctx_driver_t gfx_ctx_ios = { NULL, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "ios", }; diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 74d38285af..a5a34e324b 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -430,6 +430,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { NULL, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "ps3", #ifdef HAVE_RMENU gfx_ctx_get_available_resolutions, diff --git a/gfx/context/sdl_ctx.c b/gfx/context/sdl_ctx.c index a04d85c33b..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,6 +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, + gfx_ctx_show_mouse, "sdl-gl", }; diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index 48d1e82c7c..5ab7f1ebbc 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -480,5 +480,6 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_get_proc_address, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "videocore", }; diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 43d3646e10..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,6 +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, + 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/xdk_ctx.c b/gfx/context/xdk_ctx.c index 37d5ea0f94..714a02123b 100644 --- a/gfx/context/xdk_ctx.c +++ b/gfx/context/xdk_ctx.c @@ -395,6 +395,7 @@ const gfx_ctx_driver_t gfx_ctx_xdk = { NULL, gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, + NULL, "xdk", #if defined(HAVE_RMENU) gfx_ctx_xdk_get_available_resolutions, diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index cb86825fb2..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,6 +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, + gfx_ctx_show_mouse, "x-egl", }; diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index 6b9fb7d176..260924ea93 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -110,6 +110,9 @@ 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); + // 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 4ea379db22..3082727197 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -2196,6 +2196,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);