diff src/video/directfb/SDL_DirectFB_video.c @ 2998:d364ee9b9c15

Date: Sun, 04 Jan 2009 20:53:30 +0100 From: Couriersud Subject: SDL1.3 DirectFB patches The attached contains the following directfb changes: - Dynamic loading of libdirectfb.so. This may to turned off as well in configure - Use linux-input by default. May be switched off by environment variable. - Added some code which will use directfb's x11 backend when DISPLAY is set.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Jan 2009 23:43:33 +0000
parents 6ce28e5287e9
children 8f4ed5ec2b06
line wrap: on
line diff
--- a/src/video/directfb/SDL_DirectFB_video.c	Sun Jan 04 23:41:09 2009 +0000
+++ b/src/video/directfb/SDL_DirectFB_video.c	Sun Jan 04 23:43:33 2009 +0000
@@ -46,6 +46,8 @@
 #include "SDL_DirectFB_render.h"
 #include "SDL_DirectFB_mouse.h"
 
+#include "SDL_DirectFB_dyn.h"
+
 /* Initialization/Query functions */
 static int DirectFB_VideoInit(_THIS);
 static void DirectFB_VideoQuit(_THIS);
@@ -66,14 +68,18 @@
 static int
 DirectFB_Available(void)
 {
+    if (!SDL_DirectFB_LoadLibrary())
+        return 0;
+    SDL_DirectFB_UnLoadLibrary();
     return 1;
 }
 
 static void
 DirectFB_DeleteDevice(SDL_VideoDevice * device)
 {
-    SDL_free(device->driverdata);
-    SDL_free(device);
+    SDL_DirectFB_UnLoadLibrary();
+    SDL_DFB_FREE(device->driverdata);
+    SDL_DFB_FREE(device);
 }
 
 static SDL_VideoDevice *
@@ -81,6 +87,9 @@
 {
     SDL_VideoDevice *device;
 
+    if (!SDL_DirectFB_LoadLibrary())
+        return NULL;
+
     /* Initialize all variables that we clean on shutdown */
     SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice));
 
@@ -140,22 +149,47 @@
 DirectFB_VideoInit(_THIS)
 {
     IDirectFB *dfb = NULL;
-    DFB_DeviceData *devdata;
+    DFB_DeviceData *devdata = NULL;
     char *stemp;
     DFBResult ret;
 
+    SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
+
     SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
+
+    /* avoid switching to the framebuffer when we
+     * are running X11 */
+    stemp = getenv(DFBENV_USE_X11_CHECK);
+    if (stemp)
+        ret = atoi(stemp);
+    else
+        ret = 1;
+
+    if (ret) {
+        if (getenv("DISPLAY"))
+            DirectFBSetOption("system", "x11");
+        else
+            DirectFBSetOption("disable-module", "x11input");
+    }
+
+    devdata->use_linux_input = 1;       /* default: on */
+    stemp = getenv(DFBENV_USE_LINUX_INPUT);
+    if (stemp)
+        devdata->use_linux_input = atoi(stemp);
+
+    if (!devdata->use_linux_input)
+        DirectFBSetOption("disable-module", "linux_input");
+
     SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
 
-    SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
-
     devdata->use_yuv_underlays = 0;     /* default: off */
     stemp = getenv(DFBENV_USE_YUV_UNDERLAY);
     if (stemp)
         devdata->use_yuv_underlays = atoi(stemp);
 
+
     /* Create global Eventbuffer for axis events */
-    if (LINUX_INPUT_SUPPORT) {
+    if (devdata->use_linux_input) {
         SDL_DFB_CHECKERR(dfb->
                          CreateInputEventBuffer(dfb, DICAPS_ALL,
                                                 DFB_TRUE, &devdata->events));
@@ -187,6 +221,7 @@
 
 
   error:
+    SDL_DFB_FREE(devdata);
     SDL_DFB_RELEASE(dfb);
     return -1;
 }
@@ -202,7 +237,6 @@
 
     SDL_DFB_RELEASE(devdata->events);
     SDL_DFB_RELEASE(devdata->dfb);
-    SDL_DFB_FREE(_this->driverdata);
 
 #if SDL_DIRECTFB_OPENGL
     DirectFB_GL_Shutdown(_this);