src/video/directfb/SDL_DirectFB_window.c
author Sam Lantinga
Mon, 16 Aug 2010 09:04:55 -0700
changeset 4636 b196d2758026
parent 4568 25b9cd8bdc30
child 5199 164f20ba08eb
permissions -rw-r--r--
Couriersud to Sam

Hi Sam,

20100815_1.diff contains updates for the directfb driver:

- more documentation, mainly on software OpenGL in README.directfb
- Revised error handling leading to leaner code
- Improved/fixed OpenGL handling of multiple contexts.
- Made the built-in simple window manager handle OpenGL windows.
- Rewrote pixelformat mapping - this was quite ugly before.

Well, all software GL, but working :-)
slouken@2737
     1
/*
slouken@2737
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@2737
     4
slouken@2737
     5
    This library is free software; you can redistribute it and/or
slouken@2737
     6
    modify it under the terms of the GNU Lesser General Public
slouken@2737
     7
    License as published by the Free Software Foundation; either
slouken@2737
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@2737
     9
slouken@2737
    10
    This library is distributed in the hope that it will be useful,
slouken@2737
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2737
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2737
    13
    Lesser General Public License for more details.
slouken@2737
    14
slouken@2737
    15
    You should have received a copy of the GNU Lesser General Public
slouken@2737
    16
    License along with this library; if not, write to the Free Software
slouken@2737
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2737
    18
slouken@2737
    19
    Sam Lantinga
slouken@2737
    20
    slouken@libsdl.org
slouken@2737
    21
*/
slouken@2737
    22
#include "SDL_config.h"
slouken@2737
    23
slouken@2737
    24
#include "SDL_syswm.h"
slouken@2737
    25
#include "../SDL_sysvideo.h"
slouken@2737
    26
#include "../../events/SDL_keyboard_c.h"
slouken@4636
    27
#include "../../video/SDL_pixels_c.h"
slouken@2737
    28
slouken@2737
    29
#include "SDL_DirectFB_video.h"
slouken@4636
    30
#if SDL_DIRECTFB_OPENGL
slouken@4636
    31
#include "SDL_DirectFB_opengl.h"
slouken@4636
    32
#endif
slouken@2737
    33
slouken@4636
    34
static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
couriersud@3023
    35
slouken@2737
    36
int
slouken@2737
    37
DirectFB_CreateWindow(_THIS, SDL_Window * window)
slouken@2737
    38
{
slouken@2737
    39
    SDL_DFB_DEVICEDATA(_this);
slouken@2737
    40
    SDL_DFB_DISPLAYDATA(_this, window);
couriersud@3023
    41
    DFB_WindowData *windata = NULL;
slouken@2737
    42
    DFBWindowOptions wopts;
slouken@2737
    43
    DFBWindowDescription desc;
slouken@4636
    44
    int x, y;
slouken@2737
    45
slouken@2737
    46
    SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
slouken@2737
    47
    windata = (DFB_WindowData *) window->driverdata;
slouken@2737
    48
couriersud@3023
    49
    windata->is_managed = devdata->has_own_wm;
couriersud@3023
    50
couriersud@3023
    51
    SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb,
couriersud@3023
    52
                                                       DFSCL_NORMAL));
couriersud@3023
    53
    SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
couriersud@3023
    54
                                                          DLSCL_ADMINISTRATIVE));
slouken@2737
    55
slouken@2737
    56
    /* Fill the window description. */
slouken@2737
    57
    if (window->x == SDL_WINDOWPOS_CENTERED) {
slouken@2737
    58
        x = (dispdata->cw - window->w) / 2;
slouken@2737
    59
    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
slouken@2737
    60
        x = 0;
slouken@2737
    61
    } else {
slouken@2737
    62
        x = window->x;
slouken@2737
    63
    }
slouken@2737
    64
    if (window->y == SDL_WINDOWPOS_CENTERED) {
slouken@2737
    65
        y = (dispdata->ch - window->h) / 2;
slouken@2737
    66
    } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
slouken@2737
    67
        y = 0;
slouken@2737
    68
    } else {
slouken@2737
    69
        y = window->y;
slouken@2737
    70
    }
slouken@2737
    71
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@2737
    72
        x = 0;
slouken@2737
    73
        y = 0;
slouken@2737
    74
    }
slouken@2737
    75
slouken@4636
    76
    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
slouken@2737
    77
couriersud@3023
    78
    /* Create Window */
couriersud@3023
    79
    desc.flags =
couriersud@3023
    80
        DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_POSX
couriersud@3023
    81
        | DWDESC_POSY | DWDESC_SURFACE_CAPS;
slouken@2737
    82
    desc.posx = x;
slouken@2737
    83
    desc.posy = y;
couriersud@3023
    84
    desc.width = windata->size.w;
couriersud@3023
    85
    desc.height = windata->size.h;
slouken@2737
    86
    desc.pixelformat = dispdata->pixelformat;
slouken@2737
    87
    desc.surface_caps = DSCAPS_PREMULTIPLIED;
slouken@2737
    88
slouken@2737
    89
    /* Create the window. */
couriersud@3023
    90
    SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
couriersud@3023
    91
                                                   &windata->window));
slouken@2737
    92
couriersud@3023
    93
    /* Set Options */
slouken@4636
    94
    SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts));
slouken@2737
    95
slouken@2737
    96
    if (window->flags & SDL_WINDOW_RESIZABLE)
slouken@2737
    97
        wopts |= DWOP_SCALE;
slouken@2737
    98
    else
slouken@2737
    99
        wopts |= DWOP_KEEP_SIZE;
slouken@2737
   100
couriersud@3023
   101
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@2737
   102
        wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
slouken@4636
   103
        SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER));
couriersud@3023
   104
    }
slouken@4636
   105
    SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts));
slouken@2737
   106
couriersud@3023
   107
    /* See what we got */
slouken@3040
   108
    SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
slouken@3040
   109
                     (_this, window, &window->w, &window->h));
couriersud@3023
   110
slouken@2737
   111
    /* Get the window's surface. */
couriersud@3023
   112
    SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window,
couriersud@3023
   113
                                                 &windata->window_surface));
couriersud@3023
   114
    /* And get a subsurface for rendering */
couriersud@3023
   115
    SDL_DFB_CHECKERR(windata->window_surface->
couriersud@3023
   116
                     GetSubSurface(windata->window_surface, &windata->client,
couriersud@3023
   117
                                   &windata->surface));
couriersud@3023
   118
slouken@4636
   119
    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF));
couriersud@3023
   120
couriersud@3023
   121
    /* Create Eventbuffer */
couriersud@3023
   122
    SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
slouken@3040
   123
                                                        &windata->
slouken@3040
   124
                                                        eventbuffer));
slouken@3040
   125
    SDL_DFB_CHECKERR(windata->window->
slouken@3040
   126
                     EnableEvents(windata->window, DWET_ALL));
slouken@2737
   127
couriersud@3023
   128
    /* Create a font */
couriersud@3023
   129
    /* FIXME: once during Video_Init */
slouken@4636
   130
    windata->font = NULL;
couriersud@3023
   131
slouken@2737
   132
    /* Make it the top most window. */
slouken@4636
   133
    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
slouken@2737
   134
slouken@2737
   135
    /* remember parent */
slouken@4568
   136
    windata->sdl_window = window;
slouken@2737
   137
slouken@2737
   138
    /* Add to list ... */
slouken@2737
   139
slouken@2737
   140
    windata->next = devdata->firstwin;
slouken@2737
   141
    windata->opacity = 0xFF;
slouken@2737
   142
    devdata->firstwin = windata;
slouken@2737
   143
couriersud@3023
   144
    /* Draw Frame */
slouken@4636
   145
    DirectFB_WM_RedrawLayout(_this, window);
couriersud@3023
   146
slouken@2737
   147
    return 0;
slouken@2737
   148
  error:
slouken@2737
   149
    SDL_DFB_RELEASE(windata->window);
slouken@2737
   150
    SDL_DFB_RELEASE(windata->surface);
slouken@2737
   151
    return -1;
slouken@2737
   152
}
slouken@2737
   153
slouken@2737
   154
int
slouken@2737
   155
DirectFB_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
slouken@2737
   156
{
slouken@2737
   157
    SDL_Unsupported();
slouken@2737
   158
    return -1;
slouken@2737
   159
}
slouken@2737
   160
slouken@2737
   161
void
slouken@2737
   162
DirectFB_SetWindowTitle(_THIS, SDL_Window * window)
slouken@2737
   163
{
couriersud@3023
   164
    SDL_DFB_WINDOWDATA(window);
couriersud@3023
   165
couriersud@3023
   166
    if (windata->is_managed) {
couriersud@3023
   167
        windata->wm_needs_redraw = 1;
slouken@4636
   168
        DirectFB_WM_RedrawLayout(_this, window);
couriersud@3023
   169
    } else
couriersud@3023
   170
        SDL_Unsupported();
couriersud@3023
   171
}
couriersud@3023
   172
couriersud@3023
   173
void
couriersud@3023
   174
DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
couriersud@3023
   175
{
couriersud@3023
   176
    SDL_DFB_DEVICEDATA(_this);
couriersud@3023
   177
    SDL_DFB_WINDOWDATA(window);
couriersud@3023
   178
    SDL_Surface *surface = NULL;
couriersud@3023
   179
couriersud@3023
   180
    if (icon) {
couriersud@3023
   181
        SDL_PixelFormat format;
couriersud@3023
   182
        DFBSurfaceDescription dsc;
couriersud@3023
   183
        Uint32 *dest;
couriersud@3023
   184
        Uint32 *p;
couriersud@3023
   185
        int pitch, i;
couriersud@3023
   186
couriersud@3023
   187
        /* Convert the icon to ARGB for modern window managers */
couriersud@3023
   188
        SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
couriersud@3023
   189
                       0xFF000000);
couriersud@3023
   190
        surface = SDL_ConvertSurface(icon, &format, 0);
couriersud@3023
   191
        if (!surface) {
couriersud@3023
   192
            return;
couriersud@3023
   193
        }
couriersud@3023
   194
        dsc.flags =
couriersud@3023
   195
            DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
couriersud@3023
   196
        dsc.caps = DSCAPS_VIDEOONLY;
couriersud@3023
   197
        dsc.width = surface->w;
couriersud@3023
   198
        dsc.height = surface->h;
couriersud@3023
   199
        dsc.pixelformat = DSPF_ARGB;
couriersud@3023
   200
couriersud@3023
   201
        SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc,
couriersud@3023
   202
                                                     &windata->icon));
couriersud@3023
   203
couriersud@3023
   204
        SDL_DFB_CHECKERR(windata->icon->Lock(windata->icon, DSLF_WRITE,
couriersud@3023
   205
                                             (void *) &dest, &pitch));
couriersud@3023
   206
couriersud@3023
   207
        p = surface->pixels;
couriersud@3023
   208
        for (i = 0; i < surface->h; i++)
couriersud@3023
   209
            memcpy((char *) dest + i * pitch,
couriersud@3023
   210
                   (char *) p + i * surface->pitch, 4 * surface->w);
couriersud@3023
   211
slouken@4636
   212
        SDL_DFB_CHECK(windata->icon->Unlock(windata->icon));
couriersud@3023
   213
        SDL_FreeSurface(surface);
couriersud@3023
   214
    } else {
couriersud@3023
   215
        SDL_DFB_RELEASE(windata->icon);
couriersud@3023
   216
    }
couriersud@3023
   217
    return;
couriersud@3023
   218
  error:
couriersud@3023
   219
    if (surface)
couriersud@3023
   220
        SDL_FreeSurface(surface);
couriersud@3023
   221
    SDL_DFB_RELEASE(windata->icon);
couriersud@3023
   222
    return;
slouken@2737
   223
}
slouken@2737
   224
slouken@2737
   225
void
slouken@2737
   226
DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
slouken@2737
   227
{
slouken@2737
   228
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   229
    int x, y;
slouken@2737
   230
slouken@2737
   231
    if (window->y == SDL_WINDOWPOS_UNDEFINED)
slouken@2737
   232
        y = 0;
slouken@2737
   233
    else
slouken@2737
   234
        y = window->y;
slouken@2737
   235
slouken@2737
   236
    if (window->x == SDL_WINDOWPOS_UNDEFINED)
slouken@2737
   237
        x = 0;
slouken@2737
   238
    else
slouken@2737
   239
        x = window->x;
slouken@2737
   240
slouken@2737
   241
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@2737
   242
        x = 0;
slouken@2737
   243
        y = 0;
slouken@2737
   244
    }
slouken@4636
   245
    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
slouken@4636
   246
    SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y));
slouken@2737
   247
}
slouken@2737
   248
slouken@2737
   249
void
slouken@2737
   250
DirectFB_SetWindowSize(_THIS, SDL_Window * window)
slouken@2737
   251
{
slouken@4636
   252
    //SDL_DFB_DEVICEDATA(_this);
couriersud@3023
   253
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   254
slouken@2737
   255
    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
slouken@2737
   256
        int cw;
slouken@2737
   257
        int ch;
slouken@2737
   258
slouken@2737
   259
        /* Make sure all events are disabled for this operation ! */
couriersud@3023
   260
        SDL_DFB_CHECKERR(windata->window->DisableEvents(windata->window,
couriersud@3023
   261
                                                        DWET_ALL));
couriersud@3023
   262
couriersud@3023
   263
        SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch));
couriersud@3023
   264
couriersud@3023
   265
        if (cw != window->w || ch != window->h) {
slouken@2737
   266
slouken@4636
   267
		    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
couriersud@3023
   268
            SDL_DFB_CHECKERR(windata->window->Resize(windata->window,
couriersud@3023
   269
                                                     windata->size.w,
couriersud@3023
   270
                                                     windata->size.h));
couriersud@3023
   271
        }
slouken@2737
   272
slouken@4636
   273
        SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
slouken@4636
   274
                     (_this, window, &window->w, &window->h));
slouken@4636
   275
        DirectFB_AdjustWindowSurface(_this, window);
slouken@4636
   276
couriersud@3023
   277
        SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
couriersud@3023
   278
                                                       DWET_ALL));
couriersud@3023
   279
slouken@2737
   280
    }
slouken@2737
   281
    return;
slouken@2737
   282
  error:
slouken@4636
   283
    SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL));
slouken@2737
   284
    return;
slouken@2737
   285
}
slouken@2737
   286
slouken@2737
   287
void
slouken@2737
   288
DirectFB_ShowWindow(_THIS, SDL_Window * window)
slouken@2737
   289
{
slouken@2737
   290
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   291
slouken@4636
   292
    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity));
slouken@2737
   293
slouken@2737
   294
}
slouken@2737
   295
slouken@2737
   296
void
slouken@2737
   297
DirectFB_HideWindow(_THIS, SDL_Window * window)
slouken@2737
   298
{
slouken@2737
   299
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   300
slouken@4636
   301
    SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity));
slouken@4636
   302
    SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0));
slouken@2737
   303
}
slouken@2737
   304
slouken@2737
   305
void
slouken@2737
   306
DirectFB_RaiseWindow(_THIS, SDL_Window * window)
slouken@2737
   307
{
slouken@2737
   308
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   309
slouken@4636
   310
    SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window));
slouken@4636
   311
    SDL_DFB_CHECK(windata->window->RequestFocus(windata->window));
slouken@2737
   312
}
slouken@2737
   313
slouken@2737
   314
void
slouken@2737
   315
DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
slouken@2737
   316
{
couriersud@3023
   317
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   318
couriersud@3023
   319
    if (windata->is_managed) {
slouken@3040
   320
        DirectFB_WM_MaximizeWindow(_this, window);
couriersud@3023
   321
    } else
couriersud@3023
   322
        SDL_Unsupported();
slouken@2737
   323
}
slouken@2737
   324
slouken@2737
   325
void
slouken@2737
   326
DirectFB_MinimizeWindow(_THIS, SDL_Window * window)
slouken@2737
   327
{
slouken@2737
   328
    /* FIXME: Size to 32x32 ? */
slouken@2737
   329
slouken@2737
   330
    SDL_Unsupported();
slouken@2737
   331
}
slouken@2737
   332
slouken@2737
   333
void
slouken@2737
   334
DirectFB_RestoreWindow(_THIS, SDL_Window * window)
slouken@2737
   335
{
couriersud@3023
   336
    SDL_DFB_WINDOWDATA(window);
couriersud@3023
   337
couriersud@3023
   338
    if (windata->is_managed) {
slouken@3040
   339
        DirectFB_WM_RestoreWindow(_this, window);
couriersud@3023
   340
    } else
couriersud@3023
   341
        SDL_Unsupported();
slouken@2737
   342
}
slouken@2737
   343
slouken@2737
   344
void
slouken@2737
   345
DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
slouken@2737
   346
{
slouken@4636
   347
    SDL_DFB_DEVICEDATA(_this);
slouken@2737
   348
    SDL_DFB_WINDOWDATA(window);
slouken@4636
   349
    DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
slouken@2737
   350
couriersud@3023
   351
    if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
slouken@4636
   352
        if (gwindata != NULL)
slouken@4636
   353
        {
slouken@4636
   354
		    SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
slouken@4636
   355
		    SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window));
slouken@4636
   356
        }
slouken@4636
   357
        SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
slouken@4636
   358
        SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window));
slouken@4636
   359
        devdata->grabbed_window = window;
slouken@2737
   360
    } else {
slouken@4636
   361
        SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
slouken@4636
   362
        SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
slouken@4636
   363
        devdata->grabbed_window = NULL;
slouken@2737
   364
    }
slouken@2737
   365
}
slouken@2737
   366
slouken@2737
   367
void
slouken@2737
   368
DirectFB_DestroyWindow(_THIS, SDL_Window * window)
slouken@2737
   369
{
slouken@2737
   370
    SDL_DFB_DEVICEDATA(_this);
slouken@2737
   371
    SDL_DFB_WINDOWDATA(window);
slouken@2737
   372
    DFB_WindowData *p;
slouken@2737
   373
slouken@4636
   374
    /* Some cleanups */
slouken@4636
   375
    SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
slouken@4636
   376
    SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window));
slouken@2737
   377
slouken@4636
   378
#if SDL_DIRECTFB_OPENGL
slouken@4636
   379
	DirectFB_GL_DestroyWindowContexts(_this, window);
slouken@4636
   380
#endif
couriersud@3023
   381
slouken@4636
   382
    SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL));
slouken@4636
   383
    SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface));
slouken@4636
   384
    SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface));
slouken@4636
   385
  	SDL_DFB_RELEASE(windata->icon);
slouken@4636
   386
    SDL_DFB_RELEASE(windata->font);
slouken@2737
   387
    SDL_DFB_RELEASE(windata->eventbuffer);
slouken@2737
   388
    SDL_DFB_RELEASE(windata->surface);
couriersud@3023
   389
    SDL_DFB_RELEASE(windata->window_surface);
couriersud@3023
   390
slouken@2737
   391
    SDL_DFB_RELEASE(windata->window);
slouken@2737
   392
slouken@2737
   393
    /* Remove from list ... */
slouken@2737
   394
slouken@2737
   395
    p = devdata->firstwin;
slouken@2737
   396
    while (p && p->next != windata)
slouken@2737
   397
        p = p->next;
slouken@2737
   398
    if (p)
slouken@2737
   399
        p->next = windata->next;
slouken@2737
   400
    else
slouken@2737
   401
        devdata->firstwin = windata->next;
slouken@2737
   402
    SDL_free(windata);
slouken@2737
   403
    return;
slouken@2737
   404
}
slouken@2737
   405
slouken@2737
   406
SDL_bool
slouken@2737
   407
DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
slouken@2737
   408
                         struct SDL_SysWMinfo * info)
slouken@2737
   409
{
slouken@2737
   410
    SDL_Unsupported();
slouken@2737
   411
    return SDL_FALSE;
slouken@2737
   412
}
couriersud@3023
   413
slouken@4636
   414
static void
slouken@4636
   415
DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window)
couriersud@3023
   416
{
couriersud@3023
   417
    SDL_DFB_WINDOWDATA(window);
couriersud@3023
   418
    int adjust = windata->wm_needs_redraw;
couriersud@3023
   419
    int cw, ch;
couriersud@3023
   420
slouken@4636
   421
    DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
couriersud@3023
   422
couriersud@3023
   423
    SDL_DFB_CHECKERR(windata->
couriersud@3023
   424
                     window_surface->GetSize(windata->window_surface, &cw,
couriersud@3023
   425
                                             &ch));
couriersud@3023
   426
    if (cw != windata->size.w || ch != windata->size.h) {
couriersud@3023
   427
        adjust = 1;
couriersud@3023
   428
    }
couriersud@3023
   429
couriersud@3023
   430
    if (adjust) {
slouken@4636
   431
#if SDL_DIRECTFB_OPENGL
slouken@4636
   432
		DirectFB_GL_FreeWindowContexts(_this, window);
slouken@4636
   433
#endif
slouken@4636
   434
couriersud@3038
   435
#if DFB_VERSION_ATLEAST(1,2,1)
slouken@3040
   436
        SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
couriersud@3023
   437
                                                        windata->size.w,
couriersud@3023
   438
                                                        windata->size.h));
slouken@3040
   439
        SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
couriersud@3023
   440
                                                          windata->
couriersud@3023
   441
                                                          window_surface,
couriersud@3023
   442
                                                          &windata->client));
couriersud@3037
   443
#else
slouken@3040
   444
        DFBWindowOptions opts;
slouken@3040
   445
slouken@3040
   446
        SDL_DFB_CHECKERR(windata->window->GetOptions(windata->window, &opts));
slouken@3040
   447
        /* recreate subsurface */
slouken@3040
   448
        SDL_DFB_RELEASE(windata->surface);
couriersud@3039
   449
slouken@3040
   450
        if (opts & DWOP_SCALE)
slouken@3040
   451
            SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
slouken@3040
   452
                                                            windata->size.w,
slouken@3040
   453
                                                            windata->size.h));
slouken@3040
   454
        SDL_DFB_CHECKERR(windata->window_surface->
slouken@3040
   455
                         GetSubSurface(windata->window_surface,
slouken@3040
   456
                                       &windata->client, &windata->surface));
couriersud@3037
   457
#endif
slouken@4636
   458
        DirectFB_WM_RedrawLayout(_this, window);
slouken@4636
   459
        
slouken@4636
   460
#if SDL_DIRECTFB_OPENGL
slouken@4636
   461
		DirectFB_GL_ReAllocWindowContexts(_this, window);
slouken@4636
   462
#endif
slouken@4636
   463
   }
couriersud@3023
   464
  error:
couriersud@3023
   465
    return;
couriersud@3023
   466
}