Commit 771abd36 authored by Sam Lantinga's avatar Sam Lantinga

Date: Sun, 31 Aug 2008 17:53:59 +0200

From: Couriersud
Subject: Re: Updated DirectFB driver for SDL1.3

attached is a patch which brings the directfb driver in line with
current svn. In addition:

* driver now is in line with the structure of the X11 driver.
  This adds a couple of files.
* driver now supports relative mouse movements

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403190
parent 9be698fb
This diff is collapsed.
...@@ -25,5 +25,6 @@ ...@@ -25,5 +25,6 @@
/* Functions to be exported */ /* Functions to be exported */
extern void DirectFB_InitKeyboard(_THIS); extern void DirectFB_InitKeyboard(_THIS);
extern void DirectFB_QuitKeyboard(_THIS);
extern void DirectFB_PumpEventsWindow(_THIS); extern void DirectFB_PumpEventsWindow(_THIS);
extern SDLKey DirectFB_GetLayoutKey(_THIS, SDLKey physicalKey); extern SDLKey DirectFB_GetLayoutKey(_THIS, SDLKey physicalKey);
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_directfb_modes_h
#define _SDL_directfb_modes_h
#include "SDL_DirectFB_video.h"
#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL)
typedef struct _DFB_DisplayData DFB_DisplayData;
struct _DFB_DisplayData
{
IDirectFBDisplayLayer *layer;
DFBSurfacePixelFormat pixelformat;
/* FIXME: support for multiple video layer.
* However, I do not know any card supporting
* more than one
*/
DFBDisplayLayerID vidID;
IDirectFBDisplayLayer *vidlayer;
int vidIDinuse;
int cw;
int ch;
};
extern void DirectFB_InitModes(_THIS);
extern void DirectFB_GetDisplayModes(_THIS);
extern int DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void DirectFB_QuitModes(_THIS);
#endif /* _SDL_directfb_modes_h */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "SDL_config.h" #include "SDL_config.h"
#include "SDL_DirectFB_video.h" #include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_mouse.h"
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
...@@ -49,7 +48,8 @@ DirectFB_InitMouse(_THIS) ...@@ -49,7 +48,8 @@ DirectFB_InitMouse(_THIS)
mouse.FreeCursor = DirectFB_FreeCursor; mouse.FreeCursor = DirectFB_FreeCursor;
mouse.WarpMouse = DirectFB_WarpMouse; mouse.WarpMouse = DirectFB_WarpMouse;
mouse.FreeMouse = DirectFB_FreeMouse; mouse.FreeMouse = DirectFB_FreeMouse;
devdata->mouse = SDL_AddMouse(&mouse, -1); mouse.cursor_shown = 1;
devdata->mouse = SDL_AddMouse(&mouse, -1, "Mouse", 0, 0, 1);
} }
void void
...@@ -85,23 +85,21 @@ DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) ...@@ -85,23 +85,21 @@ DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
dsc.height = surface->h; dsc.height = surface->h;
dsc.pixelformat = DSPF_ARGB; dsc.pixelformat = DSPF_ARGB;
SDL_DFB_CHECKERR(devdata-> SDL_DFB_CHECKERR(devdata->dfb->
dfb->CreateSurface(devdata->dfb, &dsc, &curdata->surf)); CreateSurface(devdata->dfb, &dsc, &curdata->surf));
curdata->hotx = hot_x; curdata->hotx = hot_x;
curdata->hoty = hot_y; curdata->hoty = hot_y;
cursor->driverdata = curdata; cursor->driverdata = curdata;
SDL_DFB_CHECKERR(curdata-> SDL_DFB_CHECKERR(curdata->surf->
surf->Lock(curdata->surf, DSLF_WRITE, (void *) &dest, Lock(curdata->surf, DSLF_WRITE, (void *) &dest, &pitch));
&pitch));
//FIXME: Implies a lot of things, e.g. rgba format for SDL_SURFACE .... /* Relies on the fact that this is only called with ARGB surface. */
p = surface->pixels; p = surface->pixels;
for (i = 0; i < surface->w * surface->h; i++) for (i = 0; i < surface->h; i++)
if (p[i] == 0x00000000) memcpy((char *) dest + i * pitch, (char *) p + i * surface->pitch,
dest[i] = 0x00000000; 4 * surface->w);
else
dest[i] = p[i];
curdata->surf->Unlock(curdata->surf); curdata->surf->Unlock(curdata->surf);
return cursor; return cursor;
error: error:
...@@ -113,38 +111,39 @@ static int ...@@ -113,38 +111,39 @@ static int
DirectFB_ShowCursor(SDL_Cursor * cursor) DirectFB_ShowCursor(SDL_Cursor * cursor)
{ {
SDL_DFB_CURSORDATA(cursor); SDL_DFB_CURSORDATA(cursor);
SDL_VideoDevice *dev = SDL_GetVideoDevice();
SDL_DFB_DEVICEDATA(dev);
#if 0
DFB_DisplayData *dispdata =
(DFB_DisplayData *) dev->displays[dev->current_display].driverdata;
#endif
DFBResult ret; DFBResult ret;
SDL_WindowID wid; SDL_WindowID wid;
wid = SDL_GetFocusWindow(); wid = SDL_GetFocusWindow();
if (!wid) if (wid < 0)
return -1; return -1;
else { else {
SDL_Window *window = SDL_GetWindowFromID(wid); SDL_Window *window = SDL_GetWindowFromID(wid);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
if (display) {
DFB_DisplayData *dispdata =
(DFB_DisplayData *) display->driverdata;
DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
if (cursor) if (cursor)
SDL_DFB_CHECKERR(windata->window->SetCursorShape(windata->window, SDL_DFB_CHECKERR(windata->window->
curdata->surf, SetCursorShape(windata->window,
curdata->hotx, curdata->surf, curdata->hotx,
curdata->hoty)); curdata->hoty));
//TODO: Check administrative
SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, /* fprintf(stdout, "Cursor is %s\n", cursor ? "on" : "off"); */
SDL_DFB_CHECKERR(dispdata->layer->
SetCooperativeLevel(dispdata->layer,
DLSCL_ADMINISTRATIVE)); DLSCL_ADMINISTRATIVE));
SDL_DFB_CHECKERR(dispdata->layer->SetCursorOpacity(dispdata->layer, SDL_DFB_CHECKERR(dispdata->layer->
cursor ? 0xC0 : SetCursorOpacity(dispdata->layer,
0x00)); cursor ? 0xC0 : 0x00));
SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, SDL_DFB_CHECKERR(dispdata->layer->
SetCooperativeLevel(dispdata->layer,
DLSCL_SHARED)); DLSCL_SHARED));
} }
}
return 0; return 0;
error: error:
...@@ -155,8 +154,7 @@ DirectFB_ShowCursor(SDL_Cursor * cursor) ...@@ -155,8 +154,7 @@ DirectFB_ShowCursor(SDL_Cursor * cursor)
static void static void
DirectFB_MoveCursor(SDL_Cursor * cursor) DirectFB_MoveCursor(SDL_Cursor * cursor)
{ {
SDL_DFB_CURSORDATA(cursor);
/* Do we need to do something here ? */
} }
/* Free a window manager cursor */ /* Free a window manager cursor */
...@@ -182,8 +180,8 @@ DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) ...@@ -182,8 +180,8 @@ DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
int cx, cy; int cx, cy;
SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy)); SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy));
SDL_DFB_CHECKERR(dispdata-> SDL_DFB_CHECKERR(dispdata->layer->
layer->WarpCursor(dispdata->layer, cx + x, cy + y)); WarpCursor(dispdata->layer, cx + x, cy + y));
error: error:
return; return;
...@@ -193,8 +191,7 @@ DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y) ...@@ -193,8 +191,7 @@ DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
static void static void
DirectFB_FreeMouse(SDL_Mouse * mouse) DirectFB_FreeMouse(SDL_Mouse * mouse)
{ {
// nothing yet /* nothing yet */
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with _this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_DirectFB_video.h"
#if SDL_DIRECTFB_OPENGL
struct SDL_GLDriverData
{
int gl_active; /* to stop switching drivers while we have a valid context */
int initialized;
DirectFB_GLContext *firstgl; /* linked list */
};
#define OPENGL_REQUIRS_DLOPEN
#if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN)
#include <dlfcn.h>
#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL))
#define GL_LoadFunction dlsym
#define GL_UnloadObject dlclose
#else
#define GL_LoadObject SDL_LoadObject
#define GL_LoadFunction SDL_LoadFunction
#define GL_UnloadObject SDL_UnloadObject
#endif
static void DirectFB_GL_UnloadLibrary(_THIS);
int
DirectFB_GL_Initialize(_THIS)
{
if (_this->gl_data) {
return 0;
}
_this->gl_data =
(struct SDL_GLDriverData *) SDL_calloc(1,
sizeof(struct
SDL_GLDriverData));
if (!_this->gl_data) {
SDL_OutOfMemory();
return -1;
}
_this->gl_data->initialized = 0;
++_this->gl_data->initialized;
_this->gl_data->firstgl = NULL;
if (DirectFB_GL_LoadLibrary(_this, NULL) < 0) {
return -1;
}
/* Initialize extensions */
/* FIXME needed?
* X11_GL_InitExtensions(_this);
*/
return 0;
}
void
DirectFB_GL_Shutdown(_THIS)
{
if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
return;
}
DirectFB_GL_UnloadLibrary(_this);
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
int
DirectFB_GL_LoadLibrary(_THIS, const char *path)
{
SDL_DFB_DEVICEDATA(_this);
void *handle = NULL;
SDL_DFB_DEBUG("Loadlibrary : %s\n", path);
if (_this->gl_data->gl_active) {
SDL_SetError("OpenGL context already created");
return -1;
}
if (path == NULL) {
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
if (path == NULL) {
path = "libGL.so";
}
}
handle = GL_LoadObject(path);
if (handle == NULL) {
SDL_DFB_ERR("Library not found: %s\n", path);
/* SDL_LoadObject() will call SDL_SetError() for us. */
return -1;
}
SDL_DFB_DEBUG("Loaded library: %s\n", path);
/* Unload the old driver and reset the pointers */
DirectFB_GL_UnloadLibrary(_this);
_this->gl_config.dll_handle = handle;
_this->gl_config.driver_loaded = 1;
if (path) {
SDL_strlcpy(_this->gl_config.driver_path, path,
SDL_arraysize(_this->gl_config.driver_path));
} else {
*_this->gl_config.driver_path = '\0';
}
devdata->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
devdata->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");
return 0;
}
static void
DirectFB_GL_UnloadLibrary(_THIS)
{
int ret;
if (_this->gl_config.driver_loaded) {
ret = GL_UnloadObject(_this->gl_config.dll_handle);
if (ret)
SDL_DFB_ERR("Error #%d trying to unload library.\n", ret);
_this->gl_config.dll_handle = NULL;
_this->gl_config.driver_loaded = 0;
}
}
void *
DirectFB_GL_GetProcAddress(_THIS, const char *proc)
{
void *handle;
handle = _this->gl_config.dll_handle;
return GL_LoadFunction(handle, proc);
}
SDL_GLContext
DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
DirectFB_GLContext *context;
int ret;
SDL_DFB_CALLOC(context, 1, sizeof(*context));
SDL_DFB_CHECKERR(windata->surface->
GetGL(windata->surface, &context->context));
SDL_DFB_CHECKERR(context->context->Unlock(context->context));
context->next = _this->gl_data->firstgl;
_this->gl_data->firstgl = context;
if (DirectFB_GL_MakeCurrent(_this, window, context) < 0) {
DirectFB_GL_DeleteContext(_this, context);
return NULL;
}
return context;
error:
return NULL;
}
int
DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
SDL_DFB_WINDOWDATA(window);
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
DirectFB_GLContext *p;
int ret;
for (p = _this->gl_data->firstgl; p; p = p->next)
p->context->Unlock(p->context);
if (windata) {
int cw, ch;
windata->gl_context = NULL;
/* Everything is unlocked, check for a resize */
SDL_DFB_CHECKERR(windata->surface->
GetSize(windata->surface, &cw, &ch));
if (cw != window->w || ch != window->h)
SDL_DFB_CHECKERR(windata->window->
ResizeSurface(windata->window, window->w,
window->h));
}
if (ctx != NULL) {
SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context));
}
if (windata)
windata->gl_context = ctx;
return 0;
error:
return -1;
}
int
DirectFB_GL_SetSwapInterval(_THIS, int interval)
{
SDL_Unsupported();
return -1;
}
int
DirectFB_GL_GetSwapInterval(_THIS)
{
SDL_Unsupported();
return -1;
}
void
DirectFB_GL_SwapWindow(_THIS, SDL_Window * window)
{
SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
int ret;
DFBRegion region;
region.x1 = 0;
region.y1 = 0;
region.x2 = window->w;
region.y2 = window->h;
if (devdata->glFinish)
devdata->glFinish();
else if (devdata->glFlush)
devdata->glFlush();
if (1 || windata->gl_context) {
/* SDL_DFB_CHECKERR(windata->gl_context->context->Unlock(windata->gl_context->context)); */
SDL_DFB_CHECKERR(windata->surface->
Flip(windata->surface, &region, DSFLIP_ONSYNC));
/* SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context)); */
}
return;
error:
return;
}
void
DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context)
{
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
DirectFB_GLContext *p;
ctx->context->Unlock(ctx->context);
ctx->context->Release(ctx->context);
p = _this->gl_data->firstgl;
while (p && p->next != ctx)
p = p->next;
if (p)
p->next = ctx->next;
else
_this->gl_data->firstgl = ctx->next;
SDL_DFB_FREE(ctx);
}
#endif
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_directfb_opengl_h
#define _SDL_directfb_opengl_h
#if SDL_DIRECTFB_OPENGL
#include "SDL_opengl.h"
typedef struct _DirectFB_GLContext DirectFB_GLContext;
struct _DirectFB_GLContext
{
IDirectFBGL *context;
DirectFB_GLContext *next;
};
/* OpenGL functions */
extern int DirectFB_GL_Initialize(_THIS);
extern void DirectFB_GL_Shutdown(_THIS);
extern int DirectFB_GL_LoadLibrary(_THIS, const char *path);
extern void *DirectFB_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_GLContext DirectFB_GL_CreateContext(_THIS, SDL_Window * window);
extern int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window,
SDL_GLContext context);
extern int DirectFB_GL_SetSwapInterval(_THIS, int interval);
extern int DirectFB_GL_GetSwapInterval(_THIS);
extern void DirectFB_GL_SwapWindow(_THIS, SDL_Window * window);
extern void DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context);
#endif /* SDL_DIRECTFB_OPENGL */
#endif /* _SDL_directfb_opengl_h */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
...@@ -24,9 +24,14 @@ ...@@ -24,9 +24,14 @@
#ifndef _SDL_DirectFB_video_h #ifndef _SDL_DirectFB_video_h
#define _SDL_DirectFB_video_h #define _SDL_DirectFB_video_h
#include "../SDL_sysvideo.h"
#include <directfb.h> #include <directfb.h>
#include <directfb_version.h> #include <directfb_version.h>
#include "SDL_mouse.h"
#define DEBUG 0
#define LOG_CHANNEL stdout #define LOG_CHANNEL stdout
#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23) #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
...@@ -42,10 +47,18 @@ ...@@ -42,10 +47,18 @@
#include "SDL_loadso.h" #include "SDL_loadso.h"
#endif #endif
#include "SDL_mouse.h" #include "SDL_DirectFB_events.h"
#include "../SDL_sysvideo.h" /*
* #include "SDL_DirectFB_gamma.h"
* #include "SDL_DirectFB_keyboard.h"
*/
#include "SDL_DirectFB_modes.h"
#include "SDL_DirectFB_mouse.h"
#include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h"
#define DEBUG 1 #define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY"
#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT"
#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0) #define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0) #define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
...@@ -102,50 +115,8 @@ ...@@ -102,50 +115,8 @@
/* Private display data */ /* Private display data */
#define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (DFB_DeviceData *) ((dev)->driverdata) #define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (DFB_DeviceData *) ((dev)->driverdata)
#define SDL_DFB_WINDOWDATA(win) DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL)
#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL)
typedef struct _DFB_DisplayData DFB_DisplayData;
#define DFB_MAX_SCREENS 10 #define DFB_MAX_SCREENS 10
#define DFB_MAX_MODES 50
struct _DFB_DisplayData
{
IDirectFBDisplayLayer *layer;
DFBSurfacePixelFormat pixelformat;
//FIXME: support for multiple layer ...
DFBDisplayLayerID vidID;
int vidIDinuse;
int cw;
int ch;
int nummodes;
SDL_DisplayMode *modelist;
#if 0
WMcursor *last_cursor;
WMcursor *blank_cursor;
WMcursor *default_cursor;
#endif
};
typedef struct _DFB_WindowData DFB_WindowData;
struct _DFB_WindowData
{
IDirectFBSurface *surface;
IDirectFBPalette *palette;
IDirectFBWindow *window;
IDirectFBGL *gl_context;
IDirectFBEventBuffer *eventbuffer;
DFBWindowID windowID;
int id; /* SDL window id */
DFB_WindowData *next;
Uint8 opacity;
};
typedef struct _DFB_DeviceData DFB_DeviceData; typedef struct _DFB_DeviceData DFB_DeviceData;
struct _DFB_DeviceData struct _DFB_DeviceData
...@@ -158,25 +129,14 @@ struct _DFB_DeviceData ...@@ -158,25 +129,14 @@ struct _DFB_DeviceData
int kbdgeneric; int kbdgeneric;
DFB_WindowData *firstwin; DFB_WindowData *firstwin;
int numscreens; int use_yuv_underlays;
DFBScreenID screenid[DFB_MAX_SCREENS];
DFBDisplayLayerID gralayer[DFB_MAX_SCREENS];
DFBDisplayLayerID vidlayer[DFB_MAX_SCREENS];
int aux; /* auxiliary integer for callbacks */
/* OpenGL */ /* OpenGL */
void (*glFinish) (void); void (*glFinish) (void);
void (*glFlush) (void); void (*glFlush) (void);
};
struct SDL_GLDriverData /* global events */
{ IDirectFBEventBuffer *events;
int gl_active; /* to stop switching drivers while we have a valid context */
#if SDL_DIRECTFB_OPENGL
IDirectFBGL *gl_context;
#endif /* SDL_DIRECTFB_OPENGL */
}; };
#endif /* _SDL_DirectFB_video_h */ #endif /* _SDL_DirectFB_video_h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_syswm.h"
#include "../SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_DirectFB_video.h"
int
DirectFB_CreateWindow(_THIS, SDL_Window * window)
{
SDL_DFB_DEVICEDATA(_this);
SDL_DFB_DISPLAYDATA(_this, window);
DFB_WindowData *windata;
DFBWindowOptions wopts;
DFBWindowDescription desc;
int ret, x, y;
SDL_DFB_DEBUG("Trace x %d y %d w %d h %d\n", window->x, window->y,
window->w, window->h);
window->driverdata = NULL;
SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
windata = (DFB_WindowData *) window->driverdata;
SDL_DFB_CHECKERR(devdata->dfb->
SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL));
SDL_DFB_CHECKERR(dispdata->layer->
SetCooperativeLevel(dispdata->layer,
DLSCL_ADMINISTRATIVE));
/* Fill the window description. */
if (window->x == SDL_WINDOWPOS_CENTERED) {
x = (dispdata->cw - window->w) / 2;
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
x = 0;
} else {
x = window->x;
}
if (window->y == SDL_WINDOWPOS_CENTERED) {
y = (dispdata->ch - window->h) / 2;
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
y = 0;
} else {
y = window->y;
}
if (window->flags & SDL_WINDOW_FULLSCREEN) {
x = 0;
y = 0;
}
desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT;
/*| DWDESC_CAPS | DWDESC_SURFACE_CAPS */
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0)
/* Needed for 1.2 */
desc.flags |= DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS;
desc.posx = x;
desc.posy = y;
#else
if (!(window->flags & SDL_WINDOW_FULLSCREEN)
&& window->x != SDL_WINDOWPOS_UNDEFINED
&& window->y != SDL_WINDOWPOS_UNDEFINED) {
desc.flags |= DWDESC_POSX | DWDESC_POSY;
desc.posx = x;
desc.posy = y;
}
#endif
desc.width = window->w;
desc.height = window->h;
desc.pixelformat = dispdata->pixelformat;
#if 0
desc.caps = 0;
desc.surface_caps =
DSCAPS_DOUBLE | DSCAPS_TRIPLE | DSCAPS_PREMULTIPLIED |
DSCAPS_VIDEOONLY;
#endif
desc.surface_caps = DSCAPS_PREMULTIPLIED;
/* DSCAPS_VIDEOONLY has negative impact on performance */
/* Create the window. */
SDL_DFB_CHECKERR(dispdata->layer->
CreateWindow(dispdata->layer, &desc, &windata->window));
windata->window->GetOptions(windata->window, &wopts);
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0)
if (window->flags & SDL_WINDOW_RESIZABLE)
wopts |= DWOP_SCALE;
else
wopts |= DWOP_KEEP_SIZE;
#else
wopts |= DWOP_KEEP_SIZE; /* if not we will crash ... */
#endif
if (window->flags & SDL_WINDOW_FULLSCREEN)
wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
windata->window->SetOptions(windata->window, wopts);
/* Get the window's surface. */
SDL_DFB_CHECKERR(windata->window->
GetSurface(windata->window, &windata->surface));
windata->window->SetOpacity(windata->window, 0xFF);
SDL_DFB_CHECKERR(windata->window->
CreateEventBuffer(windata->window,
&(windata->eventbuffer)));
SDL_DFB_CHECKERR(windata->window->
EnableEvents(windata->window, DWET_ALL));
if (window->flags & SDL_WINDOW_FULLSCREEN)
windata->window->SetStackingClass(windata->window, DWSC_UPPER);
/* Make it the top most window. */
windata->window->RaiseToTop(windata->window);
windata->window->GetID(windata->window, &windata->windowID);
windata->window->GetSize(windata->window, &window->w, &window->h);
/* remember parent */
windata->id = window->id;
/* Add to list ... */
windata->next = devdata->firstwin;
windata->opacity = 0xFF;
devdata->firstwin = windata;
return 0;
error:
SDL_DFB_RELEASE(windata->window);
SDL_DFB_RELEASE(windata->surface);
return -1;
}
int
DirectFB_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
SDL_Unsupported();
return -1;
}
void
DirectFB_SetWindowTitle(_THIS, SDL_Window * window)
{
SDL_Unsupported();
}
void
DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
int x, y;
if (window->y == SDL_WINDOWPOS_UNDEFINED)
y = 0;
else
y = window->y;
if (window->x == SDL_WINDOWPOS_UNDEFINED)
x = 0;
else
x = window->x;
if (window->flags & SDL_WINDOW_FULLSCREEN) {
x = 0;
y = 0;
}
windata->window->MoveTo(windata->window, x, y);
}
void
DirectFB_SetWindowSize(_THIS, SDL_Window * window)
{
int ret;
SDL_DFB_WINDOWDATA(window);
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0)
int cw;
int ch;
/* Make sure all events are disabled for this operation ! */
SDL_DFB_CHECKERR(windata->window->
DisableEvents(windata->window, DWET_ALL));
SDL_DFB_CHECKERR(windata->window->GetSize(windata->window, &cw, &ch));
if (cw != window->w || ch != window->h)
SDL_DFB_CHECKERR(windata->window->
Resize(windata->window, window->w, window->h));
SDL_DFB_CHECKERR(windata->window->
EnableEvents(windata->window, DWET_ALL));
#else
SDL_DFB_CHECKERR(windata->window->
Resize(windata->window, window->w, window->h));
#endif
SDL_DFB_CHECKERR(windata->window->GetSize(windata->window, &window->w, &window->h)); /* if a window manager should have decided otherwise */
SDL_OnWindowResized(window);
}
return;
error:
windata->window->EnableEvents(windata->window, DWET_ALL);
return;
}
void
DirectFB_ShowWindow(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
windata->window->SetOpacity(windata->window, windata->opacity);
}
void
DirectFB_HideWindow(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
windata->window->GetOpacity(windata->window, &windata->opacity);
windata->window->SetOpacity(windata->window, 0);
}
void
DirectFB_RaiseWindow(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
windata->window->RaiseToTop(windata->window);
windata->window->RequestFocus(windata->window);
}
void
DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
{
/* FIXME: Size to Desktop ? */
SDL_Unsupported();
}
void
DirectFB_MinimizeWindow(_THIS, SDL_Window * window)
{
/* FIXME: Size to 32x32 ? */
SDL_Unsupported();
}
void
DirectFB_RestoreWindow(_THIS, SDL_Window * window)
{
SDL_Unsupported();
}
void
DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
windata->window->GrabPointer(windata->window);
windata->window->GrabKeyboard(windata->window);
} else {
windata->window->UngrabPointer(windata->window);
windata->window->UngrabKeyboard(windata->window);
}
}
void
DirectFB_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
DFB_WindowData *p;
SDL_DFB_DEBUG("Trace\n");
SDL_DFB_RELEASE(windata->eventbuffer);
SDL_DFB_RELEASE(windata->surface);
SDL_DFB_RELEASE(windata->window);
/* Remove from list ... */
p = devdata->firstwin;
while (p && p->next != windata)
p = p->next;
if (p)
p->next = windata->next;
else
devdata->firstwin = windata->next;
SDL_free(windata);
return;
}
SDL_bool
DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo * info)
{
SDL_Unsupported();
return SDL_FALSE;
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_directfb_window_h
#define _SDL_directfb_window_h
#define SDL_DFB_WINDOWDATA(win) DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL)
typedef struct _DFB_WindowData DFB_WindowData;
struct _DFB_WindowData
{
IDirectFBSurface *surface;
IDirectFBWindow *window;
DirectFB_GLContext *gl_context;
IDirectFBEventBuffer *eventbuffer;
DFBWindowID windowID;
DFB_WindowData *next;
Uint8 opacity;
SDL_WindowID id;
};
extern int DirectFB_CreateWindow(_THIS, SDL_Window * window);
extern int DirectFB_CreateWindowFrom(_THIS, SDL_Window * window,
const void *data);
extern void DirectFB_SetWindowTitle(_THIS, SDL_Window * window);
extern void DirectFB_SetWindowPosition(_THIS, SDL_Window * window);
extern void DirectFB_SetWindowSize(_THIS, SDL_Window * window);
extern void DirectFB_ShowWindow(_THIS, SDL_Window * window);
extern void DirectFB_HideWindow(_THIS, SDL_Window * window);
extern void DirectFB_RaiseWindow(_THIS, SDL_Window * window);
extern void DirectFB_MaximizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_MinimizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_RestoreWindow(_THIS, SDL_Window * window);
extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window);
extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
#endif /* _SDL_directfb_window_h */
/* vi: set ts=4 sw=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment