We have the correct window, we don't have to search for it, duh. :)
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Feb 2011 11:26:49 -0800
changeset 5349 02770b3c43f8
parent 5348 16202b090a63
child 5350 95712d32f0ed
We have the correct window, we don't have to search for it, duh. :)
test/common.c
--- a/test/common.c	Sat Feb 19 11:23:56 2011 -0800
+++ b/test/common.c	Sat Feb 19 11:26:49 2011 -0800
@@ -1018,19 +1018,22 @@
         case SDLK_g:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-G toggle grab */
+                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
+                if (window) {
+                    SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window));
+                }
             }
             break;
         case SDLK_m:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-M maximize */
-                for (i = 0; i < state->num_windows; ++i) {
-                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
-                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
-                        if (flags & SDL_WINDOW_MAXIMIZED) {
-                            SDL_RestoreWindow(state->windows[i]);
-                        } else {
-                            SDL_MaximizeWindow(state->windows[i]);
-                        }
+                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
+                if (window) {
+                    Uint32 flags = SDL_GetWindowFlags(window);
+                    if (flags & SDL_WINDOW_MAXIMIZED) {
+                        SDL_RestoreWindow(window);
+                    } else {
+                        SDL_MaximizeWindow(window);
                     }
                 }
             }
@@ -1038,25 +1041,22 @@
         case SDLK_z:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-Z minimize */
-                for (i = 0; i < state->num_windows; ++i) {
-                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
-                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
-                        SDL_MinimizeWindow(state->windows[i]);
-                    }
+                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
+                if (window) {
+                    SDL_MinimizeWindow(window);
                 }
             }
             break;
         case SDLK_RETURN:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-Enter toggle fullscreen */
-                for (i = 0; i < state->num_windows; ++i) {
-                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
-                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
-                        if (flags & SDL_WINDOW_FULLSCREEN) {
-                            SDL_SetWindowFullscreen(state->windows[i], SDL_FALSE);
-                        } else {
-                            SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
-                        }
+                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
+                if (window) {
+                    Uint32 flags = SDL_GetWindowFlags(window);
+                    if (flags & SDL_WINDOW_FULLSCREEN) {
+                        SDL_SetWindowFullscreen(window, SDL_FALSE);
+                    } else {
+                        SDL_SetWindowFullscreen(window, SDL_TRUE);
                     }
                 }
             }