Question about the display

Mac OSX specific forum
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 205
Joined: Thu Dec 28, 2023 9:04 pm

Question about the display

Post by rndrei »

How can I find out what mode the screen has? (Extended, mirror)
User avatar
mk-soft
Always Here
Always Here
Posts: 6500
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Question about the display

Post by mk-soft »

Over NSScreen: https://developer.apple.com/documentati ... guage=objc

And search forum at "nsscreen"
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
TI-994A
Addict
Addict
Posts: 2790
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Question about the display

Post by TI-994A »

There is a built-in function to determine if the display is being mirrored:

Code: Select all

ImportC ""
  CGMainDisplayID()
  CGDisplayIsInMirrorSet(displayId)
EndImport

If Not CGDisplayIsInMirrorSet(CGMainDisplayID())
  mirror$ = "not "
EndIf  

MessageRequester("Mac Main Display", "The screen is " + mirror$ + "being mirrored.")

But I'm not sure how to determine if the display has been extended. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
infratec
Always Here
Always Here
Posts: 7772
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Question about the display

Post by infratec »

Answer form ChatGPT:

Code: Select all

@import CoreGraphics;

BOOL isExtendedDesktop(void) {
    uint32_t count = 0;
    CGGetActiveDisplayList(0, NULL, &count);
    if (count <= 1) return NO;

    CGDirectDisplayID displays[count];
    CGGetActiveDisplayList(count, displays, &count);

    for (uint32_t i = 0; i < count; i++) {
        if (CGDisplayIsInMirrorSet(displays[i])) {
            return NO; // mirroring active
        }
    }
    return YES; // muliple displays, no mirroring => extended
}
Post Reply