From 4bde3afe8a7e168235307f231a4155afac900889 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 17 Jun 2023 22:33:41 +0800 Subject: [PATCH] OpenGL: change option key `type` to `library` To avoid conflict with JSON config `type` --- src/data/config_user.txt | 2 +- src/data/help.txt | 11 +++++----- src/detection/opengl/opengl_linux.c | 6 +++--- src/modules/opengl/opengl.c | 31 ++++++++++++++++------------- src/modules/opengl/option.h | 14 ++++++------- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 2ccb2e8b9..91902dedd 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -216,7 +216,7 @@ # Sets with opengl context creation library to use # Must be either auto, egl, glx or osmesa # Default is auto. -#--opengl-type auto +#--opengl-library auto # GPU hide options # Sets weather to hide certain gpu types diff --git a/src/data/help.txt b/src/data/help.txt index 3008888b7..6d7bd3f45 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -115,14 +115,13 @@ Module specific options: --bluetooth-show-disconnected: : Set if disconnected bluetooth devices should be printed. Default is false --display-compact-type: : Set if all displays should be printed in one line. Default is none --display-detect-name: : Set if display name should be detected and printed (if supported). Default is false - --display-precise-refresh-rate: :Set if decimal refresh rates should not be rounded into integers when printing + --display-precise-refresh-rate: :Set if decimal refresh rates should not be rounded into integers when printing. Default is true --sound-type: : Set what type of sound devices should be printed. Should be either main, active or all. Default is main --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ --cpu-temp : Detect and display CPU temperature if supported. Default is false --gpu-temp : Detect and display GPU temperature if supported. Default is false --gpu-force-vulkan : Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false - --gpu-hide-integrated : Hide integrated GPU if supported. Default is false - --gpu-hide-discrete : Hide discrete GPU if supported. Default is false + --gpu-hide-type : Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none --battery-temp : Detect and display Battery temperature if supported. Default is false --localip-show-ipv4 : Show IPv4 addresses in local ip module. Default is true --localip-show-ipv6 : Show IPv6 addresses in local ip module. Default is false @@ -135,10 +134,10 @@ Module specific options: --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use - --opengl-type : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto + --opengl-library : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others - --command-key : Set the module key to display, can be specified mulitple times - --command-text : Set the command text to be executed, can be specified mulitple times + --command-key : Set the module key to display + --command-text : Set the command text to be executed Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index e1127700b..9a4f42bec 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -318,7 +318,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) { #if FF_HAVE_GL - if(instance->config.openGL.type == FF_OPENGL_TYPE_GLX) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_GLX) { #ifdef FF_HAVE_GLX return glxPrint(instance, result); @@ -327,7 +327,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.openGL.type == FF_OPENGL_TYPE_EGL) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_EGL) { #ifdef FF_HAVE_EGL return eglPrint(instance, result); @@ -336,7 +336,7 @@ const char* ffDetectOpenGL(FFinstance* instance, FFOpenGLResult* result) #endif } - if(instance->config.openGL.type == FF_OPENGL_TYPE_OSMESA) + if(instance->config.openGL.library == FF_OPENGL_LIBRARY_OSMESA) { #ifdef FF_HAVE_OSMESA return osMesaPrint(instance, result); diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 7272cd31d..46924ceaa 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -47,7 +47,7 @@ void ffInitOpenGLOptions(FFOpenGLOptions* options) ffOptionInitModuleArg(&options->moduleArgs); #if defined(__linux__) || defined(__FreeBSD__) - options->type = FF_OPENGL_TYPE_AUTO; + options->library = FF_OPENGL_LIBRARY_AUTO; #endif } @@ -59,13 +59,16 @@ bool ffParseOpenGLCommandOptions(FFOpenGLOptions* options, const char* key, cons return true; #if defined(__linux__) || defined(__FreeBSD__) - options->type = (FFOpenGLType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { - { "auto", FF_OPENGL_TYPE_AUTO }, - { "egl", FF_OPENGL_TYPE_EGL }, - { "glx", FF_OPENGL_TYPE_GLX }, - { "osmesa", FF_OPENGL_TYPE_OSMESA }, - {} - }); + if (strcasecmp(key, "library") == 0) + { + options->library = (FFOpenGLLibrary) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { + { "auto", FF_OPENGL_LIBRARY_AUTO }, + { "egl", FF_OPENGL_LIBRARY_EGL }, + { "glx", FF_OPENGL_LIBRARY_GLX }, + { "osmesa", FF_OPENGL_LIBRARY_OSMESA }, + {} + }); + } #endif return false; @@ -95,20 +98,20 @@ void ffParseOpenGLJsonObject(FFinstance* instance, yyjson_val* module) continue; #if defined(__linux__) || defined(__FreeBSD__) - if (strcasecmp(key, "type") == 0) + if (strcasecmp(key, "library") == 0) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { - { "auto", FF_OPENGL_TYPE_AUTO }, - { "egl", FF_OPENGL_TYPE_EGL }, - { "glx", FF_OPENGL_TYPE_GLX }, - { "osmesa", FF_OPENGL_TYPE_OSMESA }, + { "auto", FF_OPENGL_LIBRARY_AUTO }, + { "egl", FF_OPENGL_LIBRARY_EGL }, + { "glx", FF_OPENGL_LIBRARY_GLX }, + { "osmesa", FF_OPENGL_LIBRARY_OSMESA }, {}, }); if (error) ffPrintError(instance, FF_OPENGL_MODULE_NAME, 0, &options.moduleArgs, "Invalid %s value: %s", key, error); else - options.type = (FFOpenGLType) value; + options.library = (FFOpenGLLibrary) value; continue; } #endif diff --git a/src/modules/opengl/option.h b/src/modules/opengl/option.h index 72e29c980..712374d93 100644 --- a/src/modules/opengl/option.h +++ b/src/modules/opengl/option.h @@ -5,13 +5,13 @@ #include "common/option.h" #if defined(__linux__) || defined(__FreeBSD__) -typedef enum FFOpenGLType +typedef enum FFOpenGLLibrary { - FF_OPENGL_TYPE_AUTO, - FF_OPENGL_TYPE_EGL, - FF_OPENGL_TYPE_GLX, - FF_OPENGL_TYPE_OSMESA -} FFOpenGLType; + FF_OPENGL_LIBRARY_AUTO, + FF_OPENGL_LIBRARY_EGL, + FF_OPENGL_LIBRARY_GLX, + FF_OPENGL_LIBRARY_OSMESA +} FFOpenGLLibrary; #endif typedef struct FFOpenGLOptions @@ -20,6 +20,6 @@ typedef struct FFOpenGLOptions FFModuleArgs moduleArgs; #if defined(__linux__) || defined(__FreeBSD__) - FFOpenGLType type; + FFOpenGLLibrary library; #endif } FFOpenGLOptions;