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 534902770b3c43f8
parent 5348 16202b090a63
child 5350 95712d32f0ed
We have the correct window, we don't have to search for it, duh. :)
test/common.c
     1.1 --- a/test/common.c	Sat Feb 19 11:23:56 2011 -0800
     1.2 +++ b/test/common.c	Sat Feb 19 11:26:49 2011 -0800
     1.3 @@ -1018,19 +1018,22 @@
     1.4          case SDLK_g:
     1.5              if (event->key.keysym.mod & KMOD_CTRL) {
     1.6                  /* Ctrl-G toggle grab */
     1.7 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
     1.8 +                if (window) {
     1.9 +                    SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window));
    1.10 +                }
    1.11              }
    1.12              break;
    1.13          case SDLK_m:
    1.14              if (event->key.keysym.mod & KMOD_CTRL) {
    1.15                  /* Ctrl-M maximize */
    1.16 -                for (i = 0; i < state->num_windows; ++i) {
    1.17 -                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
    1.18 -                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
    1.19 -                        if (flags & SDL_WINDOW_MAXIMIZED) {
    1.20 -                            SDL_RestoreWindow(state->windows[i]);
    1.21 -                        } else {
    1.22 -                            SDL_MaximizeWindow(state->windows[i]);
    1.23 -                        }
    1.24 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
    1.25 +                if (window) {
    1.26 +                    Uint32 flags = SDL_GetWindowFlags(window);
    1.27 +                    if (flags & SDL_WINDOW_MAXIMIZED) {
    1.28 +                        SDL_RestoreWindow(window);
    1.29 +                    } else {
    1.30 +                        SDL_MaximizeWindow(window);
    1.31                      }
    1.32                  }
    1.33              }
    1.34 @@ -1038,25 +1041,22 @@
    1.35          case SDLK_z:
    1.36              if (event->key.keysym.mod & KMOD_CTRL) {
    1.37                  /* Ctrl-Z minimize */
    1.38 -                for (i = 0; i < state->num_windows; ++i) {
    1.39 -                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
    1.40 -                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
    1.41 -                        SDL_MinimizeWindow(state->windows[i]);
    1.42 -                    }
    1.43 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
    1.44 +                if (window) {
    1.45 +                    SDL_MinimizeWindow(window);
    1.46                  }
    1.47              }
    1.48              break;
    1.49          case SDLK_RETURN:
    1.50              if (event->key.keysym.mod & KMOD_CTRL) {
    1.51                  /* Ctrl-Enter toggle fullscreen */
    1.52 -                for (i = 0; i < state->num_windows; ++i) {
    1.53 -                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
    1.54 -                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
    1.55 -                        if (flags & SDL_WINDOW_FULLSCREEN) {
    1.56 -                            SDL_SetWindowFullscreen(state->windows[i], SDL_FALSE);
    1.57 -                        } else {
    1.58 -                            SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
    1.59 -                        }
    1.60 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
    1.61 +                if (window) {
    1.62 +                    Uint32 flags = SDL_GetWindowFlags(window);
    1.63 +                    if (flags & SDL_WINDOW_FULLSCREEN) {
    1.64 +                        SDL_SetWindowFullscreen(window, SDL_FALSE);
    1.65 +                    } else {
    1.66 +                        SDL_SetWindowFullscreen(window, SDL_TRUE);
    1.67                      }
    1.68                  }
    1.69              }