From bf2b58eb6db5a59f08a3b0a3ab5e43e93711bf51 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 16:36:46 +0100 Subject: [PATCH 1/2] Add wlr_output_set_scale Fixes #465 --- include/wlr/types/wlr_output.h | 1 + rootston/output.c | 6 +++--- types/wlr_output.c | 29 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index d382b593..42c46233 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -85,6 +85,7 @@ bool wlr_output_set_mode(struct wlr_output *output, void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform); void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); +void wlr_output_set_scale(struct wlr_output *output, uint32_t scale); void wlr_output_destroy(struct wlr_output *output); void wlr_output_effective_resolution(struct wlr_output *output, int *width, int *height); diff --git a/rootston/output.c b/rootston/output.c index bf684f2f..d0f4a378 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -314,10 +314,10 @@ void output_add_notify(struct wl_listener *listener, void *data) { if (output_config->mode.width) { set_mode(wlr_output, output_config); } - wlr_output->scale = output_config->scale; + wlr_output_set_scale(wlr_output, output_config->scale); wlr_output_transform(wlr_output, output_config->transform); - wlr_output_layout_add(desktop->layout, - wlr_output, output_config->x, output_config->y); + wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, + output_config->y); } else { wlr_output_layout_add_auto(desktop->layout, wlr_output); } diff --git a/types/wlr_output.c b/types/wlr_output.c index 21d94cfb..163f2d8c 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -52,6 +52,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) { static void wlr_output_send_current_mode_to_resource( struct wl_resource *resource) { + assert(resource); struct wlr_output *output = wl_resource_get_user_data(resource); assert(output); const uint32_t version = wl_resource_get_version(resource); @@ -119,7 +120,6 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output, struct wl_global *wl_global = wl_global_create(display, &wl_output_interface, 3, wlr_output, wl_output_bind); wlr_output->wl_global = wl_global; - wl_list_init(&wlr_output->wl_resources); return wl_global; } @@ -155,6 +155,7 @@ bool wlr_output_set_mode(struct wlr_output *output, bool result = output->impl->set_mode(output, mode); if (result) { wlr_output_update_matrix(output); + struct wl_resource *resource; wl_resource_for_each(resource, &output->wl_resources) { wlr_output_send_current_mode_to_resource(resource); @@ -168,14 +169,14 @@ void wlr_output_update_size(struct wlr_output *output, int32_t width, if (output->width == width && output->height == height) { return; } + output->width = width; output->height = height; wlr_output_update_matrix(output); - if (output->wl_global != NULL) { - struct wl_resource *resource; - wl_resource_for_each(resource, &output->wl_resources) { - wlr_output_send_current_mode_to_resource(resource); - } + + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wlr_output_send_current_mode_to_resource(resource); } } @@ -194,6 +195,21 @@ void wlr_output_set_position(struct wlr_output *output, int32_t lx, output->lx = lx; output->ly = ly; + // TODO: only send geometry and done + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wl_output_send_to_resource(resource); + } +} + +void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) { + if (output->scale == scale) { + return; + } + + output->scale = scale; + + // TODO: only send mode and done struct wl_resource *resource; wl_resource_for_each(resource, &output->wl_resources) { wl_output_send_to_resource(resource); @@ -209,6 +225,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, output->transform = WL_OUTPUT_TRANSFORM_NORMAL; output->scale = 1; wl_list_init(&output->cursors); + wl_list_init(&output->wl_resources); wl_signal_init(&output->events.frame); wl_signal_init(&output->events.swap_buffers); wl_signal_init(&output->events.resolution); From dac0233804c7a8a1ffe76c4c3f0644873a0267d0 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 16:54:08 +0100 Subject: [PATCH 2/2] Send new output to clients when changing transform --- types/wlr_output.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/wlr_output.c b/types/wlr_output.c index 163f2d8c..ed74004d 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -184,6 +184,12 @@ void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform) { output->impl->transform(output, transform); wlr_output_update_matrix(output); + + // TODO: only send geometry and done + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wl_output_send_to_resource(resource); + } } void wlr_output_set_position(struct wlr_output *output, int32_t lx,