2 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
16 #include "SDL_test_common.h"
18 static SDLTest_CommonState *state;
20 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
24 SDLTest_CommonQuit(state);
28 main(int argc, char *argv[])
33 /* Enable standard application logging */
34 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
36 /* Initialize test framework */
37 state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
42 for (i = 1; i < argc;) {
45 consumed = SDLTest_CommonArg(state, i);
46 /* needed voodoo to allow app to launch via OS X Finder */
47 if (SDL_strncmp(argv[i], "-psn", 4)==0) {
54 SDLTest_CommonLogUsage(state, argv[0], NULL);
59 if (!SDLTest_CommonInit(state)) {
63 for (i = 0; i < state->num_windows; ++i) {
64 SDL_Renderer *renderer = state->renderers[i];
65 SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
66 SDL_RenderClear(renderer);
67 SDL_RenderPresent(renderer);
70 SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
72 /* Main render loop */
75 /* Check for events */
76 while (SDL_PollEvent(&event)) {
77 if (event.type == SDL_DROPBEGIN) {
78 SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID);
79 } else if (event.type == SDL_DROPCOMPLETE) {
80 SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID);
81 } else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
82 const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text";
83 char *dropped_filedir = event.drop.file;
84 SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir);
85 /* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */
86 /*SDL_free(dropped_filedir);*/
89 SDLTest_CommonEvent(state, &event, &done);
94 /* keep the compiler happy ... */
98 /* vi: set ts=4 sw=4 expandtab: */