diff --git a/docs.html b/docs.html
index f2c3ccc43..e35b5ffd3 100644
--- a/docs.html
+++ b/docs.html
@@ -16,6 +16,7 @@ be found at the main SDL page.
Major changes since SDL 1.0.0:
+ - 1.2.1: Fixed stuck keys when changing the video mode
- 1.2.1: Fixed double-mouse event bug on Windows using OpenGL
- 1.2.1: Fixed 320x200 video mode on framebuffer console
- 1.2.1: Improved robustness for the ELO touchpad (thanks Alex!)
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index c7898befb..d5597eba3 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -335,6 +335,7 @@ void SDL_ResetKeyboard(void)
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
}
+ SDL_KeyRepeat.timestamp = 0;
}
int SDL_EnableUNICODE(int enable)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 65f6197ec..c5b1fb4c8 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -567,6 +567,9 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
}
+ /* Reset the keyboard here so event callbacks can run */
+ SDL_ResetKeyboard();
+
/* Clean up any previous video mode */
if ( SDL_PublicSurface != NULL ) {
SDL_PublicSurface = NULL;
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index 3d376feca..3c3ff1510 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -54,6 +54,9 @@ static char rcsid =
#include "SDL_x11events_c.h"
+/* Define this if you want to debug X11 events */
+/*#define DEBUG_XEVENTS*/
+
/* The translation tables from an X11 keysym to a SDL keysym */
static SDLKey ODD_keymap[256];
static SDLKey MISC_keymap[256];
@@ -219,6 +222,9 @@ printf("FocusOut!\n");
/* Generated upon EnterWindow and FocusIn */
case KeymapNotify: {
+#ifdef DEBUG_XEVENTS
+printf("KeymapNotify!\n");
+#endif
X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
}
break;
@@ -263,6 +269,10 @@ printf("FocusOut!\n");
/* Key press? */
case KeyPress: {
SDL_keysym keysym;
+
+#ifdef DEBUG_XEVENTS
+printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
+#endif
posted = SDL_PrivateKeyboard(SDL_PRESSED,
X11_TranslateKey(SDL_Display, &xevent.xkey,
xevent.xkey.keycode,
@@ -274,6 +284,9 @@ printf("FocusOut!\n");
case KeyRelease: {
SDL_keysym keysym;
+#ifdef DEBUG_XEVENTS
+printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
+#endif
/* Check to see if this is a repeated key */
if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) {
posted = SDL_PrivateKeyboard(SDL_RELEASED,