The International Simutrans Forum

 

Author Topic: r5846 SDL Linux Fullscreen Key Fix  (Read 3854 times)

0 Members and 1 Guest are viewing this topic.

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
r5846 SDL Linux Fullscreen Key Fix
« on: July 31, 2012, 09:47:52 PM »
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10636
  • Languages: De,EN,JP
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #1 on: August 06, 2012, 09:43:31 PM »
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).

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #2 on: August 06, 2012, 10:59:16 PM »
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.

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #3 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.

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).

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #4 on: August 07, 2012, 08:56:48 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.

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #5 on: August 07, 2012, 11:10:10 AM »
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).

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #6 on: August 07, 2012, 11:24:30 AM »
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.)

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: r5846 SDL Linux Fullscreen Key Fix
« Reply #7 on: August 07, 2012, 11:30:03 AM »
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.