comparison src/video/directfb/SDL_DirectFB_WM.c @ 5202:164f20ba08eb

Updated the DirectFB support, from Couriersud attached is a working directfb driver diff which works with the current changes. There are a number of changes around it as well, e.g. configure.in. The directfb renderdriver right now still depends on a some "includes" from src/video/directfb. That's why it is not yet moved to the new render folder.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Feb 2011 16:07:10 -0800
parents b196d2758026
children b530ef003506
comparison
equal deleted inserted replaced
5201:7c3422025c35 5202:164f20ba08eb
16 License along with this library; if not, write to the Free Software 16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21
22 SDL1.3 DirectFB driver by couriersud@arcor.de
23
21 */ 24 */
22 #include "SDL_config.h"
23
24 //#include "SDL_syswm.h"
25 //#include "../SDL_sysvideo.h"
26 //#include "../../events/SDL_keyboard_c.h"
27 25
28 #include "SDL_DirectFB_video.h" 26 #include "SDL_DirectFB_video.h"
27 #include "SDL_DirectFB_window.h"
29 28
30 #include "../../events/SDL_windowevents_c.h" 29 #include "../../events/SDL_windowevents_c.h"
31 30
32 #define COLOR_EXPAND(col) col.r, col.g, col.b, col.a 31 #define COLOR_EXPAND(col) col.r, col.g, col.b, col.a
33 32
124 int x, y, w; 123 int x, y, w;
125 124
126 125
127 if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN)) 126 if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
128 return; 127 return;
128
129 SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
130 SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
131 SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
132 SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));
129 133
130 LoadFont(_this, window); 134 LoadFont(_this, window);
131 //s->SetDrawingFlags(s, DSDRAW_BLEND); 135 //s->SetDrawingFlags(s, DSDRAW_BLEND);
132 s->SetColor(s, COLOR_EXPAND(t->frame_color)); 136 s->SetColor(s, COLOR_EXPAND(t->frame_color));
133 /* top */ 137 /* top */
179 183
180 DFBResult 184 DFBResult
181 DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch) 185 DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch)
182 { 186 {
183 SDL_DFB_WINDOWDATA(window); 187 SDL_DFB_WINDOWDATA(window);
184 188 IDirectFBWindow *dfbwin = windata->dfbwin;
185 SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch)); 189
190 SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, cw, ch));
191 dfbwin->GetSize(dfbwin, cw, ch);
186 *cw -= windata->theme.left_size + windata->theme.right_size; 192 *cw -= windata->theme.left_size + windata->theme.right_size;
187 *ch -= 193 *ch -=
188 windata->theme.top_size + windata->theme.caption_size + 194 windata->theme.top_size + windata->theme.caption_size +
189 windata->theme.bottom_size; 195 windata->theme.bottom_size;
190 return DFB_OK; 196 return DFB_OK;
195 { 201 {
196 SDL_DFB_WINDOWDATA(window); 202 SDL_DFB_WINDOWDATA(window);
197 203
198 if (!windata->is_managed) 204 if (!windata->is_managed)
199 windata->theme = theme_none; 205 windata->theme = theme_none;
206 else if (flags & SDL_WINDOW_BORDERLESS)
207 //desc.caps |= DWCAPS_NODECORATION;)
208 windata->theme = theme_none;
200 else if (flags & SDL_WINDOW_FULLSCREEN) { 209 else if (flags & SDL_WINDOW_FULLSCREEN) {
201 windata->theme = theme_none; 210 windata->theme = theme_none;
202 } else if (flags & SDL_WINDOW_MAXIMIZED) { 211 } else if (flags & SDL_WINDOW_MAXIMIZED) {
203 windata->theme = theme_std; 212 windata->theme = theme_std;
204 windata->theme.left_size = 0; 213 windata->theme.left_size = 0;
218 windata->size.h = 227 windata->size.h =
219 h + windata->theme.top_size + 228 h + windata->theme.top_size +
220 windata->theme.caption_size + windata->theme.bottom_size; 229 windata->theme.caption_size + windata->theme.bottom_size;
221 } 230 }
222 231
223 void
224 DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
225 {
226 SDL_DFB_WINDOWDATA(window);
227 SDL_VideoDisplay *display = window->display;
228
229 SDL_DFB_CHECK(windata->window->GetPosition(windata->window,
230 &windata->restore.x, &windata->restore.y));
231 SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w,
232 &windata->restore.h));
233
234 DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
235
236 SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0));
237 SDL_DFB_CHECK(windata->window->Resize(windata->window,
238 display->current_mode.w, display->current_mode.h));
239 }
240
241 void
242 DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window)
243 {
244 SDL_DFB_WINDOWDATA(window);
245
246 DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
247 windata->restore.w, windata->restore.h);
248
249 SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w,
250 windata->restore.h));
251 SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x,
252 windata->restore.y));
253 }
254 232
255 enum 233 enum
256 { 234 {
257 WM_POS_NONE = 0x00, 235 WM_POS_NONE = 0x00,
258 WM_POS_CAPTION = 0x01, 236 WM_POS_CAPTION = 0x01,
305 } 283 }
306 } 284 }
307 return pos; 285 return pos;
308 } 286 }
309 287
310 static int wm_grab;
311 static int wm_lastx;
312 static int wm_lasty;
313
314 int 288 int
315 DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) 289 DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
316 { 290 {
317 SDL_DFB_DEVICEDATA(_this); 291 SDL_DFB_DEVICEDATA(_this);
318 SDL_DFB_WINDOWDATA(window); 292 SDL_DFB_WINDOWDATA(window);
319 DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); 293 DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
294 IDirectFBWindow *dfbwin = windata->dfbwin;
295 DFBWindowOptions wopts;
320 296
321 if (!windata->is_managed) 297 if (!windata->is_managed)
322 return 0; 298 return 0;
299
300 SDL_DFB_CHECK(dfbwin->GetOptions(dfbwin, &wopts));
323 301
324 switch (evt->type) { 302 switch (evt->type) {
325 case DWET_BUTTONDOWN: 303 case DWET_BUTTONDOWN:
326 if (evt->buttons & DIBM_LEFT) { 304 if (evt->buttons & DIBM_LEFT) {
327 int pos = WMPos(windata, evt->x, evt->y); 305 int pos = WMPos(windata, evt->x, evt->y);
328 switch (pos) { 306 switch (pos) {
329 case WM_POS_NONE: 307 case WM_POS_NONE:
330 return 0; 308 return 0;
331 case WM_POS_CLOSE: 309 case WM_POS_CLOSE:
332 wm_grab = WM_POS_NONE; 310 windata->wm_grab = WM_POS_NONE;
333 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0, 311 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0,
334 0); 312 0);
335 return 1; 313 return 1;
336 case WM_POS_MAX: 314 case WM_POS_MAX:
337 wm_grab = WM_POS_NONE; 315 windata->wm_grab = WM_POS_NONE;
338 if (window->flags & SDL_WINDOW_MAXIMIZED) { 316 if (window->flags & SDL_WINDOW_MAXIMIZED) {
339 SDL_RestoreWindow(window); 317 SDL_RestoreWindow(window);
340 } else { 318 } else {
341 SDL_MaximizeWindow(window); 319 SDL_MaximizeWindow(window);
342 } 320 }
343 return 1; 321 return 1;
344 case WM_POS_CAPTION: 322 case WM_POS_CAPTION:
345 DirectFB_RaiseWindow(_this, window); 323 if (!(wopts & DWOP_KEEP_STACKING)) {
324 DirectFB_RaiseWindow(_this, window);
325 }
326 if (window->flags & SDL_WINDOW_MAXIMIZED)
327 return 1;
346 /* fall through */ 328 /* fall through */
347 default: 329 default:
348 wm_grab = pos; 330 windata->wm_grab = pos;
349 if (gwindata != NULL) 331 if (gwindata != NULL)
350 SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window)); 332 SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
351 SDL_DFB_CHECK(windata->window->GrabPointer(windata->window)); 333 SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin));
352 wm_lastx = evt->cx; 334 windata->wm_lastx = evt->cx;
353 wm_lasty = evt->cy; 335 windata->wm_lasty = evt->cy;
354 } 336 }
355 } 337 }
356 return 1; 338 return 1;
357 case DWET_BUTTONUP: 339 case DWET_BUTTONUP:
340 if (!windata->wm_grab)
341 return 0;
342 if (!(evt->buttons & DIBM_LEFT)) {
343 if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
344 int dx = evt->cx - windata->wm_lastx;
345 int dy = evt->cy - windata->wm_lasty;
346
347 if (!(wopts & DWOP_KEEP_SIZE)) {
348 int cw, ch;
349 if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
350 dx = 0;
351 else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
352 dy = 0;
353 SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));
354
355 /* necessary to trigger an event - ugly*/
356 SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));
357 SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy));
358 SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));
359
360 SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
361 }
362 }
363 SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin));
364 if (gwindata != NULL)
365 SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin));
366 windata->wm_grab = WM_POS_NONE;
367 return 1;
368 }
358 break; 369 break;
359 case DWET_MOTION: 370 case DWET_MOTION:
360 if (!wm_grab) 371 if (!windata->wm_grab)
361 return 0; 372 return 0;
362 if (evt->buttons & DIBM_LEFT) { 373 if (evt->buttons & DIBM_LEFT) {
363 int dx = evt->cx - wm_lastx; 374 int dx = evt->cx - windata->wm_lastx;
364 int dy = evt->cy - wm_lasty; 375 int dy = evt->cy - windata->wm_lasty;
365 int cw, ch; 376
366 377 if (windata->wm_grab & WM_POS_CAPTION) {
367 if (wm_grab & WM_POS_CAPTION) 378 if (!(wopts & DWOP_KEEP_POSITION))
368 SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy)); 379 SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy));
369 if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
370 if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
371 dx = 0;
372 else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
373 dy = 0;
374 SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch));
375 SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy));
376 } 380 }
377 wm_lastx = evt->cx; 381 if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
378 wm_lasty = evt->cy; 382 if (!(wopts & DWOP_KEEP_SIZE)) {
379 return 1; 383 int cw, ch;
384
385 /* Make sure all events are disabled for this operation ! */
386 SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));
387
388 if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
389 dx = 0;
390 else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
391 dy = 0;
392
393 SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));
394 SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
395
396 SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));
397 }
398 }
399 windata->wm_lastx = evt->cx;
400 windata->wm_lasty = evt->cy;
401 return 1;
380 } 402 }
381 SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
382 if (gwindata != NULL)
383 SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window));
384 wm_grab = WM_POS_NONE;
385 break; 403 break;
386 case DWET_KEYDOWN: 404 case DWET_KEYDOWN:
387 break; 405 break;
388 case DWET_KEYUP: 406 case DWET_KEYUP:
389 break; 407 break;
390 default: 408 default:
391 ; 409 ;
392 } 410 }
393 return 0; 411 return 0;
394 } 412 }
413