SDL
SDL copied to clipboard
[macOS] Can’t add or remove displays
I discovered yesterday that after init, displays added or removed are ignored on macOS. SDL_GetNumDisplayModes() only provides the number at init. And I think new displays cannot be accessed.
Perhaps I'm missing something here? In SDL_cocoamodes.m (version 2.26.5):
SDL_AddVideoDisplay()is only called on initSDL_DelVideoDisplay()is never called
I’m not sure of the correct way to start adding this. Maybe use CGDisplayRegisterReconfigurationCallback to detect the change?
That seems like a good place to start. @icculus, thoughts?
@RustyMoyher, did you try that? Do you have a PR for this?
No, I didn't make any progress on this, beyond just testing CGDisplayRegisterReconfigurationCallback to receive notifications.
static void displayChanged(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags, void *userInfo)
{
if (flags & kCGDisplayAddFlag) {
// createDisplayConnectedEvent
}
if (flags & kCGDisplayRemoveFlag) {
// createDisplayDisconnectedEvent
}
}
...
CGDisplayRegisterReconfigurationCallback(displayChanged, NULL);
Okay, thanks!
@mikela-valve, relevant for your interests!