diff options
author | emersion <contact@emersion.fr> | 2018-01-06 12:39:15 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-01-06 12:39:15 +0100 |
commit | 6fe380a1769fe40a9ce0f1d6f1aeb1b3beb63c16 (patch) | |
tree | 592679fb44df7048e33a55d90fd13242a5ca6baf | |
parent | be3a7b0017823d80cd50c830d788a96e0e0ef6e8 (diff) |
output_layout: handle output enable event
-rw-r--r-- | types/wlr_output_layout.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 5b2dee8c..7e782399 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -18,6 +18,7 @@ struct wlr_output_layout_output_state { struct wlr_box _box; // should never be read directly, use the getter bool auto_configured; + struct wl_listener enable; struct wl_listener resolution; struct wl_listener scale; struct wl_listener transform; @@ -47,6 +48,7 @@ struct wlr_output_layout *wlr_output_layout_create() { static void wlr_output_layout_output_destroy( struct wlr_output_layout_output *l_output) { wl_signal_emit(&l_output->events.destroy, l_output); + wl_list_remove(&l_output->state->enable.link); wl_list_remove(&l_output->state->resolution.link); wl_list_remove(&l_output->state->scale.link); wl_list_remove(&l_output->state->transform.link); @@ -74,12 +76,19 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) { static struct wlr_box *wlr_output_layout_output_get_box( struct wlr_output_layout_output *l_output) { - l_output->state->_box.x = l_output->x; - l_output->state->_box.y = l_output->y; - int width, height; - wlr_output_effective_resolution(l_output->output, &width, &height); - l_output->state->_box.width = width; - l_output->state->_box.height = height; + if (!l_output->output->enabled) { + l_output->state->_box.x = 0; + l_output->state->_box.y = 0; + l_output->state->_box.width = 0; + l_output->state->_box.height = 0; + } else { + l_output->state->_box.x = l_output->x; + l_output->state->_box.y = l_output->y; + int width, height; + wlr_output_effective_resolution(l_output->output, &width, &height); + l_output->state->_box.width = width; + l_output->state->_box.height = height; + } return &l_output->state->_box; } @@ -98,7 +107,7 @@ static void wlr_output_layout_reconfigure(struct wlr_output_layout *layout) { // in the layout struct wlr_output_layout_output *l_output; wl_list_for_each(l_output, &layout->outputs, link) { - if (l_output->state->auto_configured) { + if (l_output->state->auto_configured || !l_output->output->enabled) { continue; } @@ -116,7 +125,7 @@ static void wlr_output_layout_reconfigure(struct wlr_output_layout *layout) { } wl_list_for_each(l_output, &layout->outputs, link) { - if (!l_output->state->auto_configured) { + if (!l_output->state->auto_configured || !l_output->output->enabled) { continue; } struct wlr_box *box = wlr_output_layout_output_get_box(l_output); @@ -126,12 +135,21 @@ static void wlr_output_layout_reconfigure(struct wlr_output_layout *layout) { } wl_list_for_each(l_output, &layout->outputs, link) { + if (!l_output->output->enabled) { + continue; + } wlr_output_set_position(l_output->output, l_output->x, l_output->y); } wl_signal_emit(&layout->events.change, layout); } +static void handle_output_enable(struct wl_listener *listener, void *data) { + struct wlr_output_layout_output_state *state = + wl_container_of(listener, state, enable); + wlr_output_layout_reconfigure(state->layout); +} + static void handle_output_resolution(struct wl_listener *listener, void *data) { struct wlr_output_layout_output_state *state = wl_container_of(listener, state, resolution); @@ -176,6 +194,8 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create( wl_signal_init(&l_output->events.destroy); wl_list_insert(&layout->outputs, &l_output->link); + wl_signal_add(&output->events.enable, &l_output->state->enable); + l_output->state->enable.notify = handle_output_enable; wl_signal_add(&output->events.resolution, &l_output->state->resolution); l_output->state->resolution.notify = handle_output_resolution; wl_signal_add(&output->events.scale, &l_output->state->scale); |