Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_video.c @ 3023:d72a0dd80e8b
DirectFB cleanups & simple window manager
- use SDL_getenv, not getenv ...
- no more support for 0.9.25 - not even mentioned any longer on directfb.org
- fix fullscreen issues
- add a simple window manager unless the directfb team comes up with a working wm.
The driver has support for a very, very basic window manager you may
want to use when runnning with "wm=default". Use
export SDL_DIRECTFB_WM=1
to enable basic window borders including icon support. In order to have the window title rendered,
you need to have the following font installed:
/usr/share/fonts/truetype/freefont/FreeSans.ttf
author | Couriersud <couriersud@arcor.de> |
---|---|
date | Sun, 11 Jan 2009 23:49:23 +0000 |
parents | 8cc00819c8d6 |
children | 62d4992e5a92 |
comparison
equal
deleted
inserted
replaced
3022:db20dde98dd3 | 3023:d72a0dd80e8b |
---|---|
33 #include <unistd.h> | 33 #include <unistd.h> |
34 #include <sys/mman.h> | 34 #include <sys/mman.h> |
35 | 35 |
36 #include <directfb.h> | 36 #include <directfb.h> |
37 #include <directfb_version.h> | 37 #include <directfb_version.h> |
38 #include <directfb_strings.h> | |
38 | 39 |
39 #include "SDL_video.h" | 40 #include "SDL_video.h" |
40 #include "SDL_mouse.h" | 41 #include "SDL_mouse.h" |
41 #include "../SDL_sysvideo.h" | 42 #include "../SDL_sysvideo.h" |
42 #include "../SDL_pixels_c.h" | 43 #include "../SDL_pixels_c.h" |
53 static void DirectFB_VideoQuit(_THIS); | 54 static void DirectFB_VideoQuit(_THIS); |
54 | 55 |
55 static int DirectFB_Available(void); | 56 static int DirectFB_Available(void); |
56 static SDL_VideoDevice *DirectFB_CreateDevice(int devindex); | 57 static SDL_VideoDevice *DirectFB_CreateDevice(int devindex); |
57 | 58 |
59 #if 0 | |
58 static int DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp); | 60 static int DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp); |
59 static int DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp); | 61 static int DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp); |
62 #endif | |
60 | 63 |
61 VideoBootStrap DirectFB_bootstrap = { | 64 VideoBootStrap DirectFB_bootstrap = { |
62 "directfb", "DirectFB", | 65 "directfb", "DirectFB", |
63 DirectFB_Available, DirectFB_CreateDevice | 66 DirectFB_Available, DirectFB_CreateDevice |
64 }; | 67 }; |
109 #endif | 112 #endif |
110 device->PumpEvents = DirectFB_PumpEventsWindow; | 113 device->PumpEvents = DirectFB_PumpEventsWindow; |
111 device->CreateWindow = DirectFB_CreateWindow; | 114 device->CreateWindow = DirectFB_CreateWindow; |
112 device->CreateWindowFrom = DirectFB_CreateWindowFrom; | 115 device->CreateWindowFrom = DirectFB_CreateWindowFrom; |
113 device->SetWindowTitle = DirectFB_SetWindowTitle; | 116 device->SetWindowTitle = DirectFB_SetWindowTitle; |
117 device->SetWindowIcon = DirectFB_SetWindowIcon; | |
114 device->SetWindowPosition = DirectFB_SetWindowPosition; | 118 device->SetWindowPosition = DirectFB_SetWindowPosition; |
115 device->SetWindowSize = DirectFB_SetWindowSize; | 119 device->SetWindowSize = DirectFB_SetWindowSize; |
116 device->ShowWindow = DirectFB_ShowWindow; | 120 device->ShowWindow = DirectFB_ShowWindow; |
117 device->HideWindow = DirectFB_HideWindow; | 121 device->HideWindow = DirectFB_HideWindow; |
118 device->RaiseWindow = DirectFB_RaiseWindow; | 122 device->RaiseWindow = DirectFB_RaiseWindow; |
143 if (device) | 147 if (device) |
144 free(device); | 148 free(device); |
145 return (0); | 149 return (0); |
146 } | 150 } |
147 | 151 |
152 static const DirectFBSurfaceDrawingFlagsNames(drawing_flags); | |
153 static const DirectFBSurfaceBlittingFlagsNames(blitting_flags); | |
154 static const DirectFBAccelerationMaskNames(acceleration_mask); | |
155 | |
156 static void | |
157 DirectFB_DeviceInformation(IDirectFB * dfb) | |
158 { | |
159 DFBGraphicsDeviceDescription desc; | |
160 int n; | |
161 | |
162 dfb->GetDeviceDescription(dfb, &desc); | |
163 | |
164 fprintf(LOG_CHANNEL, "DirectFB Device Information\n"); | |
165 fprintf(LOG_CHANNEL, "===========================\n"); | |
166 fprintf(LOG_CHANNEL, "Name: %s\n", desc.name); | |
167 fprintf(LOG_CHANNEL, "Vendor: %s\n", desc.vendor); | |
168 fprintf(LOG_CHANNEL, "Driver Name: %s\n", desc.driver.name); | |
169 fprintf(LOG_CHANNEL, "Driver Vendor: %s\n", desc.driver.vendor); | |
170 fprintf(LOG_CHANNEL, "Driver Version: %d.%d\n", desc.driver.major, | |
171 desc.driver.minor); | |
172 | |
173 fprintf(LOG_CHANNEL, "\nVideo memoory: %d\n", desc.video_memory); | |
174 | |
175 fprintf(LOG_CHANNEL, "\nBlitting flags:\n"); | |
176 for (n = 0; blitting_flags[n].flag; n++) { | |
177 if (desc.blitting_flags & blitting_flags[n].flag) | |
178 printf(" %s\n", blitting_flags[n].name); | |
179 } | |
180 | |
181 fprintf(LOG_CHANNEL, "\nDrawing flags:\n"); | |
182 for (n = 0; drawing_flags[n].flag; n++) { | |
183 if (desc.drawing_flags & drawing_flags[n].flag) | |
184 printf(" %s\n", drawing_flags[n].name); | |
185 } | |
186 | |
187 fprintf(LOG_CHANNEL, "\nAcceleration flags:\n"); | |
188 for (n = 0; acceleration_mask[n].mask; n++) { | |
189 if (desc.acceleration_mask & acceleration_mask[n].mask) | |
190 printf(" %s\n", acceleration_mask[n].name); | |
191 } | |
192 | |
193 | |
194 } | |
195 | |
148 static int | 196 static int |
149 DirectFB_VideoInit(_THIS) | 197 DirectFB_VideoInit(_THIS) |
150 { | 198 { |
151 IDirectFB *dfb = NULL; | 199 IDirectFB *dfb = NULL; |
152 DFB_DeviceData *devdata = NULL; | 200 DFB_DeviceData *devdata = NULL; |
157 | 205 |
158 SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); | 206 SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); |
159 | 207 |
160 /* avoid switching to the framebuffer when we | 208 /* avoid switching to the framebuffer when we |
161 * are running X11 */ | 209 * are running X11 */ |
162 stemp = getenv(DFBENV_USE_X11_CHECK); | 210 stemp = SDL_getenv(DFBENV_USE_X11_CHECK); |
163 if (stemp) | 211 if (stemp) |
164 ret = atoi(stemp); | 212 ret = atoi(stemp); |
165 else | 213 else |
166 ret = 1; | 214 ret = 1; |
167 | 215 |
168 if (ret) { | 216 if (ret) { |
169 if (getenv("DISPLAY")) | 217 if (SDL_getenv("DISPLAY")) |
170 DirectFBSetOption("system", "x11"); | 218 DirectFBSetOption("system", "x11"); |
171 else | 219 else |
172 DirectFBSetOption("disable-module", "x11input"); | 220 DirectFBSetOption("disable-module", "x11input"); |
173 } | 221 } |
174 | 222 |
175 devdata->use_linux_input = 1; /* default: on */ | 223 devdata->use_linux_input = 1; /* default: on */ |
176 stemp = getenv(DFBENV_USE_LINUX_INPUT); | 224 stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT); |
177 if (stemp) | 225 if (stemp) |
178 devdata->use_linux_input = atoi(stemp); | 226 devdata->use_linux_input = atoi(stemp); |
179 | 227 |
180 if (!devdata->use_linux_input) | 228 if (!devdata->use_linux_input) |
181 DirectFBSetOption("disable-module", "linux_input"); | 229 DirectFBSetOption("disable-module", "linux_input"); |
182 | 230 |
183 SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); | 231 SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); |
184 | 232 |
233 DirectFB_DeviceInformation(dfb); | |
185 devdata->use_yuv_underlays = 0; /* default: off */ | 234 devdata->use_yuv_underlays = 0; /* default: off */ |
186 stemp = getenv(DFBENV_USE_YUV_UNDERLAY); | 235 stemp = SDL_getenv(DFBENV_USE_YUV_UNDERLAY); |
187 if (stemp) | 236 if (stemp) |
188 devdata->use_yuv_underlays = atoi(stemp); | 237 devdata->use_yuv_underlays = atoi(stemp); |
189 | 238 |
190 | 239 |
191 /* Create global Eventbuffer for axis events */ | 240 /* Create global Eventbuffer for axis events */ |
192 if (devdata->use_linux_input) { | 241 if (devdata->use_linux_input) { |
193 SDL_DFB_CHECKERR(dfb-> | 242 SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, |
194 CreateInputEventBuffer(dfb, DICAPS_ALL, | 243 DFB_TRUE, |
195 DFB_TRUE, &devdata->events)); | 244 &devdata->events)); |
196 } else { | 245 } else { |
197 SDL_DFB_CHECKERR(dfb-> | 246 SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES |
198 CreateInputEventBuffer(dfb, | 247 /*DICAPS_ALL */ , |
199 DICAPS_AXES /*DICAPS_ALL */ , | 248 DFB_TRUE, |
200 DFB_TRUE, &devdata->events)); | 249 &devdata->events)); |
201 } | 250 } |
202 | 251 |
203 devdata->initialized = 1; | 252 devdata->initialized = 1; |
253 | |
254 /* simple window manager support */ | |
255 stemp = SDL_getenv(DFBENV_USE_WM); | |
256 if (stemp) | |
257 devdata->has_own_wm = atoi(stemp); | |
258 else | |
259 devdata->has_own_wm = 0; | |
260 | |
204 devdata->dfb = dfb; | 261 devdata->dfb = dfb; |
205 devdata->firstwin = NULL; | 262 devdata->firstwin = NULL; |
206 | 263 |
207 _this->driverdata = devdata; | 264 _this->driverdata = devdata; |
208 | 265 |
213 #endif | 270 #endif |
214 | 271 |
215 DirectFB_AddRenderDriver(_this); | 272 DirectFB_AddRenderDriver(_this); |
216 DirectFB_InitMouse(_this); | 273 DirectFB_InitMouse(_this); |
217 DirectFB_InitKeyboard(_this); | 274 DirectFB_InitKeyboard(_this); |
218 | |
219 | 275 |
220 return 0; | 276 return 0; |
221 | 277 |
222 | 278 |
223 error: | 279 error: |
243 #endif | 299 #endif |
244 | 300 |
245 devdata->initialized = 0; | 301 devdata->initialized = 0; |
246 } | 302 } |
247 | 303 |
304 #if 0 | |
248 static int | 305 static int |
249 DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp) | 306 DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp) |
250 { | 307 { |
251 return -1; | 308 return -1; |
252 } | 309 } |
254 static int | 311 static int |
255 DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp) | 312 DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp) |
256 { | 313 { |
257 return -1; | 314 return -1; |
258 } | 315 } |
316 #endif |