mirror of https://github.com/stella-emu/stella.git
Fix for weird Alt-Tab behaviour in Linux.
- An extraneous TAB key event was being generated - This is possibly an SDL bug in Linux only; it doesn't happen on other systems - I've contacted the SDL mailing list for more info, so this code may be temporary
This commit is contained in:
parent
1677ecae12
commit
4af7ba28fb
11
Changes.txt
11
Changes.txt
|
@ -12,6 +12,15 @@
|
||||||
Release History
|
Release History
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
||||||
|
5.0.1 to 5.x: (xxxx yy, 2017)
|
||||||
|
|
||||||
|
* Fixed an annoying bug in Linux, where Alt-Tab'ing out of a window and
|
||||||
|
then back again would pass a 'Tab' key event to the app, which in
|
||||||
|
most cases would navigate to the next UI element.
|
||||||
|
|
||||||
|
-Have fun!
|
||||||
|
|
||||||
|
|
||||||
5.0 to 5.0.1: (July 23, 2017)
|
5.0 to 5.0.1: (July 23, 2017)
|
||||||
|
|
||||||
* Fixed issues in keypad, Genesis and various other controllers that use
|
* Fixed issues in keypad, Genesis and various other controllers that use
|
||||||
|
@ -25,8 +34,6 @@
|
||||||
|
|
||||||
* Codebase now uses C++14 features.
|
* Codebase now uses C++14 features.
|
||||||
|
|
||||||
-Have fun!
|
|
||||||
|
|
||||||
|
|
||||||
4.7.3 to 5.0: (July 16, 2017)
|
4.7.3 to 5.0: (July 16, 2017)
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ EventHandler::EventHandler(OSystem& osystem)
|
||||||
myFryingFlag(false),
|
myFryingFlag(false),
|
||||||
myUseCtrlKeyFlag(true),
|
myUseCtrlKeyFlag(true),
|
||||||
mySkipMouseMotion(true),
|
mySkipMouseMotion(true),
|
||||||
|
myAltKeyCounter(0),
|
||||||
myContSnapshotInterval(0),
|
myContSnapshotInterval(0),
|
||||||
myContSnapshotCounter(0)
|
myContSnapshotCounter(0)
|
||||||
{
|
{
|
||||||
|
@ -246,6 +247,16 @@ void EventHandler::handleTextEvent(char text)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
||||||
{
|
{
|
||||||
|
// Swallow KBDK_TAB and KBDK_RETURN under certain conditions
|
||||||
|
// See commments on 'myAltKeyCounter' for more information
|
||||||
|
#ifdef BSPF_UNIX
|
||||||
|
if(myAltKeyCounter > 1 && (key == KBDK_TAB || key == KBDK_RETURN))
|
||||||
|
{
|
||||||
|
myAltKeyCounter = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
|
|
||||||
// Immediately store the key state
|
// Immediately store the key state
|
||||||
|
@ -263,8 +274,16 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if(key == KBDK_RETURN)
|
if(key == KBDK_TAB)
|
||||||
{
|
{
|
||||||
|
// Swallow Alt-Tab, but remember that it happened
|
||||||
|
myAltKeyCounter = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(key == KBDK_RETURN)
|
||||||
|
{
|
||||||
|
// Swallow Alt-Enter, but remember that it happened
|
||||||
|
myAltKeyCounter = 1;
|
||||||
myOSystem.frameBuffer().toggleFullscreen();
|
myOSystem.frameBuffer().toggleFullscreen();
|
||||||
}
|
}
|
||||||
// These only work when in emulation mode
|
// These only work when in emulation mode
|
||||||
|
@ -823,11 +842,18 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int)
|
||||||
switch(e)
|
switch(e)
|
||||||
{
|
{
|
||||||
case EVENT_WINDOW_EXPOSED:
|
case EVENT_WINDOW_EXPOSED:
|
||||||
myOSystem.frameBuffer().update();
|
myOSystem.frameBuffer().update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVENT_WINDOW_FOCUS_GAINED:
|
||||||
|
// Used to handle Alt-x key combos; sometimes the key associated with
|
||||||
|
// Alt gets 'stuck' and is passed to the core for processing
|
||||||
|
if(myAltKeyCounter > 0)
|
||||||
|
myAltKeyCounter = 2;
|
||||||
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case EVENT_WINDOW_MINIMIZED:
|
case EVENT_WINDOW_MINIMIZED:
|
||||||
if(myState == S_EMULATE) enterMenuMode(S_MENU);
|
if(myState == S_EMULATE) enterMenuMode(S_MENU);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default: // handle other events as testing requires
|
default: // handle other events as testing requires
|
||||||
|
|
|
@ -583,6 +583,19 @@ class EventHandler
|
||||||
// state change; we detect when this happens and discard the event
|
// state change; we detect when this happens and discard the event
|
||||||
bool mySkipMouseMotion;
|
bool mySkipMouseMotion;
|
||||||
|
|
||||||
|
// Sometimes key combos with the Alt key become 'stuck' after the
|
||||||
|
// window changes state, and we want to ignore that event
|
||||||
|
// For example, press Alt-Tab and then upon re-entering the window,
|
||||||
|
// the app receives 'tab'; obviously the 'tab' shouldn't be happening
|
||||||
|
// So we keep track of the cases that matter (Alt-Tab and Alt-Enter)
|
||||||
|
// and swallow the event afterwards
|
||||||
|
// Basically, the initial event sets the variable to 1, and upon
|
||||||
|
// returning to the app (ie, receiving EVENT_WINDOW_FOCUS_GAINED),
|
||||||
|
// the count is updated to 2, but only if it was already updated to 1
|
||||||
|
// TODO - This may be a bug in SDL, and might be removed in the future
|
||||||
|
// It only seems to be an issue in Linux
|
||||||
|
uInt8 myAltKeyCounter;
|
||||||
|
|
||||||
// Used for continuous snapshot mode
|
// Used for continuous snapshot mode
|
||||||
uInt32 myContSnapshotInterval;
|
uInt32 myContSnapshotInterval;
|
||||||
uInt32 myContSnapshotCounter;
|
uInt32 myContSnapshotCounter;
|
||||||
|
|
Loading…
Reference in New Issue