summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2016-10-18 23:24:49 -0700
committerSam Lantinga <slouken@libsdl.org>2016-10-18 23:24:49 -0700
commit0d62d07ca1e8ef9ed283bbd06264e5750a61aa76 (patch)
tree5b3e1e2d6bc3079cec18fcedcb4a8a641f79949a
parent8bb4e77b9501bd0fca8629315eff479bcedb06a4 (diff)
downloadsdl-0d62d07ca1e8ef9ed283bbd06264e5750a61aa76.tar.gz
Fixed bug 3369 - RaspberryPI ability to specify a Dispmanx layer
Albert Casals On a RaspberryPI, it might become convenient to specify the Dispmanx layer SDL uses. Currently, it is hardcoded to be 10000 to sit above most applications. This can be specially useful when integrating other graphical apps and frameworks like OMXplayer, QT5 etc.. in order to have more flexibility on their Z-order.
-rw-r--r--include/SDL_hints.h8
-rw-r--r--src/video/raspberry/SDL_rpimouse.c12
-rw-r--r--src/video/raspberry/SDL_rpivideo.c21
3 files changed, 37 insertions, 4 deletions
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 9efb9550c..dd1546431 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -700,6 +700,14 @@ extern "C" {
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
/**
+ * \brief Tell SDL which Dispmanx layer to use on a Raspberry PI
+ *
+ * Also known as Z-order. The variable can take a negative or positive value.
+ * The default is 10000.
+ */
+#define SDL_HINT_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 3a84254ae..ae9bdfd5c 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 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_HINT_RPI_VIDEO_LAYER);
+ if (env) {
+ layer = SDL_atoi(env) + 1;
+ }
+
curdata->element = vc_dispmanx_element_add(update,
data->dispman_display,
- SDL_RPI_MOUSELAYER, // 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 40a398a03..67dc77b1c 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,11 +256,25 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
src_rect.width = window->w << 16;
src_rect.height = window->h << 16;
+ env = SDL_GetHint(SDL_HINT_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 );
+ vc_dispmanx_update_submit_sync(dispman_update);
if (!_this->egl_data) {
if (SDL_GL_LoadLibrary(NULL) < 0) {