diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cb37bc40..e685a13b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Features: * Support foot terminal (#431, Linux) * Support cursor size detection on Windows (Cursor, Windows) * Support cursor detection on macOS (Cursor, macOS) -* Support display name and decimal refresh rate detection (Display, macOS / Windows) +* Support display name, display type and decimal refresh rate detection (Display, macOS / Windows) Bugfixes: * Fix date time format diff --git a/src/detection/displayserver/displayserver.c b/src/detection/displayserver/displayserver.c index eeaad5dfc..270f4a93c 100644 --- a/src/detection/displayserver/displayserver.c +++ b/src/detection/displayserver/displayserver.c @@ -1,7 +1,15 @@ #include "displayserver.h" #include "detection/internal.h" -bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, double refreshRate, uint32_t scaledWidth, uint32_t scaledHeight, FFstrbuf* name) +bool ffdsAppendDisplay( + FFDisplayServerResult* result, + uint32_t width, + uint32_t height, + double refreshRate, + uint32_t scaledWidth, + uint32_t scaledHeight, + FFstrbuf* name, + FFDisplayType type) { if(width == 0 || height == 0) return false; @@ -13,6 +21,7 @@ bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t h display->scaledWidth = scaledWidth; display->scaledHeight = scaledHeight; ffStrbufInitMove(&display->name, name); + display->type = type; return true; } diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index fde40a4c6..e75181b71 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -34,6 +34,12 @@ #define FF_WM_PROTOCOL_X11 "X11" #define FF_WM_PROTOCOL_WAYLAND "Wayland" +typedef enum FFDisplayType { + FF_DISPLAY_TYPE_UNKNOWN, + FF_DISPLAY_TYPE_BUILTIN, + FF_DISPLAY_TYPE_EXTERNAL, +} FFDisplayType; + typedef struct FFDisplayResult { uint32_t width; @@ -42,6 +48,7 @@ typedef struct FFDisplayResult uint32_t scaledWidth; uint32_t scaledHeight; FFstrbuf name; + FFDisplayType type; } FFDisplayResult; typedef struct FFDisplayServerResult @@ -56,6 +63,15 @@ typedef struct FFDisplayServerResult } FFDisplayServerResult; const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance); -bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, double refreshRate, uint32_t scaledWidth, uint32_t scaledHeight, FFstrbuf* name); + +bool ffdsAppendDisplay( + FFDisplayServerResult* result, + uint32_t width, + uint32_t height, + double refreshRate, + uint32_t scaledWidth, + uint32_t scaledHeight, + FFstrbuf* name, + FFDisplayType type); #endif diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 5d07e4263..b3b8e78b4 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -58,7 +58,8 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) refreshRate, (uint32_t)CGDisplayModeGetWidth(mode), (uint32_t)CGDisplayModeGetHeight(mode), - &name + &name, + CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL ); CGDisplayModeRelease(mode); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 34fe40f82..4c8601b0d 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -93,7 +93,12 @@ static void detectDisplays(FFDisplayServerResult* ds, bool detectName) path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator, data.width, data.height, - &name); + &name, + path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || + path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || + path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED + ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL + ); } } } diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 55f7ea46f..edab77051 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -126,7 +126,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist display.refreshRate / 1000.0, (uint32_t) (display.width / display.scale), (uint32_t) (display.height / display.scale), - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); ffThreadMutexUnlock(&mutex); diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index e89b32545..89fc1ae00 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -118,7 +118,8 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result) 0, (uint32_t) iterator.data->width_in_pixels, (uint32_t) iterator.data->height_in_pixels, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); ffxcb_screen_next(&iterator); } @@ -183,7 +184,8 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo refreshRate == 0 ? data->defaultRefreshRate : refreshRate, (uint32_t) modeInfo->width, (uint32_t) modeInfo->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } @@ -221,7 +223,8 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc) data->defaultRefreshRate, (uint32_t) crtcInfoReply->width, (uint32_t) crtcInfoReply->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); free(crtcInfoReply); @@ -267,7 +270,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* data->defaultRefreshRate, (uint32_t) monitor->width, (uint32_t) monitor->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } @@ -328,7 +332,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen) data->defaultRefreshRate, (uint32_t) screen->width_in_pixels, (uint32_t) screen->height_in_pixels, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 0df2bb350..f1dcbeabc 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -83,7 +83,8 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result) 0, (uint32_t) WidthOfScreen(screen), (uint32_t) HeightOfScreen(screen), - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } @@ -142,7 +143,8 @@ static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo) refreshRate == 0 ? data->defaultRefreshRate : refreshRate, (uint32_t) modeInfo->width, (uint32_t) modeInfo->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } @@ -174,7 +176,8 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc) data->defaultRefreshRate, (uint32_t) crtcInfo->width, (uint32_t) crtcInfo->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); data->ffXRRFreeCrtcInfo(crtcInfo); @@ -211,7 +214,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo) data->defaultRefreshRate, (uint32_t) monitorInfo->width, (uint32_t) monitorInfo->height, - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } @@ -266,7 +270,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen) data->defaultRefreshRate, (uint32_t) WidthOfScreen(screen), (uint32_t) HeightOfScreen(screen), - NULL + NULL, + FF_DISPLAY_TYPE_UNKNOWN ); } diff --git a/src/modules/display.c b/src/modules/display.c index 1c55d2f19..f4dddbe1f 100644 --- a/src/modules/display.c +++ b/src/modules/display.c @@ -3,7 +3,7 @@ #include "detection/displayserver/displayserver.h" #define FF_DISPLAY_MODULE_NAME "Display" -#define FF_DISPLAY_NUM_FORMAT_ARGS 6 +#define FF_DISPLAY_NUM_FORMAT_ARGS 7 void ffPrintDisplay(FFinstance* instance) { @@ -44,20 +44,23 @@ void ffPrintDisplay(FFinstance* instance) { FFDisplayResult* result = ffListGet(&dsResult->displays, i); uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1); + const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external"; if(instance->config.display.outputFormat.length == 0) { - if(result->name.length) + if(result->name.length || (moduleIndex > 0 && displayType)) { ffStrbufClear(&key); if(instance->config.display.key.length == 0) { - ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.chars); + ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, result->name.length ? result->name.chars : displayType); } else { ffParseFormatString(&key, &instance->config.display.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name} + {FF_FORMAT_ARG_TYPE_UINT, &i}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, }); } ffPrintLogoAndKey(instance, key.chars, 0, NULL); @@ -93,6 +96,7 @@ void ffPrintDisplay(FFinstance* instance) {FF_FORMAT_ARG_TYPE_UINT, &result->scaledWidth}, {FF_FORMAT_ARG_TYPE_UINT, &result->scaledHeight}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, }); }