mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Display (Linux): detect primary display
This commit is contained in:
@@ -202,7 +202,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
(uint32_t) (display.height / display.scale),
|
||||
rotation,
|
||||
&display.name,
|
||||
display.type
|
||||
display.type,
|
||||
false
|
||||
);
|
||||
|
||||
ffThreadMutexUnlock(&mutex);
|
||||
|
||||
@@ -127,7 +127,8 @@ void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
(uint32_t) iterator.data->height_in_pixels,
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
);
|
||||
ffxcb_screen_next(&iterator);
|
||||
}
|
||||
@@ -183,7 +184,7 @@ typedef struct XcbRandrData
|
||||
xcb_randr_get_screen_resources_reply_t* screenResources;
|
||||
} XcbRandrData;
|
||||
|
||||
static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation)
|
||||
static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* modeInfo, FFstrbuf* name, uint32_t rotation, bool primary)
|
||||
{
|
||||
double refreshRate = (double) modeInfo->dot_clock / (double) (modeInfo->htotal * modeInfo->vtotal);
|
||||
|
||||
@@ -196,11 +197,12 @@ static bool xcbRandrHandleModeInfo(XcbRandrData* data, xcb_randr_mode_info_t* mo
|
||||
(uint32_t) modeInfo->height,
|
||||
rotation,
|
||||
name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
);
|
||||
}
|
||||
|
||||
static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation)
|
||||
static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrbuf* name, uint32_t rotation, bool primary)
|
||||
{
|
||||
//We do the check here, because we want the best fallback display if this call failed
|
||||
if(data->screenResources == NULL)
|
||||
@@ -211,7 +213,7 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrb
|
||||
while(modesIterator.rem > 0)
|
||||
{
|
||||
if(modesIterator.data->id == mode)
|
||||
return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation);
|
||||
return xcbRandrHandleModeInfo(data, modesIterator.data, name, rotation, primary);
|
||||
|
||||
data->ffxcb_randr_mode_info_next(&modesIterator);
|
||||
}
|
||||
@@ -219,7 +221,7 @@ static bool xcbRandrHandleMode(XcbRandrData* data, xcb_randr_mode_t mode, FFstrb
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name)
|
||||
static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrbuf* name, bool primary)
|
||||
{
|
||||
xcb_randr_get_crtc_info_cookie_t crtcInfoCookie = data->ffxcb_randr_get_crtc_info(data->connection, crtc, XCB_CURRENT_TIME);
|
||||
xcb_randr_get_crtc_info_reply_t* crtcInfoReply = data->ffxcb_randr_get_crtc_info_reply(data->connection, crtcInfoCookie, NULL);
|
||||
@@ -242,7 +244,7 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
|
||||
rotation = 0;
|
||||
break;
|
||||
}
|
||||
bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation);
|
||||
bool res = xcbRandrHandleMode(data, crtcInfoReply->mode, name, rotation, primary);
|
||||
res = res ? true : ffdsAppendDisplay(
|
||||
data->result,
|
||||
(uint32_t) crtcInfoReply->width,
|
||||
@@ -252,21 +254,22 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
|
||||
(uint32_t) crtcInfoReply->height,
|
||||
rotation,
|
||||
name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
);
|
||||
|
||||
free(crtcInfoReply);
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name)
|
||||
static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary)
|
||||
{
|
||||
xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME);
|
||||
xcb_randr_get_output_info_reply_t* outputInfoReply = data->ffxcb_randr_get_output_info_reply(data->connection, outputInfoCookie, NULL);
|
||||
if(outputInfoReply == NULL)
|
||||
return false;
|
||||
|
||||
bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name);
|
||||
bool res = xcbRandrHandleCrtc(data, outputInfoReply->crtc, name, primary);
|
||||
|
||||
free(outputInfoReply);
|
||||
|
||||
@@ -297,7 +300,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
|
||||
while(outputIterator.rem > 0)
|
||||
{
|
||||
if(xcbRandrHandleOutput(data, *outputIterator.data, &name))
|
||||
if(xcbRandrHandleOutput(data, *outputIterator.data, &name, monitor->primary))
|
||||
foundOutput = true;
|
||||
data->ffxcb_randr_output_next(&outputIterator);
|
||||
};
|
||||
@@ -311,7 +314,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
(uint32_t) monitor->height,
|
||||
0,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitor->primary
|
||||
);
|
||||
}
|
||||
|
||||
@@ -374,7 +378,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
(uint32_t) screen->height_in_pixels,
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result)
|
||||
(uint32_t) HeightOfScreen(screen),
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@ static double xrandrHandleMode(XrandrData* data, RRMode mode)
|
||||
return data->defaultRefreshRate;
|
||||
}
|
||||
|
||||
static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
|
||||
static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc, bool primary)
|
||||
{
|
||||
//We do the check here, because we want the best fallback display if this call failed
|
||||
if(data->screenResources == NULL)
|
||||
@@ -182,20 +183,21 @@ static bool xrandrHandleCrtc(XrandrData* data, RRCrtc crtc)
|
||||
(uint32_t) crtcInfo->height,
|
||||
rotation,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
primary
|
||||
);
|
||||
|
||||
data->ffXRRFreeCrtcInfo(crtcInfo);
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool xrandrHandleOutput(XrandrData* data, RROutput output)
|
||||
static bool xrandrHandleOutput(XrandrData* data, RROutput output, bool primary)
|
||||
{
|
||||
XRROutputInfo* outputInfo = data->ffXRRGetOutputInfo(data->display, data->screenResources, output);
|
||||
if(outputInfo == NULL)
|
||||
return false;
|
||||
|
||||
bool res = xrandrHandleCrtc(data, outputInfo->crtc);
|
||||
bool res = xrandrHandleCrtc(data, outputInfo->crtc, primary);
|
||||
|
||||
data->ffXRRFreeOutputInfo(outputInfo);
|
||||
|
||||
@@ -208,7 +210,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
|
||||
for(int i = 0; i < monitorInfo->noutput; i++)
|
||||
{
|
||||
if(xrandrHandleOutput(data, monitorInfo->outputs[i]))
|
||||
if(xrandrHandleOutput(data, monitorInfo->outputs[i], monitorInfo->primary))
|
||||
foundOutput = true;
|
||||
}
|
||||
|
||||
@@ -221,7 +223,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
(uint32_t) monitorInfo->height,
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitorInfo->primary
|
||||
);
|
||||
}
|
||||
|
||||
@@ -278,7 +281,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
(uint32_t) HeightOfScreen(screen),
|
||||
0,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user