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 4934 - Number of screens don't get updated
Summary: Number of screens don't get updated
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.10
Hardware: x86_64 Windows (All)
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.16
Depends on:
Blocks:
 
Reported: 2020-01-10 21:02 UTC by bugzilla
Modified: 2020-06-27 20:38 UTC (History)
1 user (show)

See Also:


Attachments
Possible fix, kinda hacky. (1.64 KB, application/mbox)
2020-01-10 21:02 UTC, bugzilla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugzilla 2020-01-10 21:02:06 UTC
Created attachment 4156 [details]
Possible fix, kinda hacky.

Overview:
When adding or removing a display SDL_GetNumVideoDisplays() doesn't change the number of displays, also resolutions don't change.

Steps to Reproduce:
1) Initialize the SDL System
2) SDL_GetNumVideoDisplays(); will return the active number of displays
3) Add or remove a display
4) Call SDL_GetNumVideoDisplays();

Actual Results:
It will still have the same number of displays in step 2 as in step 4

Expected Results:
It will have the new number of displays

Build Date & Hardware:
SDL2-2.0.10-win32-x64.zip and windows 10.

Additional Builds and Platforms:
Same happens for 32 bit, and all other windows versions

Additional Information:
Windows has an WindowProc message called WM_DISPLAYCHANGE to handle this.
Added is a patch that will fix it, but it's not clean, but we can't just remove all displays and then re-add them since SDL will close all windows.
Comment 1 bugzilla 2020-03-31 19:58:17 UTC
Do you need any additional details for this?
Comment 2 Ryan C. Gordon 2020-03-31 20:04:57 UTC
My concern is that we probably can't change this until we break ABI in 2.1, since GetNumVideoDisplays can't change if an app is in the middle of using it.

But I have to think through this more (including if we should _actually_ be concerned in 2.0 about a race condition on the extraordinary event of display setup changing).

We definitely shouldn't just pretend there's a 720p display there if one suddenly vanishes.

--ryan.
Comment 3 Sam Lantinga 2020-03-31 22:15:49 UTC
I think it's okay for us to change the number of displays and not worry about the race condition for now, as long as we cleanly return an error if we're passed a newly invalid index (which I think we do right now)
Comment 4 Ryan C. Gordon 2020-06-27 20:38:25 UTC
I'm going to bump this to 2.0.16. It's worth doing, but it's more involved than I want to mess with for this release.