mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
DisplayServer (Wayland): detect display type
This commit is contained in:
parent
036752763f
commit
cb8a9c0796
@ -29,6 +29,7 @@ typedef struct WaylandDisplay
|
|||||||
int32_t refreshRate;
|
int32_t refreshRate;
|
||||||
int32_t scale;
|
int32_t scale;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
|
FFDisplayType type;
|
||||||
FFstrbuf name;
|
FFstrbuf name;
|
||||||
bool detectName;
|
bool detectName;
|
||||||
} WaylandDisplay;
|
} WaylandDisplay;
|
||||||
@ -108,6 +109,17 @@ static void waylandOutputGeometryListener(void *data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
|
static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name)
|
||||||
|
{
|
||||||
|
WaylandDisplay* display = data;
|
||||||
|
if(strncmp(name, "eDP-", strlen("eDP-")) == 0)
|
||||||
|
display->type = FF_DISPLAY_TYPE_BUILTIN;
|
||||||
|
else if(strncmp(name, "HDMI-", strlen("HDMI-")) == 0 || strncmp(name, "DP-", strlen("DP-")) == 0)
|
||||||
|
display->type = FF_DISPLAY_TYPE_EXTERNAL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version)
|
static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version)
|
||||||
{
|
{
|
||||||
struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL);
|
struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL);
|
||||||
@ -121,6 +133,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
|||||||
.refreshRate = 0,
|
.refreshRate = 0,
|
||||||
.scale = 1,
|
.scale = 1,
|
||||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
|
.type = FF_DISPLAY_TYPE_UNKNOWN,
|
||||||
};
|
};
|
||||||
ffStrbufInit(&display.name);
|
ffStrbufInit(&display.name);
|
||||||
|
|
||||||
@ -137,7 +150,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||||
.name = (void*) stubListener,
|
.name = waylandOutputNameListener,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
|
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
|
||||||
@ -177,7 +190,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
|||||||
(uint32_t) (display.width / display.scale),
|
(uint32_t) (display.width / display.scale),
|
||||||
(uint32_t) (display.height / display.scale),
|
(uint32_t) (display.height / display.scale),
|
||||||
&display.name,
|
&display.name,
|
||||||
FF_DISPLAY_TYPE_UNKNOWN
|
display.type
|
||||||
);
|
);
|
||||||
|
|
||||||
ffThreadMutexUnlock(&mutex);
|
ffThreadMutexUnlock(&mutex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user