test/testwm2.c
changeset 6677 c3202c29e352
parent 5535 96594ac5fd1a
child 6785 c094c438c0a6
     1.1 --- a/test/testwm2.c	Mon Nov 19 20:27:08 2012 -0800
     1.2 +++ b/test/testwm2.c	Mon Nov 19 20:38:52 2012 -0800
     1.3 @@ -28,8 +28,26 @@
     1.4  int
     1.5  main(int argc, char *argv[])
     1.6  {
     1.7 +    static const char *cursorNames[] = {
     1.8 +        "arrow",
     1.9 +        "ibeam",
    1.10 +        "wait",
    1.11 +        "crosshair",
    1.12 +        "waitarrow",
    1.13 +        "sizeNWSE",
    1.14 +        "sizeNESW",
    1.15 +        "sizeWE",
    1.16 +        "sizeNS",
    1.17 +        "sizeALL",
    1.18 +        "NO",
    1.19 +        "hand",
    1.20 +    };
    1.21 +    SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS);
    1.22 +
    1.23      int i, done;
    1.24      SDL_Event event;
    1.25 +    int system_cursor = -1;
    1.26 +    SDL_Cursor *cursor = NULL;
    1.27  
    1.28      /* Initialize test framework */
    1.29      state = CommonCreateState(argv, SDL_INIT_VIDEO);
    1.30 @@ -73,8 +91,33 @@
    1.31                      }
    1.32                  }
    1.33              }
    1.34 +            if (event.type == SDL_KEYUP) {
    1.35 +                SDL_bool updateCursor = SDL_FALSE;
    1.36 +
    1.37 +                if (event.key.keysym.sym == SDLK_LEFT) {
    1.38 +                    --system_cursor;
    1.39 +                    if (system_cursor < 0) {
    1.40 +                        system_cursor = SDL_NUM_SYSTEM_CURSORS - 1;
    1.41 +                    }
    1.42 +                    updateCursor = SDL_TRUE;
    1.43 +                } else if (event.key.keysym.sym == SDLK_RIGHT) {
    1.44 +                    ++system_cursor;
    1.45 +                    if (system_cursor >= SDL_NUM_SYSTEM_CURSORS) {
    1.46 +                        system_cursor = 0;
    1.47 +                    }
    1.48 +                    updateCursor = SDL_TRUE;
    1.49 +                }
    1.50 +                if (updateCursor) {
    1.51 +                    SDL_Log("Changing cursor to \"%s\"", cursorNames[system_cursor]);
    1.52 +                    SDL_FreeCursor(cursor);
    1.53 +                    cursor = SDL_CreateSystemCursor((SDL_SystemCursor)system_cursor);
    1.54 +                    SDL_SetCursor(cursor);
    1.55 +                }
    1.56 +            }
    1.57          }
    1.58      }
    1.59 +    SDL_FreeCursor(cursor);
    1.60 +
    1.61      quit(0);
    1.62  	// keep the compiler happy ...
    1.63  	return(0);