News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

r5846 SDL Linux Fullscreen Key Fix

Started by kierongreen, July 31, 2012, 09:47:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kierongreen

While investigating other issues with fullscreen mode with SDL in Linux I discovered that alt-tab and alt-f4 are not supported by SDL when in fullscreen mode. This patch minimises Simutrans if alt-tab is detected, and closes it if alt-f4 is detected.

prissi

This patch would assume that any windowmanager uses these shortcuts (and they do not, not to mention Haiku and amigaOS, where I have no clue. I am also sure MacOS uses a different shortcut).

Ters

Newer versions of Windows also have Win+Tab. The Win+Arrow keys might also need special handling. For some reason, I can't get Simutrans into fullscreen at the moment (the program just terminates), so I haven't been able to test this myself.

kierongreen

The problem with fullscreen SDL is that it doesn't pass on any keys to the window manager.

For the purposes of patch I assume that alt-tab and alt-f4 are used, this is true on Windows and most mainstream Linux distributions as far as I'm aware. Someone familiar with MacOS, Haiku and AmigaOS could include combinations for these platforms (if indeed the bug is present) along with compiler if statements for the appropriate platforms. When the window manager (or Windows) handles the key combination correctly they won't get passed to the event loop so the code will never be run.

I'm not attempting to handle all special key combinations with this patch, just provide the minimum needed for simutrans to behave as most people would expect. Due to the way simutrans works these key combinations don't have an immediate effect as it only works when the event loop is running (so not during map start and loading).

Ters

Quote from: kierongreen on August 07, 2012, 12:55:44 AM
The problem with fullscreen SDL is that it doesn't pass on any keys to the window manager.

That's quite evil in my opinion.

kierongreen

Quite evil or not it's what happens in current versions of SDL in Linux. This may change for SDL 2 but for SDL 1.x, which is what is likely to be in distributions for some time this won't change (I checked on the SDL development forums about this, they are aware of the issue).

Ters

Well, there are native backends for Windows and Mac, so we avoid the bugs and unwanted behaviours SDL there. That would leave Linux/X as the only major platform without an alternative to SDL. (Well, there is an Allegro backend, but I don't know what the status of that is.)

kierongreen

On Windows this isn't an issue as Windows itself stops the key combinations getting as far as SDL programs. I'm not sure what happens with Macs.