mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
DisplayServer (Linux): better rotation detection for X11
This commit is contained in:
parent
7965107347
commit
e7487e24ae
@ -184,6 +184,7 @@ typedef struct XcbRandrData
|
||||
|
||||
//init per screen
|
||||
uint32_t defaultRefreshRate;
|
||||
uint32_t defaultRotation;
|
||||
xcb_randr_get_screen_resources_reply_t* screenResources;
|
||||
} XcbRandrData;
|
||||
|
||||
@ -316,7 +317,7 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
|
||||
data->defaultRefreshRate,
|
||||
(uint32_t) monitor->width,
|
||||
(uint32_t) monitor->height,
|
||||
0,
|
||||
data->defaultRotation,
|
||||
&name,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitor->primary,
|
||||
@ -356,11 +357,28 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
if(screenInfoReply != NULL)
|
||||
{
|
||||
data->defaultRefreshRate = screenInfoReply->rate;
|
||||
switch (screenInfoReply->rotation)
|
||||
{
|
||||
case XCB_RANDR_ROTATION_ROTATE_90:
|
||||
data->defaultRotation = 90;
|
||||
break;
|
||||
case XCB_RANDR_ROTATION_ROTATE_180:
|
||||
data->defaultRotation = 180;
|
||||
break;
|
||||
case XCB_RANDR_ROTATION_ROTATE_270:
|
||||
data->defaultRotation = 270;
|
||||
break;
|
||||
default:
|
||||
data->defaultRotation = 0;
|
||||
break;
|
||||
}
|
||||
free(screenInfoReply);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->defaultRefreshRate = 0;
|
||||
|
||||
data->defaultRotation = 0;
|
||||
}
|
||||
//Init screen resources. They are used to iterate over all modes. xcbRandrHandleMode checks for " == NULL", to fail as late as possible.
|
||||
xcb_randr_get_screen_resources_cookie_t screenResourcesCookie = data->ffxcb_randr_get_screen_resources(data->connection, screen->root);
|
||||
data->screenResources = data->ffxcb_randr_get_screen_resources_reply(data->connection, screenResourcesCookie, NULL);
|
||||
@ -381,7 +399,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
|
||||
data->defaultRefreshRate,
|
||||
(uint32_t) screen->width_in_pixels,
|
||||
(uint32_t) screen->height_in_pixels,
|
||||
0,
|
||||
data->defaultRotation,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
|
@ -132,6 +132,7 @@ typedef struct XrandrData
|
||||
|
||||
//Init per screen
|
||||
uint32_t defaultRefreshRate;
|
||||
uint32_t defaultRotation;
|
||||
XRRScreenResources* screenResources;
|
||||
} XrandrData;
|
||||
|
||||
@ -223,7 +224,7 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
|
||||
data->defaultRefreshRate,
|
||||
(uint32_t) monitorInfo->width,
|
||||
(uint32_t) monitorInfo->height,
|
||||
0,
|
||||
data->defaultRotation,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
!!monitorInfo->primary,
|
||||
@ -259,10 +260,30 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
if(screenConfiguration != NULL)
|
||||
{
|
||||
data->defaultRefreshRate = (uint32_t) data->ffXRRConfigCurrentRate(screenConfiguration);
|
||||
Rotation rotation = 0;
|
||||
data->ffXRRConfigCurrentConfiguration(screenConfiguration, &rotation);
|
||||
switch (rotation)
|
||||
{
|
||||
case RR_Rotate_90:
|
||||
data->defaultRotation = 90;
|
||||
break;
|
||||
case RR_Rotate_180:
|
||||
data->defaultRotation = 180;
|
||||
break;
|
||||
case RR_Rotate_270:
|
||||
data->defaultRotation = 270;
|
||||
break;
|
||||
default:
|
||||
data->defaultRotation = 0;
|
||||
break;
|
||||
}
|
||||
data->ffXRRFreeScreenConfigInfo(screenConfiguration);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->defaultRefreshRate = 0;
|
||||
data->defaultRotation = 0;
|
||||
}
|
||||
|
||||
//Init screen resources
|
||||
data->screenResources = data->ffXRRGetScreenResources(data->display, RootWindowOfScreen(screen));
|
||||
@ -282,7 +303,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
data->defaultRefreshRate,
|
||||
(uint32_t) WidthOfScreen(screen),
|
||||
(uint32_t) HeightOfScreen(screen),
|
||||
0,
|
||||
data->defaultRotation,
|
||||
NULL,
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
false,
|
||||
@ -301,6 +322,7 @@ void ffdsConnectXrandr(FFDisplayServerResult* result)
|
||||
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenInfo,)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentRate,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRConfigCurrentConfiguration,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetMonitors,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenResources,);
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputInfo,);
|
||||
|
Loading…
x
Reference in New Issue
Block a user