diff test/common.c @ 5251:58265e606e4e

Window coordinates are in the global space and windows are not tied to a particular display. Also added Ctrl-Enter keybinding to the test code to toggle fullscreen mode for testing.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 10 Feb 2011 14:44:25 -0800
parents 762e40fb8e28
children d844537c42fd
line wrap: on
line diff
--- a/test/common.c	Thu Feb 10 14:36:09 2011 -0800
+++ b/test/common.c	Thu Feb 10 14:44:25 2011 -0800
@@ -1015,12 +1015,14 @@
         case SDLK_m:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-M maximize */
-                /* FIXME: Which window has focus for this keyboard? */
                 for (i = 0; i < state->num_windows; ++i) {
-                    if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) {
-                        SDL_RestoreWindow(state->windows[i]);
-                    } else {
-                        SDL_MaximizeWindow(state->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]);
+                        }
                     }
                 }
             }
@@ -1028,9 +1030,26 @@
         case SDLK_z:
             if (event->key.keysym.mod & KMOD_CTRL) {
                 /* Ctrl-Z minimize */
-                /* FIXME: Which window has focus for this keyboard? */
                 for (i = 0; i < state->num_windows; ++i) {
-                    SDL_MinimizeWindow(state->windows[i]);
+                    Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
+                    if (flags & SDL_WINDOW_INPUT_FOCUS) {
+                        SDL_MinimizeWindow(state->windows[i]);
+                    }
+                }
+            }
+            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);
+                        }
+                    }
                 }
             }
             break;