wlr_xdg_output_v1: move where name & description are sent

This commit is contained in:
Ian Fan 2019-01-22 21:32:42 +00:00 committed by emersion
parent f3ff40a0eb
commit c41d01306d
1 changed files with 15 additions and 21 deletions

View File

@ -1,5 +1,4 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
@ -25,28 +24,11 @@ static void output_handle_resource_destroy(struct wl_resource *resource) {
} }
static void output_send_details(struct wlr_xdg_output_v1 *xdg_output, static void output_send_details(struct wlr_xdg_output_v1 *xdg_output,
struct wl_resource *resource, bool updated) { struct wl_resource *resource) {
struct wlr_output *output = xdg_output->layout_output->output;
zxdg_output_v1_send_logical_position(resource, zxdg_output_v1_send_logical_position(resource,
xdg_output->x, xdg_output->y); xdg_output->x, xdg_output->y);
zxdg_output_v1_send_logical_size(resource, zxdg_output_v1_send_logical_size(resource,
xdg_output->width, xdg_output->height); xdg_output->width, xdg_output->height);
if (!updated) {
// Name and description should only be sent once per output
uint32_t version = wl_resource_get_version(resource);
if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
zxdg_output_v1_send_name(resource, output->name);
}
if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) {
char description[128];
snprintf(description, sizeof(description), "%s %s %s (%s)",
output->make, output->model, output->serial, output->name);
zxdg_output_v1_send_description(resource, description);
}
}
zxdg_output_v1_send_done(resource); zxdg_output_v1_send_done(resource);
} }
@ -71,7 +53,7 @@ static void output_update(struct wlr_xdg_output_v1 *xdg_output) {
if (updated) { if (updated) {
struct wl_resource *resource; struct wl_resource *resource;
wl_resource_for_each(resource, &xdg_output->resources) { wl_resource_for_each(resource, &xdg_output->resources) {
output_send_details(xdg_output, resource, true); output_send_details(xdg_output, resource);
} }
} }
} }
@ -132,7 +114,19 @@ static void output_manager_handle_get_xdg_output(struct wl_client *client,
wl_list_insert(&xdg_output->resources, wl_list_insert(&xdg_output->resources,
wl_resource_get_link(xdg_output_resource)); wl_resource_get_link(xdg_output_resource));
output_send_details(xdg_output, xdg_output_resource, false); // Name and description should only be sent once per output
uint32_t version = wl_resource_get_version(xdg_output_resource);
if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
zxdg_output_v1_send_name(xdg_output_resource, output->name);
}
if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) {
char description[128];
snprintf(description, sizeof(description), "%s %s %s (%s)",
output->make, output->model, output->serial, output->name);
zxdg_output_v1_send_description(xdg_output_resource, description);
}
output_send_details(xdg_output, xdg_output_resource);
} }
static const struct zxdg_output_manager_v1_interface static const struct zxdg_output_manager_v1_interface