Added SDL_DROPBEGIN and SDL_DROPCOMPLETE events, plus window IDs for drops.

This allows an app to know when a set of drops are coming in a grouping of
some sort (for example, a user selected multiple files and dropped them all
on the window with a single drag), and when that set is complete.

This also adds a window ID to the drop events, so the app can determine to
which window a given drop was delivered. For application-level drops (for
example, you launched an app by dropping a file on its icon), the window ID
will be zero.
This commit is contained in:
Ryan C. Gordon
2016-01-05 01:42:00 -05:00
parent f2defe5e11
commit 8e855f2fbc
9 changed files with 79 additions and 20 deletions

View File

@@ -77,10 +77,14 @@ main(int argc, char *argv[])
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
if (event.type == SDL_DROPBEGIN) {
SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID);
} else if (event.type == SDL_DROPCOMPLETE) {
SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID);
} else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text";
char *dropped_filedir = event.drop.file;
SDL_Log("%s dropped on window: %s", typestr, dropped_filedir);
SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir);
SDL_free(dropped_filedir);
}
}