We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5508 - [PATCH] Provide default Alt+Tab handling with keyboard grab enabled
Summary: [PATCH] Provide default Alt+Tab handling with keyboard grab enabled
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: x86 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-28 02:50 UTC by Cameron Gutman
Modified: 2021-01-30 20:33 UTC (History)
0 users

See Also:


Attachments
Patch to minimize on Alt+Tab (2.67 KB, patch)
2021-01-28 02:51 UTC, Cameron Gutman
Details | Diff
Patch to minimize on Alt+Tab v2 (2.73 KB, patch)
2021-01-30 03:15 UTC, Cameron Gutman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2021-01-28 02:50:46 UTC
Per our previous discussion, this patch adds logic to minimize the window on Alt+Tab if:
- The window has keyboard grab
- The window is full-screen
- SDL_HINT_NO_GRABBED_ALT_TAB_HANDLER is 0 or unset

I'm not sure if there's a different place you'd rather me put this code, but I stuck it in SDL_SendKeyboardKeyInternal().

I went with minimizing the window instead of something like manually releasing the keyboard grab because I figure it will be less disturbing to the app. If we manually released the keyboard grab, the application would have to figure out that the grab disappeared from under it and regrab when it gains focus again. It would also require the user to press Alt+Tab twice to get the desired behavior, since the first would be eaten by the keyboard grab. By using minimize, we can let the focus leaving naturally release the grab and regrab on subsequent focus gain.
Comment 1 Cameron Gutman 2021-01-28 02:51:28 UTC
Created attachment 4724 [details]
Patch to minimize on Alt+Tab
Comment 2 Sam Lantinga 2021-01-29 16:57:03 UTC
Can you change the hint to something like SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, and default it to true?
Comment 3 Cameron Gutman 2021-01-30 03:15:30 UTC
Created attachment 4735 [details]
Patch to minimize on Alt+Tab v2

Sure, how's this?
Comment 4 Sam Lantinga 2021-01-30 20:33:20 UTC
Looks good!
https://hg.libsdl.org/SDL/rev/66802b4fc7fa