mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Display (Linux): detect monitor name for wayland
This commit is contained in:
parent
33dc097c3f
commit
2f2856eacb
@ -32,6 +32,8 @@ typedef struct WaylandDisplay
|
||||
enum wl_output_transform transform;
|
||||
FFDisplayType type;
|
||||
FFstrbuf name;
|
||||
FFstrbuf description;
|
||||
FFstrbuf vendorAndModelId;
|
||||
} WaylandDisplay;
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
@ -90,6 +92,8 @@ static void waylandOutputGeometryListener(void *data,
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
display->transform = (enum wl_output_transform) transform;
|
||||
ffStrbufAppendS(&display->vendorAndModelId, make);
|
||||
ffStrbufAppendS(&display->vendorAndModelId, model);
|
||||
}
|
||||
|
||||
static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name)
|
||||
@ -102,6 +106,13 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
static void waylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED struct wl_output* wl_output, const char* description)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
while (*description == ' ') ++description;
|
||||
ffStrbufAppendS(&display->description, description);
|
||||
}
|
||||
|
||||
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);
|
||||
@ -117,6 +128,8 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
.type = FF_DISPLAY_TYPE_UNKNOWN,
|
||||
};
|
||||
ffStrbufInit(&display.name);
|
||||
ffStrbufInit(&display.description);
|
||||
ffStrbufInit(&display.vendorAndModelId);
|
||||
|
||||
// Dirty hack for #477
|
||||
// The order of these callbacks MUST follow `struct wl_output_listener`
|
||||
@ -126,7 +139,7 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
stubListener, // done
|
||||
waylandOutputScaleListener, // scale
|
||||
waylandOutputNameListener, // name
|
||||
stubListener, // description
|
||||
waylandOutputDescriptionListener, // description
|
||||
};
|
||||
static_assert(
|
||||
sizeof(outputListener) >= sizeof(struct wl_output_listener),
|
||||
@ -185,7 +198,10 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
(uint32_t) (display.width / display.scale),
|
||||
(uint32_t) (display.height / display.scale),
|
||||
rotation,
|
||||
&display.name,
|
||||
display.description.length
|
||||
? &display.description
|
||||
: display.vendorAndModelId.length
|
||||
? &display.vendorAndModelId : &display.name,
|
||||
display.type,
|
||||
false,
|
||||
0
|
||||
|
Loading…
x
Reference in New Issue
Block a user