From b887af9a6013ea0466b6152e74f69659d7d45711 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 29 Mar 2018 12:18:13 -0400 Subject: Fix maximized windows interaction with layer shell If there were no layer surfaces the usable area of the output would be an empty box. --- rootston/layer_shell.c | 31 +++++-------------------------- rootston/output.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 26 deletions(-) (limited to 'rootston') diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c index 06ab15c3..edfaf5ea 100644 --- a/rootston/layer_shell.c +++ b/rootston/layer_shell.c @@ -82,7 +82,7 @@ static void arrange_layer(struct wlr_output *output, struct wl_list *list, wl_list_for_each(roots_surface, list, link) { struct wlr_layer_surface *layer = roots_surface->layer_surface; struct wlr_layer_surface_state *state = &layer->current; - if (exclusive != (state->exclusive_zone >0)) { + if (exclusive != (state->exclusive_zone > 0)) { continue; } struct wlr_box bounds; @@ -152,9 +152,7 @@ static void arrange_layer(struct wlr_output *output, struct wl_list *list, } } -static void arrange_layers(struct wlr_output *_output) { - struct roots_output *output = _output->data; - +void arrange_layers(struct roots_output *output) { struct wlr_box usable_area = { 0 }; wlr_output_effective_resolution(output->wlr_output, &usable_area.width, &usable_area.height); @@ -204,18 +202,9 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) { wl_container_of(listener, layer, output_destroy); layer->layer_surface->output = NULL; wl_list_remove(&layer->output_destroy.link); - wl_list_remove(&layer->output_mode.link); wlr_layer_surface_close(layer->layer_surface); } -static void handle_output_mode(struct wl_listener *listener, void *data) { - arrange_layers((struct wlr_output *)data); -} - -static void handle_output_transform(struct wl_listener *listener, void *data) { - arrange_layers((struct wlr_output *)data); -} - static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_layer_surface *layer = wl_container_of(listener, layer, surface_commit); @@ -224,7 +213,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { if (wlr_output != NULL) { struct roots_output *output = wlr_output->data; struct wlr_box old_geo = layer->geo; - arrange_layers(wlr_output); + arrange_layers(output); if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) { output_damage_whole_local_surface(output, layer_surface->surface, old_geo.x, old_geo.y, 0); @@ -258,9 +247,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&layer->unmap.link); wl_list_remove(&layer->surface_commit.link); wl_list_remove(&layer->output_destroy.link); - wl_list_remove(&layer->output_mode.link); - wl_list_remove(&layer->output_transform.link); - arrange_layers(layer->layer_surface->output); + arrange_layers((struct roots_output *)layer->layer_surface->output->data); free(layer); } @@ -306,14 +293,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { wl_signal_add(&layer_surface->output->events.destroy, &roots_surface->output_destroy); - roots_surface->output_mode.notify = handle_output_mode; - wl_signal_add(&layer_surface->output->events.mode, - &roots_surface->output_mode); - - roots_surface->output_transform.notify = handle_output_transform; - wl_signal_add(&layer_surface->output->events.transform, - &roots_surface->output_transform); - roots_surface->destroy.notify = handle_destroy; wl_signal_add(&layer_surface->events.destroy, &roots_surface->destroy); roots_surface->map.notify = handle_map; @@ -333,7 +312,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { struct wlr_layer_surface_state old_state = layer_surface->current; layer_surface->current = layer_surface->client_pending; - arrange_layers(output->wlr_output); + arrange_layers(output); layer_surface->current = old_state; } diff --git a/rootston/output.c b/rootston/output.c index d903963e..bf2bbdc2 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -816,6 +816,18 @@ static void output_damage_handle_destroy(struct wl_listener *listener, output_destroy(output); } +static void output_handle_mode(struct wl_listener *listener, void *data) { + struct roots_output *output = + wl_container_of(listener, output, mode); + arrange_layers(output); +} + +static void output_handle_transform(struct wl_listener *listener, void *data) { + struct roots_output *output = + wl_container_of(listener, output, transform); + arrange_layers(output); +} + void handle_new_output(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, new_output); @@ -845,6 +857,11 @@ void handle_new_output(struct wl_listener *listener, void *data) { output->destroy.notify = output_handle_destroy; wl_signal_add(&wlr_output->events.destroy, &output->destroy); + output->mode.notify = output_handle_mode; + wl_signal_add(&wlr_output->events.mode, &output->mode); + output->transform.notify = output_handle_transform; + wl_signal_add(&wlr_output->events.transform, &output->transform); + output->damage_frame.notify = output_damage_handle_frame; wl_signal_add(&output->damage->events.frame, &output->damage_frame); output->damage_destroy.notify = output_damage_handle_destroy; @@ -879,5 +896,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { roots_seat_configure_xcursor(seat); } + arrange_layers(output); output_damage_whole(output); } -- cgit v1.2.3