SDL  2.0
testdropfile.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "SDL_test_common.h"
+ Include dependency graph for testdropfile.c:

Go to the source code of this file.

Functions

static void quit (int rc)
 
int main (int argc, char *argv[])
 

Variables

static SDLTest_CommonStatestate
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 29 of file testdropfile.c.

References done, SDL_Event::drop, i, SDLTest_CommonState::num_windows, quit(), renderer, SDLTest_CommonState::renderers, SDL_DROPBEGIN, SDL_DROPCOMPLETE, SDL_DROPFILE, SDL_DROPTEXT, SDL_ENABLE, SDL_EventState, SDL_free, SDL_INIT_VIDEO, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogSetPriority, SDL_PollEvent, SDL_RenderClear, SDL_RenderPresent, SDL_SetRenderDrawColor, SDL_strncmp, SDLTest_CommonArg(), SDLTest_CommonCreateState(), SDLTest_CommonEvent(), SDLTest_CommonInit(), SDLTest_CommonUsage(), SDL_Event::type, and SDL_DropEvent::windowID.

30 {
31  int i, done;
33 
34  /* Enable standard application logging */
36 
37  /* Initialize test framework */
39  if (!state) {
40  return 1;
41  }
42 
43  for (i = 1; i < argc;) {
44  int consumed;
45 
46  consumed = SDLTest_CommonArg(state, i);
47  /* needed voodoo to allow app to launch via OS X Finder */
48  if (SDL_strncmp(argv[i], "-psn", 4)==0) {
49  consumed = 1;
50  }
51  if (consumed == 0) {
52  consumed = -1;
53  }
54  if (consumed < 0) {
55  SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
56  quit(1);
57  }
58  i += consumed;
59  }
60  if (!SDLTest_CommonInit(state)) {
61  quit(2);
62  }
63 
64  for (i = 0; i < state->num_windows; ++i) {
66  SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
67  SDL_RenderClear(renderer);
68  SDL_RenderPresent(renderer);
69  }
70 
72 
73  /* Main render loop */
74  done = 0;
75  while (!done) {
76  /* Check for events */
77  while (SDL_PollEvent(&event)) {
78  SDLTest_CommonEvent(state, &event, &done);
79 
80  if (event.type == SDL_DROPBEGIN) {
81  SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID);
82  } else if (event.type == SDL_DROPCOMPLETE) {
83  SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID);
84  } else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
85  const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text";
86  char *dropped_filedir = event.drop.file;
87  SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir);
88  SDL_free(dropped_filedir);
89  }
90  }
91  }
92 
93  quit(0);
94  /* keep the compiler happy ... */
95  return(0);
96 }
#define SDL_PollEvent
Uint32 windowID
Definition: SDL_events.h:470
SDLTest_CommonState * SDLTest_CommonCreateState(char **argv, Uint32 flags)
Parse command line parameters and create common state.
int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
Process one common argument.
#define SDL_ENABLE
Definition: SDL_events.h:722
SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
Open test window.
#define SDL_strncmp
#define SDL_Log
void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done)
Common event handler for test windows.
static SDL_Renderer * renderer
#define SDL_free
struct _cl_event * event
int done
Definition: checkkeys.c:28
const char * SDLTest_CommonUsage(SDLTest_CommonState *state)
Returns common usage information.
SDL_Renderer ** renderers
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define SDL_LogSetPriority
#define SDL_RenderClear
#define SDL_EventState
static void quit(int rc)
Definition: testdropfile.c:22
General event structure.
Definition: SDL_events.h:525
#define SDL_SetRenderDrawColor
static SDLTest_CommonState * state
Definition: testdropfile.c:18
#define SDL_INIT_VIDEO
Definition: SDL.h:78
SDL_DropEvent drop
Definition: SDL_events.h:551
#define SDL_RenderPresent
Uint32 type
Definition: SDL_events.h:527

◆ quit()

static void quit ( int  rc)
static

Definition at line 22 of file testdropfile.c.

References SDLTest_CommonQuit().

Referenced by main().

23 {
25  exit(rc);
26 }
static SDLTest_CommonState * state
Definition: testdropfile.c:18
void SDLTest_CommonQuit(SDLTest_CommonState *state)
Close test window.

Variable Documentation

◆ state

SDLTest_CommonState* state
static

Definition at line 18 of file testdropfile.c.