SDL/src
Sam Lantinga f2224e1fc7 Fixed bug 1990 - focus/keyboard events not generated correctly for multiple windows
Mai Lavelle

I've recently tried to create multiple windows and process key events for them, and found that key events weren't being generated for most of the windows. After some investigating I've observed the following effects. All but the most recently created window experience these effects...

- a focus lost event is generated immediately after the focus gained event, even tho window still has focus
- key events report window id 0 rather than the id of the window which has focus, SDL thinks no window has focus?
- giving focus to a non SDL window and then selecting an SDL window causes events to be generated as expected, but only until focus changes again

Focus change events are queued and delayed (200 ticks) before they are dispatched.  The problem occurs when a focus out and focus in event are received on the same tick.  When these delayed events are dispatched they will be sent in the order determined by the window list rather than the order in which they are received.

The focus out dispatch is implemented by calling SDL_SetKeyboardFocus(NULL).  This will remove focus from any window, regardless of whether it is the one originally targeted by the X11 event.

Since SDL_SetKeyboardFocus() will always dispatch a focus lost event as needed, the easiest solution is simply to only call SDL_SetKeyboardFocus(NULL) when SDL_GetKeyboardFocus() matches the target window.
2013-11-03 09:55:27 -08:00
..
atomic Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings 2013-10-20 21:56:15 -07:00
audio Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws multiple warnings 2013-10-20 21:56:15 -07:00
core Fixed a crash initializing Android touch IDs 2013-10-20 23:23:25 -07:00
cpuinfo Initialize MEMORYSTATUSEX size before GlobalMemoryStatusEx() (thanks, Justin!). 2013-10-23 19:52:14 -04:00
events Changed parameter name for gesture template save functions from "src" to "dst". 2013-11-02 12:07:21 +01:00
file Fixed building using MinGW 2013-10-17 23:02:29 -07:00
filesystem Fixed buffer overflow. 2013-10-24 00:00:10 -04:00
haptic Moved a SDL_SetError() call elsewhere to avoid triggering it needlessly. 2013-10-23 15:54:12 -04:00
input/evdev Prevent keystrokes from leaking through to the console when using evdev. 2013-10-13 17:15:43 -03:00
joystick Fixed some warnings building for 64-bit Windows 2013-10-21 01:16:16 -07:00
libm OCD fixes: Adds a space after /* (glory to regular expressions!) 2013-08-21 09:47:10 -03:00
loadso Rolled back my LoadLibrary change. The first failed call causes a dialog to pop up in Windows apps (but not console apps) and that's really bad. I'll have to deal with this in my app. 2013-09-28 14:06:39 -07:00
main Backed out changeset 737771c47c6f, done testing Buildbot changes. 2013-10-20 20:24:00 -04:00
power Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values. 2013-10-20 20:42:55 -07:00
render Changed function to return -1 through SDL_Error() instead of plain -1. 2013-11-02 11:46:43 +01:00
stdlib Fixed building using MinGW 2013-10-17 23:02:29 -07:00
test Fixed common test usage string (was "hidpi", should be "highdpi"). 2013-10-30 16:39:35 -04:00
thread Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values. 2013-10-20 20:42:55 -07:00
timer Fixes bug #2074 - Thanks Sylvain! 2013-08-29 14:03:44 -03:00
video Fixed bug 1990 - focus/keyboard events not generated correctly for multiple windows 2013-11-03 09:55:27 -08:00
SDL.c It's okay to quit things more than once. 2013-10-20 10:39:26 -07:00
SDL_assert.c Fixed building using MinGW 2013-10-17 23:02:29 -07:00
SDL_assert_c.h Fixes #2022, do not resume on Android when surfaceChanged 2013-08-12 11:13:50 -03:00
SDL_error.c Fixes #2022, do not resume on Android when surfaceChanged 2013-08-12 11:13:50 -03:00
SDL_error_c.h Fixes #2022, do not resume on Android when surfaceChanged 2013-08-12 11:13:50 -03:00
SDL_hints.c Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
SDL_log.c Fixed building using MinGW 2013-10-17 23:02:29 -07:00