| Summary: | [patch] Display hotplugging | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Eric Wasylishen <ewasylishen> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Cocoa display hotplugging patch
Cocoa + win32 display hotplugging patch |
||
Created attachment 2808 [details] Cocoa display hotplugging patch Here is a first attempt at a Cocoa implementation. To test it out I used this patch: https://bugzilla.libsdl.org/show_bug.cgi?id=3646 which adds Option+Left and Option+Right keybindings to the test apps to move the window between displays. And for X11, I think it's RRScreenChangeNotify we'll need to listen for? https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n1715 It'd be nice if SDL events were posted when this happens as well. I can pretty easily implement the iOS backend code for this, if the functionality goes into SDL. Created attachment 2814 [details]
Cocoa + win32 display hotplugging patch
Yeah, an SDL event for when this happens would be good to add.
Another thing not currently handled by my patch is if the display dimensions change when a SDL window is currently fullscreen-desktop on it (e.g. if the display is rotated or the resolution is changed.)
Added a win32 implementation.
The Windows patch needs some more work; it's causing a crash when doing fullscreen mode changes. It seems that WM_DISPLAYCHANGE gets delivered to the helper window during the ChangeDisplaySettingsEx call in WIN_SetDisplayMode. This results in all of the SDL_VideoDisplay objects being freed and the displays re-enumerated, but WIN_SetDisplayMode still has a stale pointer to one of the freed displays which it tries to dereference. so, I'll need to do something more involved than just freeing displays and re-creating them.. maybe setting a flag on the SDL_VideoDisplay to mark it as "removed". |
Would be nice to have. e.g. you currently can't plug in a display, drag an SDL window to it, and go fullscreen on the new display. Seems pretty easy to do. e.g. add a SDL_ClearVideoDisplays function to SDL_video.c that does: _this->displays = NULL; _this->num_displays = 0; Then add OS-specific handlers that detect a configuration change, and clear + re-add all of the displays. - Windows: handle WM_DISPLAYCHANGE, probably in the helper window created in SDL_HelperWindowCreate? - macOS: CGDisplayRegisterReconfigurationCallback