mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Brightness: improve performance
This commit is contained in:
@@ -127,10 +127,22 @@ static const char* detectWithDdcci(FFlist* result)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer)
|
||||
{
|
||||
FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays)
|
||||
{
|
||||
if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* ffDetectBrightness(FFlist* result)
|
||||
{
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
detectWithDisplayServices(displayServer, result);
|
||||
|
||||
if (hasBuiltinDisplay(displayServer))
|
||||
detectWithDisplayServices(displayServer, result);
|
||||
|
||||
if (instance.config.allowSlowOperations && displayServer->displays.length > result->length)
|
||||
detectWithDdcci(result);
|
||||
|
||||
@@ -58,12 +58,24 @@ static char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer)
|
||||
{
|
||||
FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays)
|
||||
{
|
||||
if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
const char* ffDetectBrightness(FFlist* result)
|
||||
{
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
|
||||
detectWithWmi(result);
|
||||
if (hasBuiltinDisplay(displayServer))
|
||||
detectWithWmi(result);
|
||||
|
||||
if (instance.config.allowSlowOperations && result->length < displayServer->displays.length)
|
||||
detectWithDdcci(displayServer, result);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user