diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 36b9318..49fe92b 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -638,6 +638,14 @@ extern "C" { #define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4" /** + * \ brief Tell SDL which Dispmanx layer to use on a RaspberryPI + * + * Also known as Z-order. The variable can take a negative + * or positive value. The default is 10000. + */ +#define SDL_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" + +/** * \brief An enumeration of hint priorities */ typedef enum diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 065f209..55eebcd 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -24,6 +24,7 @@ #include "SDL_assert.h" #include "SDL_surface.h" +#include "SDL_hints.h" #include "SDL_rpivideo.h" #include "SDL_rpimouse.h" @@ -117,7 +118,9 @@ RPI_ShowCursor(SDL_Cursor * cursor) SDL_VideoDisplay *display; SDL_DisplayData *data; VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */ , 255 /*opacity 0->255*/, 0 /* mask */ }; - + uint32_t mouse_layer=SDL_RPI_MOUSELAYER; + const char *env; + mouse = SDL_GetMouse(); if (mouse == NULL) { return -1; @@ -167,9 +170,14 @@ RPI_ShowCursor(SDL_Cursor * cursor) update = vc_dispmanx_update_start( 10 ); SDL_assert( update ); + env = SDL_GetHint(SDL_RPI_VIDEO_LAYER); + if (env) { + mouse_layer = SDL_atoi(env) + 1; + } + curdata->element = vc_dispmanx_element_add( update, data->dispman_display, - SDL_RPI_MOUSELAYER, // layer + mouse_layer, // layer &dst_rect, curdata->resource, &src_rect, diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 539c88c..e2bb840 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -38,6 +38,7 @@ #include "SDL_events.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" +#include "SDL_hints.h" #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" @@ -221,6 +222,8 @@ RPI_CreateWindow(_THIS, SDL_Window * window) VC_RECT_T src_rect; VC_DISPMANX_ALPHA_T dispman_alpha; DISPMANX_UPDATE_HANDLE_T dispman_update; + uint32_t layer=SDL_RPI_VIDEOLAYER; + const char *env; /* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */ dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; @@ -253,8 +256,22 @@ RPI_CreateWindow(_THIS, SDL_Window * window) src_rect.width = window->w << 16; src_rect.height = window->h << 16; + env = SDL_GetHint(SDL_RPI_VIDEO_LAYER); + if (env) { + layer = SDL_atoi(env); + } + dispman_update = vc_dispmanx_update_start( 0 ); - wdata->dispman_window.element = vc_dispmanx_element_add ( dispman_update, displaydata->dispman_display, SDL_RPI_VIDEOLAYER /* layer */, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha*/, 0/*clamp*/, 0/*transform*/); + wdata->dispman_window.element = vc_dispmanx_element_add (dispman_update, + displaydata->dispman_display, + layer /* layer */, + &dst_rect, + 0 /*src*/, + &src_rect, + DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha*/, + 0 /*clamp*/, + 0 /*transform*/); wdata->dispman_window.width = window->w; wdata->dispman_window.height = window->h; vc_dispmanx_update_submit_sync( dispman_update );