# HG changeset patch # User Eli Gottlieb # Date 1279510599 14400 # Node ID a4c1df8806902ddb135bfc2bc18078a9a75604dc # Parent f14a8c05f5bbdaa7f11dffa20845d04ee9aa5c83 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke. diff -r f14a8c05f5bb -r a4c1df880690 test/testshape.c --- a/test/testshape.c Sun Jul 18 23:05:40 2010 -0400 +++ b/test/testshape.c Sun Jul 18 23:36:39 2010 -0400 @@ -5,6 +5,7 @@ #include #include #include +#include #define SHAPED_WINDOW_X 150 #define SHAPED_WINDOW_Y 150 @@ -86,7 +87,7 @@ event_pending = SDL_PollEvent(&event); unsigned int current_picture = 0; SDL_WindowShapeMode mode = {ShapeModeDefault,1}; - int mouse_down = 0; + int button_down = 0; Uint32 format = 0,access = 0; SDL_Rect texture_dimensions = {0,0,0,0}; SDL_QueryTexture(textures[current_picture],&format,&access,&texture_dimensions.w,&texture_dimensions.h); @@ -95,10 +96,13 @@ while(should_exit == 0) { event_pending = SDL_PollEvent(&event); if(event_pending == 1) { - if(event.type == SDL_MOUSEBUTTONDOWN) - mouse_down = 1; - if(mouse_down && event.type == SDL_MOUSEBUTTONUP) { - mouse_down = 0; + if(event.type == SDL_KEYDOWN) { + button_down = 1; + if(event.key.keysym.sym == SDLK_ESCAPE) + should_exit = 1; + } + if(button_down && event.type == SDL_KEYUP) { + button_down = 0; current_picture += 1; if(current_picture >= num_pictures) current_picture = 0;