changeset 444:406b12a17b15

Only modifier key state is noted when X11 window opens
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Aug 2002 03:19:59 +0000
parents 778b970cec12
children 98d778ed4abf
files src/video/x11/SDL_x11video.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/x11/SDL_x11video.c	Sat Aug 17 19:36:43 2002 +0000
+++ b/src/video/x11/SDL_x11video.c	Sun Aug 18 03:19:59 2002 +0000
@@ -833,6 +833,30 @@
 	/* Update the internal keyboard state */
 	X11_SetKeyboardState(SDL_Display, NULL);
 
+	/* When the window is first mapped, ignore non-modifier keys */
+	{
+		Uint8 *keys = SDL_GetKeyState(NULL);
+		for ( i = 0; i < SDLK_LAST; ++i ) {
+			switch (i) {
+			    case SDLK_NUMLOCK:
+			    case SDLK_CAPSLOCK:
+			    case SDLK_LCTRL:
+			    case SDLK_RCTRL:
+			    case SDLK_LSHIFT:
+			    case SDLK_RSHIFT:
+			    case SDLK_LALT:
+			    case SDLK_RALT:
+			    case SDLK_LMETA:
+			    case SDLK_RMETA:
+			    case SDLK_MODE:
+				break;
+			    default:
+				keys[i] = SDL_RELEASED;
+				break;
+			}
+		}
+	}
+
 	/* Map them both and go fullscreen, if requested */
 	if ( ! SDL_windowid ) {
 		XMapWindow(SDL_Display, SDL_Window);