src/video/SDL_video.c
changeset 12070 1d65571b57dd
parent 12017 d8a165136edf
child 12143 673ec0369266
     1.1 --- a/src/video/SDL_video.c	Sun Jul 22 19:42:08 2018 -0400
     1.2 +++ b/src/video/SDL_video.c	Thu Aug 02 16:03:47 2018 -0400
     1.3 @@ -1331,9 +1331,43 @@
     1.4  #define CREATE_FLAGS \
     1.5      (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED)
     1.6  
     1.7 +static SDL_INLINE SDL_bool
     1.8 +IsAcceptingDragAndDrop(void)
     1.9 +{
    1.10 +    if ((SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) ||
    1.11 +        (SDL_GetEventState(SDL_DROPTEXT) == SDL_ENABLE)) {
    1.12 +        return SDL_TRUE;
    1.13 +    }
    1.14 +    return SDL_FALSE;
    1.15 +}
    1.16 +
    1.17 +/* prepare a newly-created window */
    1.18 +static SDL_INLINE void
    1.19 +PrepareDragAndDropSupport(SDL_Window *window)
    1.20 +{
    1.21 +    if (_this->AcceptDragAndDrop) {
    1.22 +        _this->AcceptDragAndDrop(window, IsAcceptingDragAndDrop());
    1.23 +    }
    1.24 +}
    1.25 +
    1.26 +/* toggle d'n'd for all existing windows. */
    1.27 +void
    1.28 +SDL_ToggleDragAndDropSupport(void)
    1.29 +{
    1.30 +    if (_this && _this->AcceptDragAndDrop) {
    1.31 +        const SDL_bool enable = IsAcceptingDragAndDrop();
    1.32 +        SDL_Window *window;
    1.33 +        for (window = _this->windows; window; window = window->next) {
    1.34 +            _this->AcceptDragAndDrop(window, enable);
    1.35 +        }
    1.36 +    }
    1.37 +}
    1.38 +
    1.39  static void
    1.40  SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
    1.41  {
    1.42 +    PrepareDragAndDropSupport(window);
    1.43 +
    1.44      if (flags & SDL_WINDOW_MAXIMIZED) {
    1.45          SDL_MaximizeWindow(window);
    1.46      }
    1.47 @@ -1552,6 +1586,9 @@
    1.48          SDL_DestroyWindow(window);
    1.49          return NULL;
    1.50      }
    1.51 +
    1.52 +    PrepareDragAndDropSupport(window);
    1.53 +
    1.54      return window;
    1.55  }
    1.56