mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-07 05:34:20 +01:00
Common (Windows): adds a unique type for querying registry binary data
This commit is contained in:
@@ -6,6 +6,15 @@
|
||||
#include <windows.h>
|
||||
#include <shellscalingapi.h>
|
||||
|
||||
static inline void freeArgBuffer(FFArgBuffer* buffer)
|
||||
{
|
||||
if (buffer->data)
|
||||
free(buffer->data);
|
||||
buffer->data = NULL;
|
||||
buffer->length = 0;
|
||||
}
|
||||
#define FF_AUTO_FREE_ARG_BUFFER __attribute__((__cleanup__(freeArgBuffer)))
|
||||
|
||||
// http://undoc.airesoft.co.uk/user32.dll/IsThreadDesktopComposited.php
|
||||
BOOL WINAPI IsThreadDesktopComposited();
|
||||
BOOL WINAPI GetDpiForMonitorInternal(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT* dpiX, UINT* dpiY);
|
||||
@@ -41,8 +50,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
.id = path->targetInfo.id,
|
||||
},
|
||||
};
|
||||
FF_LIST_AUTO_DESTROY edid = ffListCreate(sizeof(uint8_t));
|
||||
|
||||
FF_AUTO_FREE_ARG_BUFFER FFArgBuffer edid = {};
|
||||
if(DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS)
|
||||
{
|
||||
wchar_t regPath[256] = L"SYSTEM\\CurrentControlSet\\Enum";
|
||||
@@ -70,7 +78,7 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
}
|
||||
else
|
||||
{
|
||||
ffListClear(&edid);
|
||||
edid.length = 0;
|
||||
if (targetName.flags.friendlyNameFromEdid)
|
||||
ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName);
|
||||
else
|
||||
|
||||
@@ -24,35 +24,31 @@ static void generateString(FFFontResult* font)
|
||||
ffStrbufAppendC(&font->display, ']');
|
||||
}
|
||||
|
||||
WINUSERAPI WINBOOL WINAPI ClassicSystemParametersInfoW(UINT uiAction,UINT uiParam,PVOID pvParam,UINT fWinIni);
|
||||
|
||||
const char* ffDetectFontImpl(FFFontResult* result)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hKey = NULL;
|
||||
if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics", &hKey, NULL))
|
||||
return "ffRegOpenKeyForRead(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed";
|
||||
|
||||
FF_LIST_AUTO_DESTROY CaptionFont = ffListCreate(sizeof(uint8_t));
|
||||
FF_LIST_AUTO_DESTROY MenuFont = ffListCreate(sizeof(uint8_t));
|
||||
FF_LIST_AUTO_DESTROY MessageFont = ffListCreate(sizeof(uint8_t));
|
||||
FF_LIST_AUTO_DESTROY StatusFont = ffListCreate(sizeof(uint8_t));
|
||||
LOGFONTW fonts[4];
|
||||
FFArgBuffer fontBuffers[4] = {
|
||||
{ .data = &fonts[0], .length = sizeof(fonts[0]) },
|
||||
{ .data = &fonts[1], .length = sizeof(fonts[1]) },
|
||||
{ .data = &fonts[2], .length = sizeof(fonts[2]) },
|
||||
{ .data = &fonts[3], .length = sizeof(fonts[3]) },
|
||||
};
|
||||
|
||||
if (!ffRegReadValues(hKey, 4, (FFRegValueArg[]) {
|
||||
FF_ARG(CaptionFont, L"CaptionFont"),
|
||||
FF_ARG(MenuFont, L"MenuFont"),
|
||||
FF_ARG(MessageFont, L"MessageFont"),
|
||||
FF_ARG(StatusFont, L"StatusFont"),
|
||||
FF_ARG(fontBuffers[0], L"CaptionFont"),
|
||||
FF_ARG(fontBuffers[1], L"MenuFont"),
|
||||
FF_ARG(fontBuffers[2], L"MessageFont"),
|
||||
FF_ARG(fontBuffers[3], L"StatusFont"),
|
||||
}, NULL))
|
||||
return "ffRegReadValues(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed";
|
||||
|
||||
FFlist* fonts[4] = { &CaptionFont, &MenuFont, &MessageFont, &StatusFont };
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(fonts); ++i)
|
||||
{
|
||||
if (fonts[i]->length < sizeof(LOGFONTW))
|
||||
continue;
|
||||
|
||||
LOGFONTW* logFont = (LOGFONTW*) fonts[i]->data;
|
||||
LOGFONTW* logFont = &fonts[i];
|
||||
|
||||
ffStrbufSetWS(&result->fonts[i], logFont->lfFaceName);
|
||||
if (logFont->lfHeight < 0)
|
||||
|
||||
Reference in New Issue
Block a user