Bug 2776 - Alt-Tab doesn't work (on at least winnt/win2k/winxp)
Status: RESOLVED WONTFIX
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Platform
Version: 1.33 SVN
Hardware: PC Windows 2000
: P2 enhancement
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2006-07-12 22:42 EDT by Tony J. White
Modified: 2011-03-07 18:58:14 EST
2 users (show)

See Also:


Attachments
alt-tab support (1.69 KB, patch)
2006-07-12 22:43 EDT, Tony J. White
svn 816: fullscreen alt-tab support (3.04 KB, patch)
2006-07-14 00:36 EDT, Tony J. White
svn951 win_allowAltTab (3.70 KB, patch)
2006-10-25 10:25 EDT, Tony J. White
svn1046 win_allowAltTab (18.22 KB, patch)
2007-02-26 23:38 EST, Tony J. White
svn1048 cl_altTab / r_minimize / win_fastModeChange (10.57 KB, patch)
2007-03-02 14:48 EST, Tony J. White
svn1183 alt-tab patch (7.25 KB, patch)
2007-09-18 23:39 EDT, Tony J. White

Description Tony J. White 2006-07-12 22:42:57 EDT
It seems that Alt-Tab support was intentially disabled if the "arch" cvar is "winnt" (which is Windows NT, Windows 2000, and Windows XP).

I took the attached patch mostly from Rich Stanway's Tremulous build and it seems to work fine on Windows 2000 (all I have to test with).
Comment 1 Tony J. White 2006-07-12 22:43:36 EDT
Created attachment 957 [details]
alt-tab support
Comment 2 Zachary J. Slater 2006-07-12 22:44:30 EDT
I'm hoping this will be resolved once we switch to sdl.
Comment 3 Tony J. White 2006-07-13 10:53:49 EDT
(In reply to comment #2)
> I'm hoping this will be resolved once we switch to sdl.
> 

Will the SDL move be soon?

I ask because my patch needs work (plus a cvar to disable the behaviour).  Should I bother resubmitting?
Comment 4 Zachary J. Slater 2006-07-13 13:02:32 EDT
Not likely, unless I can find a programmer to do it. With regards to applying a cleaned up version of this patch, I haven't read it but if it isn't too hideous I don't mind.
Comment 5 Tony J. White 2006-07-14 00:36:36 EDT
Created attachment 959 [details]
svn 816: fullscreen alt-tab support

This patch adds the cvar win_allowAltTab to toggle the new behaviour.

It also supports flipping between the Desktop resolution/colordepth and that of the game.

I have only tested on Windows 2000, but I have made a Tremulous .exe so I should be able to get feedback from other versions soon.   http://trem.tjw.org/backport/
Comment 6 Tony J. White 2006-07-17 01:27:57 EDT
(In reply to comment #5)
> I have only tested on Windows 2000, but I have made a Tremulous .exe so I
> should be able to get feedback from other versions soon.  
> http://trem.tjw.org/backport/

It seems some drivers, or perhaps just cards with low video ram have problems with this.  When switching display resolution back to the one used for full screen textures become corrupted requiring /vid_restart.



Comment 7 Tony J. White 2006-10-25 10:25:19 EDT
Created attachment 1126 [details]
svn951 win_allowAltTab

This is a different version of the same thing that is less hackish.

Also win_allowAltTab now defaults too 0 (off) because of the problems this feature causes on certain hardware/drivers.

It's still unclear to me if it's possible detect which hardware/drivers are incompatible with flipping back to fullscreen with ChangeDisplaySettings().  Possibly this is just a limitation of video memory?  If this could be reliably   detected, win_allowAltTab could default to on, we would just need to send a vid_restart cmd after switching from minimized to fullscreen.
Comment 8 Tony J. White 2007-02-26 23:38:04 EST
Created attachment 1276 [details]
svn1046 win_allowAltTab

I'm posting this patch for reference, not for inclusion.

Windows OpenGL drivers tend to be quite unpredictable and lame when
changing display resolution.  Some drivers (e.g. ATI) tend to corrupt things that are important (e.g. texture memory).

This patch shows my attempt at reloading all textures from disk following a
change in display resolution.  This gives mixed results because of other
lame behaviour in the OpenGL drivers I tested:

  1) when texture memory is corrupted, simply reloading the texture with
     glTexImage2D or glTexSubImage2D fails.  The texture must be deleted
     with glDeleteTextures before it can be reloaded.

  2) If one of the textures has been modified with glTextSubImage2D (e.g.
     the "*scratch" images), then calling glDeleteTextures can cause a crash
     on some ATI drivers.

  3) Reloading all the textures after a mode change stops corruption, but
     but some textures are not visible in one of the older Rage Pro drivers
     I tested

  4) Simply changing resolution in one Rage Pro driver causes ioq3 to hang
     occasionally.

If I could have achieved decent results from this process of reloading all
texture memory, I would pursue it further, but it all seems like this is just
a wasted effort.

At this point, I think the only reasonable solution for ioquake3 is to support
three win_allowAltTab settins:
  0 - disabled
  1 - do a vid_restart (the safe way)
  2 - trust the OpenGL driver to do the right thing

I'm leaning towards 1 as being the default since I think this will be safe
on even the shittiest of display drivers.  The only issue is that some users
may be accustomed to using Alt and Tab as binds, in which case they should
recieve a message that tells them how to disable Alt-Tab support anyway.
Comment 9 Tony J. White 2007-03-02 14:48:51 EST
Created attachment 1281 [details]
svn1048 cl_altTab / r_minimize / win_fastModeChange


This patch adds Alt-Tab support to win32 and SDL builds.  It's controlled
with the following cvars:

cl_altTab [0|1] (default 1)
  When non-0, hitting the key combination Alt-Tab will minimize ioq3 and restore
  the desktop resolution.  When ioq3 is un-minimized, the fullscreen
  resolution is restored.  On Mac and Win32, this only applies to fullscreen.
 
r_minimize [0|1] (always resets to 0)
  Setting this to non-0 is the equivalent of the Alt-Tab key combination when
  cl_altTab is enabled.  Some users may choose to disable cl_altTab, and bind
  another key to 'set r_minimize 1'.

win_fastModeChange [0|1] (default 0)
  When set to non-0, the video display resolution change will not require a
  vid_restart on win32.  This can cause crashing or OpenGL context
  corruption on some drivers.  Unfortunately there doesn't seem to be a 
  good way to automatically detect if the driver handles this.

This still needs a lot of testing.

Because SDL_WM_IconfifyWindow() and SDL_WM_ToggleFullScreen() are
non-functional for Mac OS X, vid_restart is used.  SDL with X11 can do the
mode change immediately (like win32 with win_fastModeChange enabled)
Comment 10 Ryan C. Gordon 2007-05-21 11:22:10 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.

Comment 11 Erik 2007-06-21 10:06:24 EDT
TJW, just wanted to say this patch seems to work very well for most people. In the next build of ioUrbanTerror, I'm gonna enable win_fastmodechange by default, since most people like it so much.
Comment 12 Tony J. White 2007-09-18 23:39:45 EDT
Created attachment 1518 [details]
svn1183 alt-tab patch


modified for unified SDL.

r_minimize - set this cvar to non-zero to immediatly minimize ioquake3
             for example, "/bind o set r_minimize 1" (the o stands for
             "omg my boss is coming into the room")

cl_altTab  - set this to 1 (the default) to support Alt-Tab on all platforms
             set it to non-1 and the Alt-Tab key combination will be disabled
             on all platforms (even win32 when ioq3 has focus).

On Mac OS X, this is problematic because of a broken SDL_WM_IconfiyWindow() function in SDL <= 1.2.12 (see http://bugzilla.libsdl.org/show_bug.cgi?id=492)
But since we provide the Mac SDL .dylib in SVN anyway, it could just be updated.
Comment 13 Tim Angus 2007-09-19 05:34:43 EDT
I wonder if there was some way that r_minimize could be made to have persistent state, rather than acting as what is effectively a semaphore. I understand why you've done it this way (there is no obvious portable way to check when you're /not/ minimized), but I think this isn't a good way to use cvars.
Comment 14 Zachary J. Slater 2010-10-19 02:26:12 EDT
Well?
Comment 15 Thilo Schulz 2011-03-07 18:58:14 EST
I'd say: SDL problem. Furthermore we recently introduced /minimize command. As there doesn't seem to be any activity here, I'm going to close this bug.