src/video/SDL_video.c
changeset 7523 9e9ab1dc3811
parent 7508 1f64c6874619
child 7565 3d97fc52d294
     1.1 --- a/src/video/SDL_video.c	Sat Jul 27 00:49:34 2013 -0700
     1.2 +++ b/src/video/SDL_video.c	Sun Jul 14 18:17:28 2013 -0700
     1.3 @@ -1297,6 +1297,7 @@
     1.4  SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
     1.5  {
     1.6      char *title = window->title;
     1.7 +    SDL_Surface *icon = window->icon;
     1.8  
     1.9      if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
    1.10          return SDL_SetError("No OpenGL support in video driver");
    1.11 @@ -1335,6 +1336,7 @@
    1.12      }
    1.13  
    1.14      window->title = NULL;
    1.15 +    window->icon = NULL;
    1.16      window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
    1.17  
    1.18      if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
    1.19 @@ -1350,6 +1352,10 @@
    1.20          SDL_SetWindowTitle(window, title);
    1.21          SDL_free(title);
    1.22      }
    1.23 +    if (icon) {
    1.24 +        SDL_SetWindowIcon(window, icon);
    1.25 +        SDL_FreeSurface(icon);
    1.26 +    }
    1.27      SDL_FinishWindowCreation(window, flags);
    1.28  
    1.29      return 0;
    1.30 @@ -1426,8 +1432,18 @@
    1.31          return;
    1.32      }
    1.33  
    1.34 +    if (window->icon) {
    1.35 +        SDL_FreeSurface(window->icon);
    1.36 +    }
    1.37 +
    1.38 +    /* Convert the icon into ARGB8888 */
    1.39 +    window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0);
    1.40 +    if (!window->icon) {
    1.41 +        return;
    1.42 +    }
    1.43 +
    1.44      if (_this->SetWindowIcon) {
    1.45 -        _this->SetWindowIcon(_this, window, icon);
    1.46 +        _this->SetWindowIcon(_this, window, window->icon);
    1.47      }
    1.48  }
    1.49  
    1.50 @@ -2167,6 +2183,9 @@
    1.51      if (window->title) {
    1.52          SDL_free(window->title);
    1.53      }
    1.54 +    if (window->icon) {
    1.55 +        SDL_FreeSurface(window->icon);
    1.56 +    }
    1.57      if (window->gamma) {
    1.58          SDL_free(window->gamma);
    1.59      }