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 3205 - New window and glcontext swap after toggle to fullscreen mode causes input focus loss
Summary: New window and glcontext swap after toggle to fullscreen mode causes input fo...
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows (All)
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-10 09:50 UTC by nemo.nixto
Modified: 2016-01-08 17:16 UTC (History)
1 user (show)

See Also:


Attachments
Code. (2.80 KB, text/plain)
2015-12-10 09:50 UTC, nemo.nixto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nemo.nixto 2015-12-10 09:50:51 UTC
Created attachment 2334 [details]
Code.

I'm working on a windows 10 machine but i've tested on a windows 7 and an 8.1 and they all have the same result.

Switching from windowed to fullscreen followed by a new window and glcontext swap used to preserve keyboard input focus in SDL2.dll version 2.0.1.

The current version (2.0.3) and 2.0.4 of the dll loses input focus.

Additionally, SDL_GetWindowFlags reports that the window does indeed have INPUT_FOCUS, when it clearly doesn't.

I tried to force focus using SDL_RaiseWindow, SDL_SetWindowGrab(SDL_TRUE) and eventually using Window's SetFocus() with HWND provided by SDL. No dice.

I've attached the code.

Color in the window changes on pressing space.
Fullscreen toggles when pressing return.
Comment 1 Ryan C. Gordon 2015-12-29 05:20:36 UTC
Yikes, I'm not sure this approach was ever meant to work reliably (fullscreen exclusive window with fullscreen_desktop window built on top of it, the second steals the first's GL context then the first window is destroyed). Is there a real-life scenario where you need this sort of thing? We might have to mark this WONTFIX in any case.

That being said, I'm wondering if the problem you're seeing isn't a loss of input focus, but a failure to get a working GL context on the second window, due to some changes we might have made to context handling. Does the SDL_PollEvent() call really never get SDL_KEYDOWN events after you press return, or does it simply never manage to draw anything, so it looks like it never got a key press again?

--ryan.
Comment 2 nemo.nixto 2016-01-07 22:54:45 UTC
Sorry for the delay in response, Holidays 'n all, (Happy New Year btw:)

The reason for all of this is to change screen res without having to remake all the textures and display lists (yes, i still use display lists ... i'm old and set in my ways). If there is a preferred method, i'm all ears.

The SDL_WINDOW_FULLSCREEN_DESKTOP was actually malfunctioning so i went back to just the SDL_WINDOW_FULLSCREEN.

As for the SDL_Pollevent(), it does indeed draw in the actual game it gets input from controllers and if you aren't using a keyboard you don't notice.

-andrew
Comment 3 Ryan C. Gordon 2016-01-08 11:59:15 UTC
(In reply to nemo.nixto from comment #2)
> The reason for all of this is to change screen res without having to remake
> all the textures and display lists (yes, i still use display lists ... i'm
> old and set in my ways). If there is a preferred method, i'm all ears.

You can change the screen res in SDL2 without losing your existing window or GL context (this was not true in SDL 1.2).

--ryan.
Comment 4 Ryan C. Gordon 2016-01-08 12:02:26 UTC
(In reply to Ryan C. Gordon from comment #3)
> You can change the screen res in SDL2 without losing your existing window or
> GL context (this was not true in SDL 1.2).

To clarify: SDL_SetWindowDisplayMode() would be an option, or you could toggle to windowed mode with SDL_SetWindowFullscreen(win, 0), change the window size with SDL_SetWindowSize(), and change it back to fullscreen.

(or some combination therein.) SDL_WINDOW_FULLSCREEN_DESKTOP mode removes your control over the resolution of the display, but you can still force the resolution with SDL_WINDOW_FULLSCREEN.

--ryan.
Comment 5 nemo.nixto 2016-01-08 14:25:53 UTC
Thank you!

You are correct - yahoo! It is a good New Year after all :)


A
Comment 6 Ryan C. Gordon 2016-01-08 17:16:06 UTC
(In reply to nemo.nixto from comment #5)
> You are correct - yahoo! It is a good New Year after all :)

:)

I'm going to mark this as WONTFIX, since it might be something that we do wrong with two fullscreen windows competing, but it's not worth fixing in that case. Enjoy your working single window.  :)

--ryan.