Restore ability to alt+tab

Hello,
I am porting an application to SDL2, and I noticed that now it seems
that alt-tabbing has been forcibly prevented. Is there a way (including
source hack) to reenable it on common platforms (OSX, Widows, linux)?

Cheers.

Alt-tabbing should be working fine in SDL2. Could you perhaps give us a
little more information, such as a pastebin of your input-handling code or
a small example which exhibits the problem?

Alright, I’m going to carve out the input code, but I should clarify
first that I’m referring to fullscreen mode.Windowed mode still allows
alt+tab.On 04/27/2013 12:13 PM, Scott Percival wrote:

Alt-tabbing should be working fine in SDL2. Could you perhaps give us
a little more information, such as a pastebin of your input-handling
code or a small example which exhibits the problem?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Does the issue happen on all (relevant) platforms or only some?

2013/4/27, Lorenzo Pistone :> Alright, I’m going to carve out the input code, but I should clarify

first that I’m referring to fullscreen mode.Windowed mode still allows
alt+tab.

On 04/27/2013 12:13 PM, Scott Percival wrote:

Alt-tabbing should be working fine in SDL2. Could you perhaps give us
a little more information, such as a pastebin of your input-handling
code or a small example which exhibits the problem?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It happens on all the desktop platform. To b noted that alt+tabbing
(Cmd+tab, whatever) didn’t work in OSX with SDL1.2 too.

I checked the code (which is not mine), and I could find these relevant
calls.

In screen initialization:

SDL_CreateWindow(..., ...|SDL_WINDOW_INPUT_FOCUS);
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "0");
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");

In the input loop:

case SDL_WINDOWEVENT_FOCUS_GAINED:
     inputgrab(grabinput = true);
     break;
case SDL_WINDOWEVENT_FOCUS_LOST:
     inputgrab(grabinput = false);
     break;

inputgrab():

void inputgrab(bool on)
{
     if(on)
     {
         SDL_ShowCursor(SDL_FALSE);
         if(canrelativemouse)
         {
             if(SDL_SetRelativeMouseMode(SDL_TRUE) >= 0)
             {
                 SDL_SetWindowGrab(screen, SDL_TRUE);
                 relativemouse = true;
             }
             else
             {
                 SDL_SetWindowGrab(screen, SDL_FALSE);
                 canrelativemouse = false;
                 relativemouse = false;
             }
         }
     }
     else
     {
         SDL_ShowCursor(SDL_TRUE);
         if(relativemouse)
         {
             SDL_SetWindowGrab(screen, SDL_FALSE);
             SDL_SetRelativeMouseMode(SDL_FALSE);
             relativemouse = false;
         }
     }
}On 04/27/2013 12:50 PM, Sik the hedgehog wrote:

Does the issue happen on all (relevant) platforms or only some?

2013/4/27, Lorenzo Pistone <@Lorenzo_Pistone>:

Alright, I’m going to carve out the input code, but I should clarify
first that I’m referring to fullscreen mode.Windowed mode still allows
alt+tab.

On 04/27/2013 12:13 PM, Scott Percival wrote:

Alt-tabbing should be working fine in SDL2. Could you perhaps give us
a little more information, such as a pastebin of your input-handling
code or a small example which exhibits the problem?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I would suspect your SDL_WINDOWEVENT_FOCUS_LOST handler. Something similar has happened to me, because you only get events after they are already over and processed by the OS (meaning you do not have focus anymore at this point). In my case I tried to restore keyboard state when tabbing out of the application which in turn caused the app to be reactivated (like 2 out of 3 times for me).

Something in your inputgrab function probably has the same effect.