src/events/SDL_dropevents.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 01 May 2015 01:12:48 -0400
changeset 9580 d37ef6990bf9
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
permissions -rw-r--r--
checkkeys: Readded the KEYUP event test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6091
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
6091
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
  arising from the use of this software.
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
     appreciated but is not required.
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    21
#include "../SDL_internal.h"
6091
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
/* Drag and drop event handling code for SDL */
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_events.h"
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL_events_c.h"
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_dropevents_c.h"
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
int
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
SDL_SendDropFile(const char *file)
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
{
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    int posted;
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    /* Post the event, if desired */
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    posted = 0;
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
        SDL_Event event;
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
        event.type = SDL_DROPFILE;
6103
cf49f013f184 Fixed a tabstop.
Ryan C. Gordon <icculus@icculus.org>
parents: 6091
diff changeset
    40
        event.drop.file = SDL_strdup(file);
6091
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
        posted = (SDL_PushEvent(&event) > 0);
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    }
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    return (posted);
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
}
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
61fa4f3238c5 First pass at a simple drag and drop API, allowing you to accept files dropped into your application.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
/* vi: set ts=4 sw=4 expandtab: */