From 40bd6bcc437c219b9045f796f7a572903307c6b0 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 30 Aug 2017 10:39:22 -0400 Subject: implement output layout auto configuration --- include/wlr/types/wlr_output_layout.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h index b1253eb1..78127f19 100644 --- a/include/wlr/types/wlr_output_layout.h +++ b/include/wlr/types/wlr_output_layout.h @@ -67,4 +67,15 @@ void wlr_output_layout_closest_point(struct wlr_output_layout *layout, struct wlr_box *wlr_output_layout_get_box( struct wlr_output_layout *layout, struct wlr_output *reference); +/** +* Add an auto configured output to the layout. This will place the output in a +* sensible location in the layout. The coordinates of the output in the layout +* may adjust dynamically when the layout changes. If the output is already in +* the layout, it will become auto configured. If the position of the output is +* set such as with `wlr_output_layout_move()`, the output will become manually +* configured. +*/ +void wlr_output_layout_add_auto(struct wlr_output_layout *layout, + struct wlr_output *output); + #endif -- cgit v1.2.3 From d84deb07420aefb7e16bae846c57f7b4c021e803 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 30 Aug 2017 13:28:50 -0400 Subject: add wlr_output destroy event --- include/wlr/types/wlr_output.h | 1 + types/wlr_output.c | 3 +++ types/wlr_output_layout.c | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 11160d33..3371dcb5 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -37,6 +37,7 @@ struct wlr_output { struct { struct wl_signal frame; struct wl_signal resolution; + struct wl_signal destroy; } events; struct { diff --git a/types/wlr_output.c b/types/wlr_output.c index 0a38d591..ee050dc4 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -100,6 +100,7 @@ void wlr_output_init(struct wlr_output *output, output->scale = 1; wl_signal_init(&output->events.frame); wl_signal_init(&output->events.resolution); + wl_signal_init(&output->events.destroy); } void wlr_output_enable(struct wlr_output *output, bool enable) { @@ -176,6 +177,8 @@ void wlr_output_destroy(struct wlr_output *output) { return; } + wl_signal_emit(&output->events.destroy, output); + wlr_texture_destroy(output->cursor.texture); wlr_renderer_destroy(output->cursor.renderer); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 503b9ec7..b189bd46 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -13,9 +13,13 @@ struct wlr_output_layout_state { struct wlr_output_layout_output_state { struct wlr_output_layout *layout; + struct wlr_output_layout_output *l_output; + struct wlr_box *_box; bool auto_configured; + struct wl_listener resolution; + struct wl_listener output_destroy; }; struct wlr_output_layout *wlr_output_layout_init() { @@ -30,6 +34,7 @@ struct wlr_output_layout *wlr_output_layout_init() { static void wlr_output_layout_output_destroy( struct wlr_output_layout_output *l_output) { wl_list_remove(&l_output->state->resolution.link); + wl_list_remove(&l_output->state->output_destroy.link); wl_list_remove(&l_output->link); free(l_output->state->_box); free(l_output->state); @@ -111,11 +116,20 @@ static void handle_output_resolution(struct wl_listener *listener, void *data) { wlr_output_layout_reconfigure(state->layout); } +static void handle_output_destroy(struct wl_listener *listener, void *data) { + struct wlr_output_layout_output_state *state = + wl_container_of(listener, state, output_destroy); + struct wlr_output_layout *layout = state->layout; + wlr_output_layout_output_destroy(state->l_output); + wlr_output_layout_reconfigure(layout); +} + static struct wlr_output_layout_output *wlr_output_layout_output_create( struct wlr_output_layout *layout, struct wlr_output *output) { struct wlr_output_layout_output *l_output; l_output= calloc(1, sizeof(struct wlr_output_layout_output)); l_output->state = calloc(1, sizeof(struct wlr_output_layout_output_state)); + l_output->state->l_output = l_output; l_output->state->_box = calloc(1, sizeof(struct wlr_box)); l_output->state->layout = layout; l_output->output = output; @@ -124,6 +138,9 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create( wl_signal_add(&output->events.resolution, &l_output->state->resolution); l_output->state->resolution.notify = handle_output_resolution; + wl_signal_add(&output->events.destroy, &l_output->state->output_destroy); + l_output->state->output_destroy.notify = handle_output_destroy; + return l_output; } -- cgit v1.2.3