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

Go to the source code of this file.

Functions

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

Variables

static SDLTest_CommonStatestate
int done
static const char * cursorNames []
int system_cursor = -1
SDL_Cursorcursor = NULL

Function Documentation

void loop ( )

Definition at line 51 of file testwm2.c.

References cursorNames, SDL_WindowEvent::data1, SDL_WindowEvent::data2, done, SDL_WindowEvent::event, i, SDL_Event::key, SDL_KeyboardEvent::keysym, SDLTest_CommonState::num_windows, renderer, SDLTest_CommonState::renderers, SDL_CreateSystemCursor, SDL_FALSE, SDL_FreeCursor, SDL_GetDisplayName, SDL_GetWindowDisplayIndex, SDL_GetWindowFromID, SDL_KEYUP, SDL_Log, SDL_NUM_SYSTEM_CURSORS, SDL_PollEvent, SDL_RenderClear, SDL_RenderPresent, SDL_SetCursor, SDL_TRUE, SDL_WINDOWEVENT, SDL_WINDOWEVENT_MOVED, SDL_WINDOWEVENT_RESIZED, SDLK_LEFT, SDLK_RIGHT, SDLTest_CommonEvent(), SDL_Keysym::sym, system_cursor, SDL_Event::type, SDL_Event::window, and SDL_WindowEvent::windowID.

{
int i;
/* Check for events */
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT) {
if (window) {
SDL_Log("Window %d resized to %dx%d\n",
event.window.data1,
event.window.data2);
}
}
if (window) {
SDL_Log("Window %d moved to %d,%d (display %s)\n",
event.window.data1,
event.window.data2,
}
}
}
if (event.type == SDL_KEYUP) {
SDL_bool updateCursor = SDL_FALSE;
if (event.key.keysym.sym == SDLK_LEFT) {
if (system_cursor < 0) {
}
updateCursor = SDL_TRUE;
} else if (event.key.keysym.sym == SDLK_RIGHT) {
}
updateCursor = SDL_TRUE;
}
if (updateCursor) {
SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]);
}
}
}
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 118 of file testwm2.c.

References cursorNames, done, i, loop(), SDLTest_CommonState::num_windows, quit(), renderer, SDLTest_CommonState::renderers, SDL_arraysize, SDL_assert, SDL_DROPFILE, SDL_DROPTEXT, SDL_ENABLE, SDL_EventState, SDL_FreeCursor, SDL_INIT_VIDEO, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogSetPriority, SDL_NUM_SYSTEM_CURSORS, SDL_RenderClear, SDL_SetRenderDrawColor, SDLTest_CommonArg(), SDLTest_CommonCreateState(), SDLTest_CommonInit(), and SDLTest_CommonUsage().

{
int i;
/* Enable standard application logging */
/* Initialize test framework */
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
int consumed;
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
consumed = -1;
}
if (consumed < 0) {
SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
quit(1);
}
i += consumed;
}
quit(2);
}
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear(renderer);
}
/* Main render loop */
done = 0;
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
loop();
}
#endif
quit(0);
/* keep the compiler happy ... */
return(0);
}
static void quit ( int  rc)
static

Definition at line 44 of file testwm2.c.

References SDLTest_CommonQuit().

{
exit(rc);
}

Variable Documentation

const char* cursorNames[]
static
Initial value:
{
"arrow",
"ibeam",
"wait",
"crosshair",
"waitarrow",
"sizeNWSE",
"sizeNESW",
"sizeWE",
"sizeNS",
"sizeALL",
"NO",
"hand",
}

Definition at line 25 of file testwm2.c.

Referenced by loop(), and main().

int done

Definition at line 23 of file testwm2.c.

SDLTest_CommonState* state
static

Definition at line 22 of file testwm2.c.

int system_cursor = -1

Definition at line 39 of file testwm2.c.

Referenced by loop().