SDL  2.0
SDL_dropevents.c File Reference
#include "../SDL_internal.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_dropevents_c.h"
#include "../video/SDL_sysvideo.h"
+ Include dependency graph for SDL_dropevents.c:

Go to the source code of this file.

Functions

static int SDL_SendDrop (SDL_Window *window, const SDL_EventType evtype, const char *data)
 
int SDL_SendDropFile (SDL_Window *window, const char *file)
 
int SDL_SendDropText (SDL_Window *window, const char *text)
 
int SDL_SendDropComplete (SDL_Window *window)
 

Function Documentation

◆ SDL_SendDrop()

static int SDL_SendDrop ( SDL_Window window,
const SDL_EventType  evtype,
const char *  data 
)
static

Definition at line 33 of file SDL_dropevents.c.

References SDL_Window::id, SDL_Window::is_dropping, NULL, SDL_DROPBEGIN, SDL_DROPCOMPLETE, SDL_ENABLE, SDL_FALSE, SDL_GetEventState, SDL_PushEvent, SDL_strdup, SDL_TRUE, and SDL_zero.

Referenced by SDL_SendDropComplete(), SDL_SendDropFile(), and SDL_SendDropText().

34 {
35  static SDL_bool app_is_dropping = SDL_FALSE;
36  int posted = 0;
37 
38  /* Post the event, if desired */
39  if (SDL_GetEventState(evtype) == SDL_ENABLE) {
40  const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping;
42 
43  if (need_begin) {
44  SDL_zero(event);
45  event.type = SDL_DROPBEGIN;
46 
47  if (window) {
48  event.drop.windowID = window->id;
49  }
50 
51  posted = (SDL_PushEvent(&event) > 0);
52  if (!posted) {
53  return 0;
54  }
55  if (window) {
56  window->is_dropping = SDL_TRUE;
57  } else {
58  app_is_dropping = SDL_TRUE;
59  }
60  }
61 
62  SDL_zero(event);
63  event.type = evtype;
64  event.drop.file = data ? SDL_strdup(data) : NULL;
65  event.drop.windowID = window ? window->id : 0;
66  posted = (SDL_PushEvent(&event) > 0);
67 
68  if (posted && (evtype == SDL_DROPCOMPLETE)) {
69  if (window) {
70  window->is_dropping = SDL_FALSE;
71  } else {
72  app_is_dropping = SDL_FALSE;
73  }
74  }
75  }
76  return posted;
77 }
SDL_bool is_dropping
Definition: SDL_sysvideo.h:102
#define SDL_ENABLE
Definition: SDL_events.h:722
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
struct _cl_event * event
#define SDL_PushEvent
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
#define NULL
Definition: begin_code.h:164
SDL_bool
Definition: SDL_stdinc.h:139
#define SDL_strdup
Uint32 id
Definition: SDL_sysvideo.h:76
General event structure.
Definition: SDL_events.h:525

◆ SDL_SendDropComplete()

int SDL_SendDropComplete ( SDL_Window window)

Definition at line 92 of file SDL_dropevents.c.

References NULL, SDL_DROPCOMPLETE, and SDL_SendDrop().

93 {
94  return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL);
95 }
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data)
#define NULL
Definition: begin_code.h:164

◆ SDL_SendDropFile()

int SDL_SendDropFile ( SDL_Window window,
const char *  file 
)

Definition at line 80 of file SDL_dropevents.c.

References SDL_DROPFILE, and SDL_SendDrop().

81 {
82  return SDL_SendDrop(window, SDL_DROPFILE, file);
83 }
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data)

◆ SDL_SendDropText()

int SDL_SendDropText ( SDL_Window window,
const char *  text 
)

Definition at line 86 of file SDL_dropevents.c.

References SDL_DROPTEXT, and SDL_SendDrop().

87 {
88  return SDL_SendDrop(window, SDL_DROPTEXT, text);
89 }
static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data)
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47