SDL icon indicating copy to clipboard operation
SDL copied to clipboard

[macOS] Can’t add or remove displays

Open RustyMoyher opened this issue 2 years ago • 1 comments

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 init
  • SDL_DelVideoDisplay() is never called

I’m not sure of the correct way to start adding this. Maybe use CGDisplayRegisterReconfigurationCallback to detect the change?

RustyMoyher avatar May 31 '23 14:05 RustyMoyher

That seems like a good place to start. @icculus, thoughts?

slouken avatar May 31 '23 15:05 slouken

@RustyMoyher, did you try that? Do you have a PR for this?

slouken avatar Nov 08 '23 05:11 slouken

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);

RustyMoyher avatar Nov 08 '23 14:11 RustyMoyher

Okay, thanks!

slouken avatar Nov 08 '23 16:11 slouken

@mikela-valve, relevant for your interests!

slouken avatar May 21 '24 18:05 slouken