mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
output: add description
wlr_output.description is a string containing a human-readable string identifying the output. Compositors can customise it via wlr_output_set_description, for instance to make the name more user-friendly. References: https://github.com/swaywm/wlroots/issues/1623
This commit is contained in:
parent
a420d2c41e
commit
4da4a15d6b
7 changed files with 48 additions and 0 deletions
|
@ -1348,6 +1348,12 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|||
parse_edid(&wlr_conn->output, edid_len, edid);
|
||||
free(edid);
|
||||
|
||||
struct wlr_output *output = &wlr_conn->output;
|
||||
char description[128];
|
||||
snprintf(description, sizeof(description), "%s %s %s (%s)",
|
||||
output->make, output->model, output->serial, output->name);
|
||||
wlr_output_set_description(output, description);
|
||||
|
||||
wlr_log(WLR_INFO, "Detected modes:");
|
||||
|
||||
for (int i = 0; i < drm_conn->count_modes; ++i) {
|
||||
|
|
|
@ -121,6 +121,11 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
|
|||
snprintf(wlr_output->name, sizeof(wlr_output->name), "HEADLESS-%zd",
|
||||
++backend->last_output_num);
|
||||
|
||||
char description[128];
|
||||
snprintf(description, sizeof(description),
|
||||
"Headless output %zd", backend->last_output_num);
|
||||
wlr_output_set_description(wlr_output, description);
|
||||
|
||||
if (!wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||
NULL)) {
|
||||
goto error;
|
||||
|
|
|
@ -278,6 +278,11 @@ struct wlr_rdp_output *wlr_rdp_output_create(struct wlr_rdp_backend *backend,
|
|||
snprintf(wlr_output->name, sizeof(wlr_output->name), "RDP-%d",
|
||||
wl_list_length(&backend->clients));
|
||||
|
||||
char description[128];
|
||||
snprintf(description, sizeof(description),
|
||||
"RDP output %d", wl_list_length(&backend->clients));
|
||||
wlr_output_set_description(wlr_output, description);
|
||||
|
||||
if (!wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||
NULL)) {
|
||||
goto error;
|
||||
|
|
|
@ -458,6 +458,11 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
|||
snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%zd",
|
||||
++backend->last_output_num);
|
||||
|
||||
char description[128];
|
||||
snprintf(description, sizeof(description),
|
||||
"Wayland output %zd", backend->last_output_num);
|
||||
wlr_output_set_description(wlr_output, description);
|
||||
|
||||
output->backend = backend;
|
||||
wl_list_init(&output->presentation_feedbacks);
|
||||
|
||||
|
|
|
@ -149,6 +149,11 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
|||
++x11->last_output_num);
|
||||
parse_xcb_setup(wlr_output, x11->xcb);
|
||||
|
||||
char description[128];
|
||||
snprintf(description, sizeof(description),
|
||||
"X11 output %zd", x11->last_output_num);
|
||||
wlr_output_set_description(wlr_output, description);
|
||||
|
||||
uint32_t mask = XCB_CW_EVENT_MASK;
|
||||
uint32_t values[] = {
|
||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
|
|
|
@ -90,6 +90,7 @@ struct wlr_output {
|
|||
struct wl_list resources;
|
||||
|
||||
char name[24];
|
||||
char *description; // may be NULL
|
||||
char make[56];
|
||||
char model[16];
|
||||
char serial[16];
|
||||
|
@ -133,6 +134,7 @@ struct wlr_output {
|
|||
struct wl_signal mode;
|
||||
struct wl_signal scale;
|
||||
struct wl_signal transform;
|
||||
struct wl_signal description;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
|
@ -214,6 +216,7 @@ void wlr_output_set_transform(struct wlr_output *output,
|
|||
void wlr_output_set_scale(struct wlr_output *output, float scale);
|
||||
void wlr_output_set_subpixel(struct wlr_output *output,
|
||||
enum wl_output_subpixel subpixel);
|
||||
void wlr_output_set_description(struct wlr_output *output, const char *desc);
|
||||
/**
|
||||
* Schedule a done event.
|
||||
*
|
||||
|
|
|
@ -270,6 +270,22 @@ void wlr_output_set_subpixel(struct wlr_output *output,
|
|||
wlr_output_schedule_done(output);
|
||||
}
|
||||
|
||||
void wlr_output_set_description(struct wlr_output *output, const char *desc) {
|
||||
if (output->description != NULL && desc != NULL &&
|
||||
strcmp(output->description, desc) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(output->description);
|
||||
if (desc != NULL) {
|
||||
output->description = strdup(desc);
|
||||
} else {
|
||||
output->description = NULL;
|
||||
}
|
||||
|
||||
wlr_signal_emit_safe(&output->events.description, output);
|
||||
}
|
||||
|
||||
static void schedule_done_handle_idle_timer(void *data) {
|
||||
struct wlr_output *output = data;
|
||||
output->idle_done = NULL;
|
||||
|
@ -323,6 +339,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|||
wl_signal_init(&output->events.mode);
|
||||
wl_signal_init(&output->events.scale);
|
||||
wl_signal_init(&output->events.transform);
|
||||
wl_signal_init(&output->events.description);
|
||||
wl_signal_init(&output->events.destroy);
|
||||
pixman_region32_init(&output->damage);
|
||||
pixman_region32_init(&output->pending.damage);
|
||||
|
@ -365,6 +382,8 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
wl_event_source_remove(output->idle_done);
|
||||
}
|
||||
|
||||
free(output->description);
|
||||
|
||||
pixman_region32_fini(&output->pending.damage);
|
||||
pixman_region32_fini(&output->damage);
|
||||
|
||||
|
|
Loading…
Reference in a new issue