From 980e552eba2a622fafb771c34296dbbb67375779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 3 Aug 2025 09:22:47 +0800 Subject: [PATCH] Display: allow `"compactType": null`; improve json schema --- doc/json_schema.json | 35 +++++++++++++++++++++++++++-------- src/modules/display/display.c | 5 +++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index b742f0afb..45c4ef283 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -2031,15 +2031,34 @@ "const": "display" }, "compactType": { - "enum": [ - "none", - "original", - "scaled", - "original-with-refresh-rate", - "scaled-with-refresh-rate" - ], "description": "Set if all displays should be printed in one line", - "default": "none" + "oneOf": [ + { + "const": null, + "description": "Disable compact mode" + }, + { + "const": "none", + "description": "Disable compact mode (kept for compatibility)" + }, + { + "const": "original", + "description": "Print original resolutions" + }, + { + "const": "scaled", + "description": "Print scaled resolutions" + }, + { + "const": "original-with-refresh-rate", + "description": "Print original resolutions with refresh rates" + }, + { + "const": "scaled-with-refresh-rate", + "description": "Print scaled resolutions with refresh rates" + } + ], + "default": null }, "preciseRefreshRate": { "description": "Set if decimal refresh rates should not be rounded into integers when printing", diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 914af6ca6..e6ffca361 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -267,6 +267,10 @@ void ffParseDisplayJsonObject(FFDisplayOptions* options, yyjson_val* module) continue; if (unsafe_yyjson_equals_str(key, "compactType")) + { + if (yyjson_is_null(val)) + options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE; + else { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { @@ -281,6 +285,7 @@ void ffParseDisplayJsonObject(FFDisplayOptions* options, yyjson_val* module) ffPrintError(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); else options->compactType = (FFDisplayCompactType) value; + } continue; }