mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Common: get rid of detection/internal.h
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "cpu.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "displayserver.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
bool ffdsAppendDisplay(
|
||||
FFDisplayServerResult* result,
|
||||
@@ -36,7 +35,16 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds);
|
||||
|
||||
const FFDisplayServerResult* ffConnectDisplayServer()
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFDisplayServerResult,
|
||||
static FFDisplayServerResult result;
|
||||
if (result.displays.elementSize == 0)
|
||||
{
|
||||
ffStrbufInit(&result.wmProcessName);
|
||||
ffStrbufInit(&result.wmPrettyName);
|
||||
ffStrbufInit(&result.wmProtocolName);
|
||||
ffStrbufInit(&result.deProcessName);
|
||||
ffStrbufInit(&result.dePrettyName);
|
||||
ffListInit(&result.displays, sizeof(FFDisplayResult));
|
||||
ffConnectDisplayServerImpl(&result);
|
||||
);
|
||||
}
|
||||
return &result;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,8 @@ static bool detectWithGetprop(FFDisplayServerResult* ds)
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
{
|
||||
ffStrbufInitStatic(&ds->wmProcessName, "WindowManager");
|
||||
ffStrbufInitStatic(&ds->wmPrettyName, "Window Manager");
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0);
|
||||
ffStrbufSetStatic(&ds->wmProcessName, "WindowManager");
|
||||
ffStrbufSetStatic(&ds->wmPrettyName, "Window Manager");
|
||||
|
||||
if (!detectWithGetprop(ds))
|
||||
detectWithDumpsys(ds);
|
||||
|
||||
@@ -73,20 +73,11 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
FF_CFTYPE_AUTO_RELEASE CFMachPortRef port = CGWindowServerCreateServerPort();
|
||||
if (port)
|
||||
{
|
||||
ffStrbufInitStatic(&ds->wmProcessName, "WindowServer");
|
||||
ffStrbufInitStatic(&ds->wmPrettyName, "Quartz Compositor");
|
||||
}
|
||||
else
|
||||
{
|
||||
ffStrbufInit(&ds->wmProcessName);
|
||||
ffStrbufInit(&ds->wmPrettyName);
|
||||
ffStrbufSetStatic(&ds->wmProcessName, "WindowServer");
|
||||
ffStrbufSetStatic(&ds->wmPrettyName, "Quartz Compositor");
|
||||
}
|
||||
}
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufSetStatic(&ds->dePrettyName, "Aqua");
|
||||
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInitStatic(&ds->dePrettyName, "Aqua");
|
||||
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
|
||||
detectDisplays(ds);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ typedef struct FFMonitorInfo
|
||||
} FFMonitorInfo;
|
||||
|
||||
static CALLBACK BOOL MonitorEnumProc(
|
||||
HMONITOR hMonitor,
|
||||
FF_MAYBE_UNUSED HDC hdc,
|
||||
FF_MAYBE_UNUSED LPRECT lpRect,
|
||||
LPARAM lParam
|
||||
HMONITOR hMonitor,
|
||||
FF_MAYBE_UNUSED HDC hdc,
|
||||
FF_MAYBE_UNUSED LPRECT lpRect,
|
||||
LPARAM lParam
|
||||
)
|
||||
{
|
||||
FFlist* monitors = (FFlist*) lParam;
|
||||
@@ -145,20 +145,16 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
BOOL enabled;
|
||||
if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
|
||||
{
|
||||
ffStrbufInitStatic(&ds->wmProcessName, "dwm.exe");
|
||||
ffStrbufInitStatic(&ds->wmPrettyName, "Desktop Window Manager");
|
||||
ffStrbufSetStatic(&ds->wmProcessName, "dwm.exe");
|
||||
ffStrbufSetStatic(&ds->wmPrettyName, "Desktop Window Manager");
|
||||
}
|
||||
else
|
||||
{
|
||||
// `explorer.exe` only provides a subset of WM functions, as well as the taskbar and desktop icons.
|
||||
// While a window itself is drawn by kernel (GDI). Killing `explorer.exe` won't affect how windows are displayed generally.
|
||||
ffStrbufInitStatic(&ds->wmProcessName, "explorer.exe");
|
||||
ffStrbufInitStatic(&ds->wmPrettyName, "Internal");
|
||||
ffStrbufSetStatic(&ds->wmProcessName, "explorer.exe");
|
||||
ffStrbufSetStatic(&ds->wmPrettyName, "Internal");
|
||||
}
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffListInit(&ds->displays, sizeof(FFDisplayResult));
|
||||
|
||||
detectDisplays(ds);
|
||||
|
||||
|
||||
@@ -3,13 +3,6 @@
|
||||
|
||||
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
||||
{
|
||||
ffStrbufInit(&ds->wmProcessName);
|
||||
ffStrbufInit(&ds->wmPrettyName);
|
||||
ffStrbufInit(&ds->wmProtocolName);
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
|
||||
|
||||
if (instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE)
|
||||
{
|
||||
//We try wayland as our preferred display server, as it supports the most features.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "font.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
const char* ffDetectFontImpl(FFFontResult* font);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "gpu.h"
|
||||
#include "detection/internal.h"
|
||||
#include "detection/vulkan/vulkan.h"
|
||||
#include "detection/opengl/opengl.h"
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/thread.h"
|
||||
|
||||
#define FF_DETECTION_INTERNAL_GUARD(ResultType, ...) \
|
||||
static ResultType result; \
|
||||
static bool init = false; \
|
||||
if(init) \
|
||||
return &result; \
|
||||
init = true; \
|
||||
__VA_ARGS__; \
|
||||
return &result;
|
||||
@@ -1,11 +1,13 @@
|
||||
#include "media.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
void ffDetectMediaImpl(FFMediaResult* media);
|
||||
|
||||
const FFMediaResult* ffDetectMedia(void)
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFMediaResult,
|
||||
static FFMediaResult result;
|
||||
|
||||
if (result.error.chars == NULL)
|
||||
{
|
||||
ffStrbufInit(&result.error);
|
||||
ffStrbufInit(&result.playerId);
|
||||
ffStrbufInit(&result.player);
|
||||
@@ -14,10 +16,11 @@ const FFMediaResult* ffDetectMedia(void)
|
||||
ffStrbufInit(&result.album);
|
||||
ffStrbufInit(&result.url);
|
||||
ffStrbufInit(&result.status);
|
||||
|
||||
ffDetectMediaImpl(&result);
|
||||
|
||||
if(result.song.length == 0 && result.error.length == 0)
|
||||
ffStrbufAppendS(&result.error, "No media found");
|
||||
);
|
||||
}
|
||||
|
||||
return &result;
|
||||
}
|
||||
|
||||
+16
-4
@@ -1,11 +1,23 @@
|
||||
#include "os.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os);
|
||||
|
||||
const FFOSResult* ffDetectOS(void)
|
||||
{
|
||||
FF_DETECTION_INTERNAL_GUARD(FFOSResult,
|
||||
ffDetectOSImpl(&result)
|
||||
);
|
||||
static FFOSResult result;
|
||||
if (result.name.chars == NULL)
|
||||
{
|
||||
ffStrbufInit(&result.name);
|
||||
ffStrbufInit(&result.prettyName);
|
||||
ffStrbufInit(&result.id);
|
||||
ffStrbufInit(&result.version);
|
||||
ffStrbufInit(&result.versionID);
|
||||
ffStrbufInit(&result.codename);
|
||||
ffStrbufInit(&result.buildID);
|
||||
ffStrbufInit(&result.idLike);
|
||||
ffStrbufInit(&result.variant);
|
||||
ffStrbufInit(&result.variantID);
|
||||
ffDetectOSImpl(&result);
|
||||
}
|
||||
return &result;
|
||||
}
|
||||
|
||||
@@ -3,25 +3,17 @@
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
ffStrbufInitStatic(&os->name, "Android");
|
||||
ffStrbufSetStatic(&os->name, "Android");
|
||||
|
||||
ffStrbufInitStatic(&os->prettyName, "Android");
|
||||
ffStrbufSetStatic(&os->prettyName, "Android");
|
||||
|
||||
ffStrbufInitStatic(&os->id, "android");
|
||||
ffStrbufSetStatic(&os->id, "android");
|
||||
|
||||
ffStrbufInit(&os->version);
|
||||
ffSettingsGetAndroidProperty("ro.build.version.release", &os->version);
|
||||
|
||||
ffStrbufInit(&os->versionID);
|
||||
ffSettingsGetAndroidProperty("ro.build.version.release", &os->versionID);
|
||||
|
||||
ffStrbufInit(&os->codename);
|
||||
ffSettingsGetAndroidProperty("ro.build.version.codename", &os->codename);
|
||||
|
||||
ffStrbufInit(&os->buildID);
|
||||
ffSettingsGetAndroidProperty("ro.build.id", &os->buildID);
|
||||
|
||||
ffStrbufInit(&os->idLike);
|
||||
ffStrbufInit(&os->variant);
|
||||
ffStrbufInit(&os->variantID);
|
||||
}
|
||||
|
||||
@@ -98,18 +98,6 @@ static void parseOSXSoftwareLicense(FFOSResult* os)
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
ffStrbufInit(&os->name);
|
||||
ffStrbufInit(&os->version);
|
||||
ffStrbufInit(&os->buildID);
|
||||
ffStrbufInit(&os->id);
|
||||
ffStrbufInit(&os->prettyName);
|
||||
ffStrbufInit(&os->versionID);
|
||||
|
||||
ffStrbufInit(&os->codename);
|
||||
ffStrbufInit(&os->idLike);
|
||||
ffStrbufInit(&os->variant);
|
||||
ffStrbufInit(&os->variantID);
|
||||
|
||||
parseSystemVersion(os);
|
||||
|
||||
if(ffStrbufStartsWithIgnCaseS(&os->name, "MacOS"))
|
||||
|
||||
@@ -167,17 +167,6 @@ static void detectOS(FFOSResult* os)
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
ffStrbufInit(&os->name);
|
||||
ffStrbufInit(&os->prettyName);
|
||||
ffStrbufInit(&os->id);
|
||||
ffStrbufInit(&os->idLike);
|
||||
ffStrbufInit(&os->variant);
|
||||
ffStrbufInit(&os->variantID);
|
||||
ffStrbufInit(&os->version);
|
||||
ffStrbufInit(&os->versionID);
|
||||
ffStrbufInit(&os->codename);
|
||||
ffStrbufInit(&os->buildID);
|
||||
|
||||
detectOS(os);
|
||||
|
||||
if(ffStrbufIgnCaseEqualS(&os->id, "ubuntu"))
|
||||
|
||||
@@ -42,17 +42,6 @@ static const char* getOsNameByWinbrand(FFstrbuf* osName)
|
||||
extern "C"
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
ffStrbufInit(&os->name);
|
||||
ffStrbufInit(&os->prettyName);
|
||||
ffStrbufInit(&os->id);
|
||||
ffStrbufInit(&os->idLike);
|
||||
ffStrbufInit(&os->variant);
|
||||
ffStrbufInit(&os->variantID);
|
||||
ffStrbufInit(&os->version);
|
||||
ffStrbufInit(&os->versionID);
|
||||
ffStrbufInit(&os->codename);
|
||||
ffStrbufInit(&os->buildID);
|
||||
|
||||
if(getOsNameByWinbrand(&os->variant) && getOsNameByWmi(&os->variant))
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "packages.h"
|
||||
#include "detection/internal.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "terminalfont.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/processing.h"
|
||||
#include "detection/internal.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
|
||||
static void detectAlacritty(FFTerminalFontResult* terminalFont)
|
||||
|
||||
Reference in New Issue
Block a user