mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
DisplayServer: prepare for DDC/CI
This commit is contained in:
@@ -11,7 +11,8 @@ bool ffdsAppendDisplay(
|
||||
uint32_t rotation,
|
||||
FFstrbuf* name,
|
||||
FFDisplayType type,
|
||||
bool primary)
|
||||
bool primary,
|
||||
uint64_t id)
|
||||
{
|
||||
if(width == 0 || height == 0)
|
||||
return false;
|
||||
@@ -26,6 +27,7 @@ bool ffdsAppendDisplay(
|
||||
ffStrbufInitMove(&display->name, name);
|
||||
display->type = type;
|
||||
display->primary = primary;
|
||||
display->id = id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ typedef struct FFDisplayResult
|
||||
FFDisplayType type;
|
||||
uint32_t rotation;
|
||||
bool primary;
|
||||
uint64_t id; // platform dependent
|
||||
} FFDisplayResult;
|
||||
|
||||
typedef struct FFDisplayServerResult
|
||||
@@ -83,6 +84,7 @@ bool ffdsAppendDisplay(
|
||||
uint32_t rotation,
|
||||
FFstrbuf* name,
|
||||
FFDisplayType type,
|
||||
bool primary);
|
||||
bool primary,
|
||||
uint64_t id);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
(uint32_t)CGDisplayRotation(screen),
|
||||
&name,
|
||||
CGDisplayIsBuiltin(screen) ? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL,
|
||||
screen == primary
|
||||
screen == primary,
|
||||
(uint64_t)screen
|
||||
);
|
||||
CGDisplayModeRelease(mode);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
#include <WinUser.h>
|
||||
#include <wchar.h>
|
||||
|
||||
typedef struct FFMonitorInfo
|
||||
{
|
||||
HMONITOR handle;
|
||||
MONITORINFOEXW info;
|
||||
} FFMonitorInfo;
|
||||
|
||||
static CALLBACK BOOL MonitorEnumProc(
|
||||
HMONITOR hMonitor,
|
||||
FF_MAYBE_UNUSED HDC hdc,
|
||||
@@ -14,14 +20,16 @@ static CALLBACK BOOL MonitorEnumProc(
|
||||
)
|
||||
{
|
||||
FFlist* monitors = (FFlist*) lParam;
|
||||
MONITORINFOEXW* newMonitor = ffListAdd(monitors);
|
||||
newMonitor->cbSize = sizeof(*newMonitor);
|
||||
return GetMonitorInfoW(hMonitor, (MONITORINFO*) newMonitor);
|
||||
FFMonitorInfo* newMonitor = ffListAdd(monitors);
|
||||
newMonitor->handle = hMonitor;
|
||||
newMonitor->info.cbSize = sizeof(newMonitor->info);
|
||||
|
||||
return GetMonitorInfoW(hMonitor, (MONITORINFO*) &newMonitor->info);
|
||||
}
|
||||
|
||||
static void detectDisplays(FFDisplayServerResult* ds)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(MONITORINFOEXW));
|
||||
FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(FFMonitorInfo));
|
||||
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) &monitors);
|
||||
|
||||
DISPLAYCONFIG_PATH_INFO paths[128];
|
||||
@@ -50,12 +58,12 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
},
|
||||
};
|
||||
|
||||
MONITORINFOEXW* monitorInfo = NULL;
|
||||
FFMonitorInfo* monitorInfo = NULL;
|
||||
if (DisplayConfigGetDeviceInfo(&sourceName.header) == ERROR_SUCCESS)
|
||||
{
|
||||
FF_LIST_FOR_EACH(MONITORINFOEXW, item, monitors)
|
||||
FF_LIST_FOR_EACH(FFMonitorInfo, item, monitors)
|
||||
{
|
||||
if (wcsncmp(item->szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0)
|
||||
if (wcsncmp(item->info.szDevice, sourceName.viewGdiDeviceName, sizeof(sourceName.viewGdiDeviceName) / sizeof(wchar_t)) == 0)
|
||||
{
|
||||
monitorInfo = item;
|
||||
break;
|
||||
@@ -117,15 +125,16 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
width,
|
||||
height,
|
||||
path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator,
|
||||
(uint32_t) (monitorInfo->rcMonitor.right - monitorInfo->rcMonitor.left),
|
||||
(uint32_t) (monitorInfo->rcMonitor.bottom - monitorInfo->rcMonitor.top),
|
||||
(uint32_t) (monitorInfo->info.rcMonitor.right - monitorInfo->info.rcMonitor.left),
|
||||
(uint32_t) (monitorInfo->info.rcMonitor.bottom - monitorInfo->info.rcMonitor.top),
|
||||
rotation,
|
||||
&name,
|
||||
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL ||
|
||||
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED ||
|
||||
path->targetInfo.outputTechnology == DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED
|
||||
? FF_DISPLAY_TYPE_BUILTIN : FF_DISPLAY_TYPE_EXTERNAL,
|
||||
!!(monitorInfo->dwFlags & MONITORINFOF_PRIMARY)
|
||||
!!(monitorInfo->info.dwFlags & MONITORINFOF_PRIMARY),
|
||||
(uint64_t)(uintptr_t) monitorInfo->handle
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ static void parseDRM(FFDisplayServerResult* result)
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
rotation,
|
||||
&display.name,
|
||||
display.type,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
|
||||
ffThreadMutexUnlock(&mutex);
|
||||
|
||||
@@ -128,7 +128,8 @@ void ffdsConnectXcb(FFDisplayServerResult* result)
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
ffxcb_screen_next(&iterator);
|
||||
}
|
||||
@@ -198,7 +199,8 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
|
||||
rotation,
|
||||
name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
primary,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -255,7 +257,8 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
|
||||
rotation,
|
||||
name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
primary,
|
||||
0
|
||||
);
|
||||
|
||||
free(crtcInfoReply);
|
||||
@@ -315,7 +318,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitor->primary
|
||||
!!monitor->primary,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -379,7 +383,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ void ffdsConnectXlib(FFDisplayServerResult* result)
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -184,7 +185,8 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary)
|
||||
rotation,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
primary,
|
||||
0
|
||||
);
|
||||
|
||||
data->ffXRRFreeCrtcInfo(crtcInfo);
|
||||
@@ -224,7 +226,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitorInfo->primary
|
||||
!!monitorInfo->primary,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -282,7 +285,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
false,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user