mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-10 07:00:08 +01:00
Resolution: rename to display
This commit is contained in:
1 parent
65e2331979
commit
f4a58036fa
27 files changed
+91
-90
No files matched your search
@@ -19,15 +19,15 @@ uint32_t ffdsParseRefreshRate(int32_t refreshRate)
|
||||
return (uint32_t) refreshRate;
|
||||
}
|
||||
|
||||
bool ffdsAppendResolution(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate)
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate)
|
||||
{
|
||||
if(width == 0 || height == 0)
|
||||
return false;
|
||||
|
||||
FFResolutionResult* resolution = ffListAdd(&result->resolutions);
|
||||
resolution->width = width;
|
||||
resolution->height = height;
|
||||
resolution->refreshRate = refreshRate;
|
||||
FFDisplayResult* display = ffListAdd(&result->displays);
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
display->refreshRate = refreshRate;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFResolutionResult
|
||||
typedef struct FFDisplayResult
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t refreshRate;
|
||||
} FFResolutionResult;
|
||||
} FFDisplayResult;
|
||||
|
||||
typedef struct FFDisplayServerResult
|
||||
{
|
||||
@@ -20,13 +20,13 @@ typedef struct FFDisplayServerResult
|
||||
FFstrbuf deProcessName;
|
||||
FFstrbuf dePrettyName;
|
||||
FFstrbuf deVersion;
|
||||
FFlist resolutions; //List of FFResolutionResult
|
||||
FFlist displays; //List of FFDisplayResult
|
||||
} FFDisplayServerResult;
|
||||
|
||||
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
|
||||
|
||||
//Used internal
|
||||
uint32_t ffdsParseRefreshRate(int32_t refreshRate);
|
||||
bool ffdsAppendResolution(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate);
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate);
|
||||
|
||||
#endif
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <assert.h>
|
||||
#include <CoreGraphics/CGDirectDisplay.h>
|
||||
|
||||
static void detectResolution(FFDisplayServerResult* ds)
|
||||
static void detectDisplays(FFDisplayServerResult* ds)
|
||||
{
|
||||
CGDirectDisplayID screens[128];
|
||||
uint32_t screenCount;
|
||||
@@ -20,7 +20,7 @@ static void detectResolution(FFDisplayServerResult* ds)
|
||||
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(screen);
|
||||
if(mode)
|
||||
{
|
||||
ffdsAppendResolution(ds,
|
||||
ffdsAppendDisplay(ds,
|
||||
(uint32_t)CGDisplayModeGetWidth(mode),
|
||||
(uint32_t)CGDisplayModeGetHeight(mode),
|
||||
(uint32_t)CGDisplayModeGetRefreshRate(mode)
|
||||
@@ -84,6 +84,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
ffStrbufAppendS(&ds->deProcessName, "aqua");
|
||||
ffStrbufAppendS(&ds->dePrettyName, "Aqua");
|
||||
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 4);
|
||||
detectResolution(ds);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
|
||||
detectDisplays(ds);
|
||||
}
|
||||
@@ -10,5 +10,5 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
ffStrbufInitA(&ds->deProcessName, 0);
|
||||
ffStrbufInitA(&ds->dePrettyName, 0);
|
||||
ffStrbufInitA(&ds->deVersion, 0);
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 0);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffStrbufInit(&ds->deVersion);
|
||||
ffListInit(&ds->resolutions, sizeof(FFResolutionResult));
|
||||
ffListInit(&ds->displays, sizeof(FFDisplayResult));
|
||||
|
||||
DISPLAY_DEVICEW displayDevice = { .cb = sizeof(DISPLAY_DEVICEW) };
|
||||
for(DWORD devNum = 0; EnumDisplayDevicesW(NULL, devNum, &displayDevice, 0) != 0; ++devNum)
|
||||
@@ -34,7 +34,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
if(EnumDisplaySettingsW(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode) == 0)
|
||||
continue;
|
||||
|
||||
ffdsAppendResolution(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency);
|
||||
ffdsAppendDisplay(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency);
|
||||
}
|
||||
|
||||
//https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067
|
||||
|
||||
@@ -32,14 +32,14 @@ static void parseDRM(FFDisplayServerResult* result)
|
||||
continue;
|
||||
}
|
||||
|
||||
FFResolutionResult* resolution = ffListAdd(&result->resolutions);
|
||||
resolution->width = 0;
|
||||
resolution->height = 0;
|
||||
resolution->refreshRate = 0;
|
||||
FFDisplayResult* display = ffListAdd(&result->displays);
|
||||
display->width = 0;
|
||||
display->height = 0;
|
||||
display->refreshRate = 0;
|
||||
|
||||
int scanned = fscanf(modeFile, "%ux%u", &resolution->width, &resolution->height);
|
||||
if(scanned < 2 || resolution->width == 0 || resolution->height == 0)
|
||||
--result->resolutions.length;
|
||||
int scanned = fscanf(modeFile, "%ux%u", &display->width, &display->height);
|
||||
if(scanned < 2 || display->width == 0 || display->height == 0)
|
||||
--result->displays.length;
|
||||
|
||||
fclose(modeFile);
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
@@ -57,31 +57,31 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
ffStrbufInit(&ds->deProcessName);
|
||||
ffStrbufInit(&ds->dePrettyName);
|
||||
ffStrbufInit(&ds->deVersion);
|
||||
ffListInitA(&ds->resolutions, sizeof(FFResolutionResult), 4);
|
||||
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
|
||||
|
||||
//We try wayland as our prefered display server, as it supports the most features.
|
||||
//This method can't detect the name of our WM / DE
|
||||
ffdsConnectWayland(instance, ds);
|
||||
|
||||
//Try the x11 libs, from most feature rich to least.
|
||||
//We use the resolution list to detect if a connection is needed.
|
||||
//They respect wmProtocolName, and only detect resolution if it is set.
|
||||
//We use the display list to detect if a connection is needed.
|
||||
//They respect wmProtocolName, and only detect display if it is set.
|
||||
|
||||
if(ds->resolutions.length == 0)
|
||||
if(ds->displays.length == 0)
|
||||
ffdsConnectXcbRandr(instance, ds);
|
||||
|
||||
if(ds->resolutions.length == 0)
|
||||
if(ds->displays.length == 0)
|
||||
ffdsConnectXrandr(instance, ds);
|
||||
|
||||
if(ds->resolutions.length == 0)
|
||||
if(ds->displays.length == 0)
|
||||
ffdsConnectXcb(instance, ds);
|
||||
|
||||
if(ds->resolutions.length == 0)
|
||||
if(ds->displays.length == 0)
|
||||
ffdsConnectXlib(instance, ds);
|
||||
|
||||
//This resolution detection method is display server independent.
|
||||
//This display detection method is display server independent.
|
||||
//Use it if all connections failed
|
||||
if(ds->resolutions.length == 0)
|
||||
if(ds->displays.length == 0)
|
||||
parseDRM(ds);
|
||||
|
||||
//This fills in missing information about WM / DE by using env vars and iterating processes
|
||||
|
||||
@@ -59,7 +59,7 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
|
||||
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
|
||||
ffThreadMutexLock(&mutex);
|
||||
|
||||
FFResolutionResult* result = ffListAdd(wldata->results);
|
||||
FFDisplayResult* result = ffListAdd(wldata->results);
|
||||
|
||||
ffThreadMutexUnlock(&mutex);
|
||||
|
||||
@@ -136,7 +136,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
return false;
|
||||
}
|
||||
|
||||
data.results = &result->resolutions;
|
||||
data.results = &result->displays;
|
||||
|
||||
struct wl_registry_listener registry_listener = {
|
||||
.global = waylandGlobalAddListener,
|
||||
@@ -151,7 +151,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
ffwl_display_disconnect(display);
|
||||
dlclose(wayland);
|
||||
|
||||
//We successfully connected to wayland and detected the resolution.
|
||||
//We successfully connected to wayland and detected the display.
|
||||
//So we can set set the session type to wayland.
|
||||
//This is used as an indicator that we are running wayland by the x11 backends.
|
||||
ffStrbufSetS(&result->wmProtocolName, FF_DISPLAYSERVER_PROTOCOL_WAYLAND);
|
||||
|
||||
@@ -115,7 +115,7 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
|
||||
while(iterator.rem > 0)
|
||||
{
|
||||
ffdsAppendResolution(
|
||||
ffdsAppendDisplay(
|
||||
result,
|
||||
(uint32_t) iterator.data->width_in_pixels,
|
||||
(uint32_t) iterator.data->height_in_pixels,
|
||||
@@ -180,7 +180,7 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
|
||||
modeInfo->dot_clock / (uint32_t) (modeInfo->htotal * modeInfo->vtotal)
|
||||
));
|
||||
|
||||
return ffdsAppendResolution(
|
||||
return ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) modeInfo->width,
|
||||
(uint32_t) modeInfo->height,
|
||||
@@ -190,7 +190,7 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
|
||||
|
||||
static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode)
|
||||
{
|
||||
//We do the check here, because we want the best fallback resolution if this call failed
|
||||
//We do the check here, because we want the best fallback display if this call failed
|
||||
if(data->screenResources == NULL)
|
||||
return false;
|
||||
|
||||
@@ -215,7 +215,7 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc)
|
||||
return false;
|
||||
|
||||
bool res = xcbRandrHandleMode(data, crtcInfoReply->mode);
|
||||
res = res ? true : ffdsAppendResolution(
|
||||
res = res ? true : ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) crtcInfoReply->width,
|
||||
(uint32_t) crtcInfoReply->height,
|
||||
@@ -258,7 +258,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
data->ffxcb_randr_output_next(&outputIterator);
|
||||
};
|
||||
|
||||
return foundOutput ? true : ffdsAppendResolution(
|
||||
return foundOutput ? true : ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) monitor->width,
|
||||
(uint32_t) monitor->height,
|
||||
@@ -316,7 +316,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
return;
|
||||
|
||||
//If detetction failed, fallback to screen = monitor, like in the libxcb.so implementation
|
||||
ffdsAppendResolution(
|
||||
ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) screen->width_in_pixels,
|
||||
(uint32_t) screen->height_in_pixels,
|
||||
|
||||
@@ -79,7 +79,7 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
for(int i = 0; i < ScreenCount(display); i++)
|
||||
{
|
||||
Screen* screen = ScreenOfDisplay(display, i);
|
||||
ffdsAppendResolution(
|
||||
ffdsAppendDisplay(
|
||||
result,
|
||||
(uint32_t) screen->width,
|
||||
(uint32_t) screen->height,
|
||||
@@ -138,7 +138,7 @@ static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo)
|
||||
modeInfo->dotClock / (modeInfo->hTotal * modeInfo->vTotal)
|
||||
));
|
||||
|
||||
return ffdsAppendResolution(
|
||||
return ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) modeInfo->width,
|
||||
(uint32_t) modeInfo->height,
|
||||
@@ -158,7 +158,7 @@ static bool xrandrHandleMode(XrandrData* data, RRMode mode)
|
||||
|
||||
static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
|
||||
{
|
||||
//We do the check here, because we want the best fallback resolution if this call failed
|
||||
//We do the check here, because we want the best fallback display if this call failed
|
||||
if(data->screenResources == NULL)
|
||||
return false;
|
||||
|
||||
@@ -167,7 +167,7 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
|
||||
return false;
|
||||
|
||||
bool res = xrandrHandleMode(data, crtcInfo->mode);
|
||||
res = res ? true : ffdsAppendResolution(
|
||||
res = res ? true : ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) crtcInfo->width,
|
||||
(uint32_t) crtcInfo->height,
|
||||
@@ -201,7 +201,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
foundOutput = true;
|
||||
}
|
||||
|
||||
return foundOutput ? true : ffdsAppendResolution(
|
||||
return foundOutput ? true : ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) monitorInfo->width,
|
||||
(uint32_t) monitorInfo->height,
|
||||
@@ -253,7 +253,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
return;
|
||||
|
||||
//Fallback to screen
|
||||
ffdsAppendResolution(
|
||||
ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) WidthOfScreen(screen),
|
||||
(uint32_t) HeightOfScreen(screen),
|
||||
|
||||
Reference in new issue
Block a user