mirror of
https://github.com/love2d/megasource.git
synced 2026-08-21 13:10:24 +02:00
Updated SDL to the latest hg revision.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -26,21 +26,73 @@
|
||||
#include "SDL_events_c.h"
|
||||
#include "SDL_dropevents_c.h"
|
||||
|
||||
#include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */
|
||||
|
||||
int
|
||||
SDL_SendDropFile(const char *file)
|
||||
|
||||
static int
|
||||
SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data)
|
||||
{
|
||||
int posted;
|
||||
static SDL_bool app_is_dropping = SDL_FALSE;
|
||||
int posted = 0;
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
if (SDL_GetEventState(evtype) == SDL_ENABLE) {
|
||||
const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping;
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup(file);
|
||||
|
||||
if (need_begin) {
|
||||
SDL_zero(event);
|
||||
event.type = SDL_DROPBEGIN;
|
||||
|
||||
if (window) {
|
||||
event.drop.windowID = window->id;
|
||||
}
|
||||
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
if (!posted) {
|
||||
return 0;
|
||||
}
|
||||
if (window) {
|
||||
window->is_dropping = SDL_TRUE;
|
||||
} else {
|
||||
app_is_dropping = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_zero(event);
|
||||
event.type = evtype;
|
||||
event.drop.file = data ? SDL_strdup(data) : NULL;
|
||||
event.drop.windowID = window ? window->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
|
||||
if (posted && (evtype == SDL_DROPCOMPLETE)) {
|
||||
if (window) {
|
||||
window->is_dropping = SDL_FALSE;
|
||||
} else {
|
||||
app_is_dropping = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (posted);
|
||||
return posted;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendDropFile(SDL_Window *window, const char *file)
|
||||
{
|
||||
return SDL_SendDrop(window, SDL_DROPFILE, file);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendDropText(SDL_Window *window, const char *text)
|
||||
{
|
||||
return SDL_SendDrop(window, SDL_DROPTEXT, text);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendDropComplete(SDL_Window *window)
|
||||
{
|
||||
return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user