src/video/SDL_video.c
changeset 8931 44d8a2f4b431
parent 8927 be64f5daf64b
child 8935 9d2f0236322b
     1.1 --- a/src/video/SDL_video.c	Tue May 27 00:26:47 2014 -0400
     1.2 +++ b/src/video/SDL_video.c	Tue May 27 01:27:42 2014 -0400
     1.3 @@ -1410,6 +1410,11 @@
     1.4          SDL_SetWindowIcon(window, icon);
     1.5          SDL_FreeSurface(icon);
     1.6      }
     1.7 +
     1.8 +    if (window->num_drag_areas > 0) {
     1.9 +        _this->SetWindowDragAreas(window, window->drag_areas, window->num_drag_areas);
    1.10 +    }
    1.11 +
    1.12      SDL_FinishWindowCreation(window, flags);
    1.13  
    1.14      return 0;
    1.15 @@ -2305,6 +2310,8 @@
    1.16          _this->windows = window->next;
    1.17      }
    1.18  
    1.19 +    SDL_free(window->drag_areas);
    1.20 +
    1.21      SDL_free(window);
    1.22  }
    1.23  
    1.24 @@ -3380,4 +3387,34 @@
    1.25      return SDL_TRUE;
    1.26  }
    1.27  
    1.28 +int
    1.29 +SDL_SetWindowDragAreas(SDL_Window * window, const SDL_Rect *_areas, int num_areas)
    1.30 +{
    1.31 +    SDL_Rect *areas = NULL;
    1.32 +
    1.33 +    CHECK_WINDOW_MAGIC(window, -1);
    1.34 +
    1.35 +    if (!_this->SetWindowDragAreas) {
    1.36 +        return SDL_Unsupported();
    1.37 +    }
    1.38 +
    1.39 +    if (num_areas > 0) {
    1.40 +        const size_t len = sizeof (SDL_Rect) * num_areas;
    1.41 +        areas = (SDL_Rect *) SDL_malloc(len);
    1.42 +        if (!areas) {
    1.43 +            return SDL_OutOfMemory();
    1.44 +        }
    1.45 +        SDL_memcpy(areas, _areas, len);
    1.46 +    }
    1.47 +
    1.48 +    if (_this->SetWindowDragAreas(window, areas, num_areas) == -1) {
    1.49 +        SDL_free(areas);
    1.50 +        return -1;
    1.51 +    }
    1.52 +
    1.53 +    SDL_free(window->drag_areas);
    1.54 +    window->drag_areas = areas;
    1.55 +    window->num_drag_areas = num_areas;
    1.56 +}
    1.57 +
    1.58  /* vi: set ts=4 sw=4 expandtab: */