mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Display (macOS): detect primary display
This commit is contained in:
@@ -10,7 +10,8 @@ bool ffdsAppendDisplay(
|
||||
uint32_t scaledHeight,
|
||||
uint32_t rotation,
|
||||
FFstrbuf* name,
|
||||
FFDisplayType type)
|
||||
FFDisplayType type,
|
||||
bool primary)
|
||||
{
|
||||
if(width == 0 || height == 0)
|
||||
return false;
|
||||
@@ -24,6 +25,7 @@ bool ffdsAppendDisplay(
|
||||
display->rotation = rotation;
|
||||
ffStrbufInitMove(&display->name, name);
|
||||
display->type = type;
|
||||
display->primary = primary;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ typedef struct FFDisplayResult
|
||||
FFstrbuf name;
|
||||
FFDisplayType type;
|
||||
uint32_t rotation;
|
||||
bool primary;
|
||||
} FFDisplayResult;
|
||||
|
||||
typedef struct FFDisplayServerResult
|
||||
@@ -75,6 +76,7 @@ bool ffdsAppendDisplay(
|
||||
uint32_t scaledHeight,
|
||||
uint32_t rotation,
|
||||
FFstrbuf* name,
|
||||
FFDisplayType type);
|
||||
FFDisplayType type,
|
||||
bool primary);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess)
|
||||
return;
|
||||
|
||||
CGDirectDisplayID primary = CGMainDisplayID();
|
||||
|
||||
for(uint32_t i = 0; i < screenCount; i++)
|
||||
{
|
||||
CGDirectDisplayID screen = screens[i];
|
||||
@@ -60,7 +62,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
(uint32_t)CGDisplayModeGetHeight(mode),
|
||||
(uint32_t)CGDisplayRotation(screen),
|
||||
&name,
|
||||
CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL
|
||||
CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL,
|
||||
screen == primary
|
||||
);
|
||||
CGDisplayModeRelease(mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user