src/video/directfb/SDL_DirectFB_window.c
changeset 5199 164f20ba08eb
parent 4636 b196d2758026
child 5246 58265e606e4e
     1.1 --- a/src/video/directfb/SDL_DirectFB_window.c	Sat Feb 05 16:02:30 2011 -0800
     1.2 +++ b/src/video/directfb/SDL_DirectFB_window.c	Sat Feb 05 16:07:10 2011 -0800
     1.3 @@ -18,41 +18,49 @@
     1.4  
     1.5      Sam Lantinga
     1.6      slouken@libsdl.org
     1.7 +
     1.8 +    SDL1.3 DirectFB driver by couriersud@arcor.de
     1.9 +	
    1.10  */
    1.11 -#include "SDL_config.h"
    1.12 -
    1.13 -#include "SDL_syswm.h"
    1.14 -#include "../SDL_sysvideo.h"
    1.15 -#include "../../events/SDL_keyboard_c.h"
    1.16 -#include "../../video/SDL_pixels_c.h"
    1.17  
    1.18  #include "SDL_DirectFB_video.h"
    1.19 +#include "SDL_DirectFB_modes.h"
    1.20 +#include "SDL_DirectFB_window.h"
    1.21 +#include "SDL_DirectFB_shape.h"
    1.22 +
    1.23  #if SDL_DIRECTFB_OPENGL
    1.24  #include "SDL_DirectFB_opengl.h"
    1.25  #endif
    1.26  
    1.27 -static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
    1.28 +#include "SDL_syswm.h"
    1.29 +
    1.30 +#include "../SDL_pixels_c.h"
    1.31  
    1.32  int
    1.33  DirectFB_CreateWindow(_THIS, SDL_Window * window)
    1.34  {
    1.35      SDL_DFB_DEVICEDATA(_this);
    1.36 -    SDL_DFB_DISPLAYDATA(_this, window);
    1.37 +    SDL_DFB_DISPLAYDATA(window);
    1.38      DFB_WindowData *windata = NULL;
    1.39      DFBWindowOptions wopts;
    1.40      DFBWindowDescription desc;
    1.41      int x, y;
    1.42 +    int bshaped = 0;
    1.43  
    1.44 -    SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
    1.45 +    SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
    1.46      windata = (DFB_WindowData *) window->driverdata;
    1.47  
    1.48      windata->is_managed = devdata->has_own_wm;
    1.49 -
    1.50 +#if 1
    1.51      SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb,
    1.52                                                         DFSCL_NORMAL));
    1.53      SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
    1.54                                                            DLSCL_ADMINISTRATIVE));
    1.55 -
    1.56 +#endif
    1.57 +	/* FIXME ... ughh, ugly */
    1.58 +	if (window->x == -1000 && window->y == -1000)
    1.59 +		bshaped = 1;
    1.60 +	
    1.61      /* Fill the window description. */
    1.62      if (window->x == SDL_WINDOWPOS_CENTERED) {
    1.63          x = (dispdata->cw - window->w) / 2;
    1.64 @@ -61,6 +69,7 @@
    1.65      } else {
    1.66          x = window->x;
    1.67      }
    1.68 +    
    1.69      if (window->y == SDL_WINDOWPOS_CENTERED) {
    1.70          y = (dispdata->ch - window->h) / 2;
    1.71      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    1.72 @@ -68,6 +77,7 @@
    1.73      } else {
    1.74          y = window->y;
    1.75      }
    1.76 +    
    1.77      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.78          x = 0;
    1.79          y = 0;
    1.80 @@ -76,78 +86,103 @@
    1.81      DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
    1.82  
    1.83      /* Create Window */
    1.84 +	desc.caps = 0;
    1.85      desc.flags =
    1.86 -        DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_POSX
    1.87 -        | DWDESC_POSY | DWDESC_SURFACE_CAPS;
    1.88 +        DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS;
    1.89 +
    1.90 +    if (bshaped) {
    1.91 +    	desc.flags |= DWDESC_CAPS;
    1.92 +    	desc.caps |= DWCAPS_ALPHACHANNEL;
    1.93 +    }
    1.94 +    else
    1.95 +    {
    1.96 +    	desc.flags |= DWDESC_PIXELFORMAT;
    1.97 +    }
    1.98 +
    1.99 +    if (!(window->flags & SDL_WINDOW_BORDERLESS))
   1.100 +		desc.caps |= DWCAPS_NODECORATION;
   1.101 +
   1.102      desc.posx = x;
   1.103      desc.posy = y;
   1.104      desc.width = windata->size.w;
   1.105      desc.height = windata->size.h;
   1.106      desc.pixelformat = dispdata->pixelformat;
   1.107      desc.surface_caps = DSCAPS_PREMULTIPLIED;
   1.108 -
   1.109 +    
   1.110      /* Create the window. */
   1.111      SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
   1.112 -                                                   &windata->window));
   1.113 +                                                   &windata->dfbwin));
   1.114  
   1.115      /* Set Options */
   1.116 -    SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts));
   1.117 +    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
   1.118  
   1.119 -    if (window->flags & SDL_WINDOW_RESIZABLE)
   1.120 -        wopts |= DWOP_SCALE;
   1.121 -    else
   1.122 +    /* explicit rescaling of surface */
   1.123 +    wopts |= DWOP_SCALE;
   1.124 +    if (window->flags & SDL_WINDOW_RESIZABLE) {
   1.125 +        wopts &= ~DWOP_KEEP_SIZE;
   1.126 +    }
   1.127 +    else {
   1.128          wopts |= DWOP_KEEP_SIZE;
   1.129 +    }
   1.130  
   1.131      if (window->flags & SDL_WINDOW_FULLSCREEN) {
   1.132          wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
   1.133 -        SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER));
   1.134 +        SDL_DFB_CHECK(windata->dfbwin->SetStackingClass(windata->dfbwin, DWSC_UPPER));
   1.135      }
   1.136 -    SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts));
   1.137 +    
   1.138 +    if (bshaped) {
   1.139 +        wopts |= DWOP_SHAPED | DWOP_ALPHACHANNEL;
   1.140 +        wopts &= ~DWOP_OPAQUE_REGION;
   1.141 +    }
   1.142 +
   1.143 +    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
   1.144  
   1.145      /* See what we got */
   1.146 -    SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
   1.147 +    SDL_DFB_CHECK(DirectFB_WM_GetClientSize
   1.148                       (_this, window, &window->w, &window->h));
   1.149  
   1.150      /* Get the window's surface. */
   1.151 -    SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window,
   1.152 +    SDL_DFB_CHECKERR(windata->dfbwin->GetSurface(windata->dfbwin,
   1.153                                                   &windata->window_surface));
   1.154 +
   1.155      /* And get a subsurface for rendering */
   1.156      SDL_DFB_CHECKERR(windata->window_surface->
   1.157                       GetSubSurface(windata->window_surface, &windata->client,
   1.158                                     &windata->surface));
   1.159  
   1.160 -    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF));
   1.161 +    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0xFF));
   1.162  
   1.163      /* Create Eventbuffer */
   1.164 -    SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
   1.165 +
   1.166 +    SDL_DFB_CHECKERR(windata->dfbwin->CreateEventBuffer(windata->dfbwin,
   1.167                                                          &windata->
   1.168                                                          eventbuffer));
   1.169 -    SDL_DFB_CHECKERR(windata->window->
   1.170 -                     EnableEvents(windata->window, DWET_ALL));
   1.171 +    SDL_DFB_CHECKERR(windata->dfbwin->
   1.172 +                     EnableEvents(windata->dfbwin, DWET_ALL));
   1.173  
   1.174      /* Create a font */
   1.175      /* FIXME: once during Video_Init */
   1.176      windata->font = NULL;
   1.177  
   1.178      /* Make it the top most window. */
   1.179 -    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
   1.180 +    SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
   1.181  
   1.182      /* remember parent */
   1.183 -    windata->sdl_window = window;
   1.184 +    //windata->sdlwin = window;
   1.185  
   1.186      /* Add to list ... */
   1.187  
   1.188      windata->next = devdata->firstwin;
   1.189      windata->opacity = 0xFF;
   1.190 -    devdata->firstwin = windata;
   1.191 +    devdata->firstwin = window;
   1.192  
   1.193      /* Draw Frame */
   1.194      DirectFB_WM_RedrawLayout(_this, window);
   1.195  
   1.196      return 0;
   1.197    error:
   1.198 -    SDL_DFB_RELEASE(windata->window);
   1.199 -    SDL_DFB_RELEASE(windata->surface);
   1.200 +	SDL_DFB_RELEASE(windata->surface);
   1.201 +    SDL_DFB_RELEASE(windata->dfbwin);
   1.202      return -1;
   1.203  }
   1.204  
   1.205 @@ -226,61 +261,69 @@
   1.206  DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
   1.207  {
   1.208      SDL_DFB_WINDOWDATA(window);
   1.209 +    SDL_DFB_DISPLAYDATA(window);
   1.210      int x, y;
   1.211  
   1.212 -    if (window->y == SDL_WINDOWPOS_UNDEFINED)
   1.213 +    if (window->x == SDL_WINDOWPOS_CENTERED) {
   1.214 +        x = (dispdata->cw - window->w) / 2;
   1.215 +    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
   1.216 +        x = 0;
   1.217 +    } else {
   1.218 +        x = window->x;
   1.219 +    }
   1.220 +    
   1.221 +    if (window->y == SDL_WINDOWPOS_CENTERED) {
   1.222 +        y = (dispdata->ch - window->h) / 2;
   1.223 +    } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
   1.224          y = 0;
   1.225 -    else
   1.226 +    } else {
   1.227          y = window->y;
   1.228 -
   1.229 -    if (window->x == SDL_WINDOWPOS_UNDEFINED)
   1.230 -        x = 0;
   1.231 -    else
   1.232 -        x = window->x;
   1.233 +    }
   1.234  
   1.235      if (window->flags & SDL_WINDOW_FULLSCREEN) {
   1.236          x = 0;
   1.237          y = 0;
   1.238      }
   1.239      DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
   1.240 -    SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y));
   1.241 +    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, x, y));
   1.242  }
   1.243  
   1.244  void
   1.245  DirectFB_SetWindowSize(_THIS, SDL_Window * window)
   1.246  {
   1.247 -    //SDL_DFB_DEVICEDATA(_this);
   1.248      SDL_DFB_WINDOWDATA(window);
   1.249  
   1.250 +    if(SDL_IsShapedWindow(window))
   1.251 +        DirectFB_ResizeWindowShape(window);
   1.252 +
   1.253      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
   1.254          int cw;
   1.255          int ch;
   1.256  
   1.257          /* Make sure all events are disabled for this operation ! */
   1.258 -        SDL_DFB_CHECKERR(windata->window->DisableEvents(windata->window,
   1.259 +        SDL_DFB_CHECKERR(windata->dfbwin->DisableEvents(windata->dfbwin,
   1.260                                                          DWET_ALL));
   1.261 -
   1.262          SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch));
   1.263  
   1.264          if (cw != window->w || ch != window->h) {
   1.265  
   1.266  		    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
   1.267 -            SDL_DFB_CHECKERR(windata->window->Resize(windata->window,
   1.268 +            SDL_DFB_CHECKERR(windata->dfbwin->Resize(windata->dfbwin,
   1.269                                                       windata->size.w,
   1.270                                                       windata->size.h));
   1.271          }
   1.272  
   1.273          SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
   1.274                       (_this, window, &window->w, &window->h));
   1.275 -        DirectFB_AdjustWindowSurface(_this, window);
   1.276 +        DirectFB_AdjustWindowSurface(window);
   1.277  
   1.278 -        SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
   1.279 +        SDL_DFB_CHECKERR(windata->dfbwin->EnableEvents(windata->dfbwin,
   1.280                                                         DWET_ALL));
   1.281  
   1.282      }
   1.283      return;
   1.284    error:
   1.285 -    SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL));
   1.286 +    SDL_DFB_CHECK(windata->dfbwin->EnableEvents(windata->dfbwin, DWET_ALL));
   1.287      return;
   1.288  }
   1.289  
   1.290 @@ -289,7 +332,7 @@
   1.291  {
   1.292      SDL_DFB_WINDOWDATA(window);
   1.293  
   1.294 -    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity));
   1.295 +    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, windata->opacity));
   1.296  
   1.297  }
   1.298  
   1.299 @@ -298,8 +341,8 @@
   1.300  {
   1.301      SDL_DFB_WINDOWDATA(window);
   1.302  
   1.303 -    SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity));
   1.304 -    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0));
   1.305 +    SDL_DFB_CHECK(windata->dfbwin->GetOpacity(windata->dfbwin, &windata->opacity));
   1.306 +    SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0));
   1.307  }
   1.308  
   1.309  void
   1.310 @@ -307,19 +350,32 @@
   1.311  {
   1.312      SDL_DFB_WINDOWDATA(window);
   1.313  
   1.314 -    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
   1.315 -    SDL_DFB_CHECK(windata->window->RequestFocus(windata->window));
   1.316 +    SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
   1.317 +    SDL_DFB_CHECK(windata->dfbwin->RequestFocus(windata->dfbwin));
   1.318  }
   1.319  
   1.320  void
   1.321  DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
   1.322  {
   1.323      SDL_DFB_WINDOWDATA(window);
   1.324 +    SDL_VideoDisplay *display = window->display;
   1.325 +    DFBWindowOptions wopts;
   1.326  
   1.327 -    if (windata->is_managed) {
   1.328 -        DirectFB_WM_MaximizeWindow(_this, window);
   1.329 -    } else
   1.330 -        SDL_Unsupported();
   1.331 +    SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin,
   1.332 +                                 &windata->restore.x, &windata->restore.y));
   1.333 +    SDL_DFB_CHECK(windata->dfbwin->GetSize(windata->dfbwin, &windata->restore.w,
   1.334 +                             &windata->restore.h));
   1.335 +
   1.336 +    DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
   1.337 +
   1.338 +    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, 0, 0));
   1.339 +    SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin,
   1.340 +                            display->current_mode.w, display->current_mode.h));
   1.341 +
   1.342 +    /* Set Options */
   1.343 +    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
   1.344 +    wopts |= DWOP_KEEP_SIZE | DWOP_KEEP_POSITION;
   1.345 +    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
   1.346  }
   1.347  
   1.348  void
   1.349 @@ -334,11 +390,29 @@
   1.350  DirectFB_RestoreWindow(_THIS, SDL_Window * window)
   1.351  {
   1.352      SDL_DFB_WINDOWDATA(window);
   1.353 +    DFBWindowOptions wopts;
   1.354  
   1.355 -    if (windata->is_managed) {
   1.356 -        DirectFB_WM_RestoreWindow(_this, window);
   1.357 -    } else
   1.358 -        SDL_Unsupported();
   1.359 +    /* Set Options */
   1.360 +    SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
   1.361 +    wopts &= ~(DWOP_KEEP_SIZE | DWOP_KEEP_POSITION);
   1.362 +    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
   1.363 +
   1.364 +    /* Window layout */
   1.365 +    DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
   1.366 +    	windata->restore.w, windata->restore.h);
   1.367 +    SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, windata->restore.w,
   1.368 +                            windata->restore.h));
   1.369 +    SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, windata->restore.x,
   1.370 +                            windata->restore.y));
   1.371 +
   1.372 +    if (!(window->flags & SDL_WINDOW_RESIZABLE))
   1.373 +        wopts |= DWOP_KEEP_SIZE;
   1.374 +
   1.375 +    if (window->flags & SDL_WINDOW_FULLSCREEN)
   1.376 +        wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_SIZE;
   1.377 +    SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
   1.378 +
   1.379 +
   1.380  }
   1.381  
   1.382  void
   1.383 @@ -351,15 +425,15 @@
   1.384      if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
   1.385          if (gwindata != NULL)
   1.386          {
   1.387 -		    SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
   1.388 -		    SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window));
   1.389 +		    SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
   1.390 +		    SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin));
   1.391          }
   1.392 -        SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
   1.393 -        SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window));
   1.394 +        SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin));
   1.395 +        SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin));
   1.396          devdata->grabbed_window = window;
   1.397      } else {
   1.398 -        SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
   1.399 -        SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
   1.400 +        SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
   1.401 +        SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
   1.402          devdata->grabbed_window = NULL;
   1.403      }
   1.404  }
   1.405 @@ -372,13 +446,22 @@
   1.406      DFB_WindowData *p;
   1.407  
   1.408      /* Some cleanups */
   1.409 -    SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
   1.410 -    SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
   1.411 +    SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
   1.412 +    SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
   1.413  
   1.414  #if SDL_DIRECTFB_OPENGL
   1.415  	DirectFB_GL_DestroyWindowContexts(_this, window);
   1.416  #endif
   1.417  
   1.418 +	if (window->shaper)
   1.419 +	{
   1.420 +	    SDL_ShapeData *data = window->shaper->driverdata;
   1.421 +	    SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface));
   1.422 +    	SDL_DFB_RELEASE(data->surface);
   1.423 +    	SDL_DFB_FREE(data);
   1.424 +    	SDL_DFB_FREE(window->shaper);
   1.425 +	}
   1.426 +
   1.427      SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL));
   1.428      SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface));
   1.429      SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface));
   1.430 @@ -388,13 +471,14 @@
   1.431      SDL_DFB_RELEASE(windata->surface);
   1.432      SDL_DFB_RELEASE(windata->window_surface);
   1.433  
   1.434 -    SDL_DFB_RELEASE(windata->window);
   1.435 +    SDL_DFB_RELEASE(windata->dfbwin);
   1.436  
   1.437      /* Remove from list ... */
   1.438  
   1.439 -    p = devdata->firstwin;
   1.440 -    while (p && p->next != windata)
   1.441 -        p = p->next;
   1.442 +    p = devdata->firstwin->driverdata;
   1.443 +
   1.444 +    while (p && p->next != window)
   1.445 +        p = (p->next ? p->next->driverdata : NULL);
   1.446      if (p)
   1.447          p->next = windata->next;
   1.448      else
   1.449 @@ -407,12 +491,25 @@
   1.450  DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
   1.451                           struct SDL_SysWMinfo * info)
   1.452  {
   1.453 -    SDL_Unsupported();
   1.454 -    return SDL_FALSE;
   1.455 +    SDL_DFB_DEVICEDATA(_this);
   1.456 +    SDL_DFB_WINDOWDATA(window);
   1.457 +
   1.458 +    if (info->version.major == SDL_MAJOR_VERSION &&
   1.459 +        info->version.minor == SDL_MINOR_VERSION) {
   1.460 +        info->subsystem = SDL_SYSWM_DIRECTFB;
   1.461 +        info->info.dfb.dfb = devdata->dfb;
   1.462 +        info->info.dfb.window = windata->dfbwin;
   1.463 +        info->info.dfb.surface = windata->surface;
   1.464 +        return SDL_TRUE;
   1.465 +    } else {
   1.466 +        SDL_SetError("Application not compiled with SDL %d.%d\n",
   1.467 +                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   1.468 +        return SDL_FALSE;
   1.469 +    }
   1.470  }
   1.471  
   1.472 -static void
   1.473 -DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window)
   1.474 +void
   1.475 +DirectFB_AdjustWindowSurface(SDL_Window * window)
   1.476  {
   1.477      SDL_DFB_WINDOWDATA(window);
   1.478      int adjust = windata->wm_needs_redraw;
   1.479 @@ -429,11 +526,11 @@
   1.480  
   1.481      if (adjust) {
   1.482  #if SDL_DIRECTFB_OPENGL
   1.483 -		DirectFB_GL_FreeWindowContexts(_this, window);
   1.484 +		DirectFB_GL_FreeWindowContexts(window->display->device, window);
   1.485  #endif
   1.486  
   1.487 -#if DFB_VERSION_ATLEAST(1,2,1)
   1.488 -        SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
   1.489 +#if (DFB_VERSION_ATLEAST(1,2,1))
   1.490 +        SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
   1.491                                                          windata->size.w,
   1.492                                                          windata->size.h));
   1.493          SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
   1.494 @@ -443,22 +540,22 @@
   1.495  #else
   1.496          DFBWindowOptions opts;
   1.497  
   1.498 -        SDL_DFB_CHECKERR(windata->window->GetOptions(windata->window, &opts));
   1.499 +        SDL_DFB_CHECKERR(windata->dfbwin->GetOptions(windata->dfbwin, &opts));
   1.500          /* recreate subsurface */
   1.501          SDL_DFB_RELEASE(windata->surface);
   1.502  
   1.503          if (opts & DWOP_SCALE)
   1.504 -            SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
   1.505 +            SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
   1.506                                                              windata->size.w,
   1.507                                                              windata->size.h));
   1.508          SDL_DFB_CHECKERR(windata->window_surface->
   1.509                           GetSubSurface(windata->window_surface,
   1.510                                         &windata->client, &windata->surface));
   1.511  #endif
   1.512 -        DirectFB_WM_RedrawLayout(_this, window);
   1.513 +        DirectFB_WM_RedrawLayout(window->display->device, window);
   1.514          
   1.515  #if SDL_DIRECTFB_OPENGL
   1.516 -		DirectFB_GL_ReAllocWindowContexts(_this, window);
   1.517 +		DirectFB_GL_ReAllocWindowContexts(window->display->device, window);
   1.518  #endif
   1.519     }
   1.520    error: