mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Display: split phycial resolution and scaled resolution
This commit is contained in:
@@ -19,7 +19,7 @@ uint32_t ffdsParseRefreshRate(int32_t refreshRate)
|
||||
return (uint32_t) refreshRate;
|
||||
}
|
||||
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate)
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t scaledWidth, uint32_t scaledHeight)
|
||||
{
|
||||
if(width == 0 || height == 0)
|
||||
return false;
|
||||
@@ -28,6 +28,8 @@ bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t h
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
display->refreshRate = refreshRate;
|
||||
display->scaledWidth = scaledWidth;
|
||||
display->scaledHeight = scaledHeight;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ typedef struct FFDisplayResult
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t refreshRate;
|
||||
uint32_t scaledWidth;
|
||||
uint32_t scaledHeight;
|
||||
} FFDisplayResult;
|
||||
|
||||
typedef struct FFDisplayServerResult
|
||||
@@ -27,6 +29,6 @@ const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
|
||||
|
||||
//Used internal
|
||||
uint32_t ffdsParseRefreshRate(int32_t refreshRate);
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate);
|
||||
bool ffdsAppendDisplay(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate, uint32_t scaledWidth, uint32_t scaledHeight);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,9 +21,11 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
if(mode)
|
||||
{
|
||||
ffdsAppendDisplay(ds,
|
||||
(uint32_t)CGDisplayModeGetPixelWidth(mode),
|
||||
(uint32_t)CGDisplayModeGetPixelHeight(mode),
|
||||
(uint32_t)CGDisplayModeGetRefreshRate(mode),
|
||||
(uint32_t)CGDisplayModeGetWidth(mode),
|
||||
(uint32_t)CGDisplayModeGetHeight(mode),
|
||||
(uint32_t)CGDisplayModeGetRefreshRate(mode)
|
||||
(uint32_t)CGDisplayModeGetHeight(mode)
|
||||
);
|
||||
CGDisplayModeRelease(mode);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
|
||||
if(EnumDisplaySettingsW(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode) == 0)
|
||||
continue;
|
||||
|
||||
ffdsAppendDisplay(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency);
|
||||
ffdsAppendDisplay(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency, 0, 0);
|
||||
}
|
||||
|
||||
//https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067
|
||||
|
||||
@@ -36,6 +36,8 @@ static void parseDRM(FFDisplayServerResult* result)
|
||||
display->width = 0;
|
||||
display->height = 0;
|
||||
display->refreshRate = 0;
|
||||
display->scaledWidth = 0;
|
||||
display->scaledHeight = 0;
|
||||
|
||||
int scanned = fscanf(modeFile, "%ux%u", &display->width, &display->height);
|
||||
if(scanned < 2 || display->width == 0 || display->height == 0)
|
||||
|
||||
@@ -66,6 +66,8 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
|
||||
result->width = (uint32_t) width;
|
||||
result->height = (uint32_t) height;
|
||||
result->refreshRate = ffdsParseRefreshRate(refreshRate / 1000);
|
||||
result->scaledWidth = 0;
|
||||
result->scaledHeight = 0;
|
||||
}
|
||||
|
||||
static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
|
||||
|
||||
@@ -119,6 +119,8 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
result,
|
||||
(uint32_t) iterator.data->width_in_pixels,
|
||||
(uint32_t) iterator.data->height_in_pixels,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
ffxcb_screen_next(&iterator);
|
||||
@@ -184,7 +186,9 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
|
||||
data->result,
|
||||
(uint32_t) modeInfo->width,
|
||||
(uint32_t) modeInfo->height,
|
||||
refreshRate == 0 ? data->defaultRefreshRate : refreshRate
|
||||
refreshRate == 0 ? data->defaultRefreshRate : refreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,7 +223,9 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc)
|
||||
data->result,
|
||||
(uint32_t) crtcInfoReply->width,
|
||||
(uint32_t) crtcInfoReply->height,
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
free(crtcInfoReply);
|
||||
@@ -262,7 +268,9 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
data->result,
|
||||
(uint32_t) monitor->width,
|
||||
(uint32_t) monitor->height,
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -320,7 +328,9 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
data->result,
|
||||
(uint32_t) screen->width_in_pixels,
|
||||
(uint32_t) screen->height_in_pixels,
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
result,
|
||||
(uint32_t) screen->width,
|
||||
(uint32_t) screen->height,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
@@ -142,7 +144,9 @@ static bool xrandrHandleModeInfo(XrandrData* data, XRRModeInfo* modeInfo)
|
||||
data->result,
|
||||
(uint32_t) modeInfo->width,
|
||||
(uint32_t) modeInfo->height,
|
||||
refreshRate == 0 ? data->defaultRefreshRate : refreshRate
|
||||
refreshRate == 0 ? data->defaultRefreshRate : refreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -171,7 +175,9 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
|
||||
data->result,
|
||||
(uint32_t) crtcInfo->width,
|
||||
(uint32_t) crtcInfo->height,
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
data->ffXRRFreeCrtcInfo(crtcInfo);
|
||||
@@ -205,7 +211,9 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
data->result,
|
||||
(uint32_t) monitorInfo->width,
|
||||
(uint32_t) monitorInfo->height,
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -257,7 +265,9 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
data->result,
|
||||
(uint32_t) WidthOfScreen(screen),
|
||||
(uint32_t) HeightOfScreen(screen),
|
||||
data->defaultRefreshRate
|
||||
data->defaultRefreshRate,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ void ffPrintDisplay(FFinstance* instance)
|
||||
if(result->refreshRate > 0)
|
||||
printf(" @ %iHz", result->refreshRate);
|
||||
|
||||
if(
|
||||
result->scaledWidth > 0 && result->scaledWidth != result->width &&
|
||||
result->scaledHeight > 0 && result->scaledHeight != result->height)
|
||||
printf(" (as %ix%i)", result->scaledWidth, result->scaledHeight);
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user