diff options
Diffstat (limited to 'sway/desktop/layer_shell.c')
-rw-r--r-- | sway/desktop/layer_shell.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 137b3260..f7e5d19c 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -156,7 +156,6 @@ void arrange_layers(struct sway_output *output) { | |||
156 | struct wlr_box usable_area = { 0 }; | 156 | struct wlr_box usable_area = { 0 }; |
157 | wlr_output_effective_resolution(output->wlr_output, | 157 | wlr_output_effective_resolution(output->wlr_output, |
158 | &usable_area.width, &usable_area.height); | 158 | &usable_area.width, &usable_area.height); |
159 | struct wlr_box usable_area_before = output->usable_area; | ||
160 | 159 | ||
161 | // Arrange exclusive surfaces from top->bottom | 160 | // Arrange exclusive surfaces from top->bottom |
162 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], | 161 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], |
@@ -167,11 +166,11 @@ void arrange_layers(struct sway_output *output) { | |||
167 | &usable_area, true); | 166 | &usable_area, true); |
168 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], | 167 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], |
169 | &usable_area, true); | 168 | &usable_area, true); |
170 | memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box)); | ||
171 | 169 | ||
172 | if (memcmp(&usable_area_before, | 170 | if (memcmp(&usable_area, &output->usable_area, |
173 | &usable_area, sizeof(struct wlr_box)) != 0) { | 171 | sizeof(struct wlr_box)) != 0) { |
174 | wlr_log(L_DEBUG, "arrange"); | 172 | wlr_log(L_DEBUG, "Usable area changed, rearranging output"); |
173 | memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box)); | ||
175 | arrange_windows(output->swayc, -1, -1); | 174 | arrange_windows(output->swayc, -1, -1); |
176 | } | 175 | } |
177 | 176 | ||
@@ -193,22 +192,10 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) { | |||
193 | struct sway_layer_surface *sway_layer = | 192 | struct sway_layer_surface *sway_layer = |
194 | wl_container_of(listener, sway_layer, output_destroy); | 193 | wl_container_of(listener, sway_layer, output_destroy); |
195 | wl_list_remove(&sway_layer->output_destroy.link); | 194 | wl_list_remove(&sway_layer->output_destroy.link); |
196 | wl_list_remove(&sway_layer->output_mode.link); | ||
197 | wl_list_remove(&sway_layer->output_transform.link); | ||
198 | sway_layer->layer_surface->output = NULL; | 195 | sway_layer->layer_surface->output = NULL; |
199 | wlr_layer_surface_close(sway_layer->layer_surface); | 196 | wlr_layer_surface_close(sway_layer->layer_surface); |
200 | } | 197 | } |
201 | 198 | ||
202 | static void handle_output_mode(struct wl_listener *listener, void *data) { | ||
203 | struct wlr_output *output = data; | ||
204 | arrange_layers((struct sway_output *)output->data); | ||
205 | } | ||
206 | |||
207 | static void handle_output_transform(struct wl_listener *listener, void *data) { | ||
208 | struct wlr_output *output = data; | ||
209 | arrange_layers((struct sway_output *)output->data); | ||
210 | } | ||
211 | |||
212 | static void handle_surface_commit(struct wl_listener *listener, void *data) { | 199 | static void handle_surface_commit(struct wl_listener *listener, void *data) { |
213 | struct sway_layer_surface *layer = | 200 | struct sway_layer_surface *layer = |
214 | wl_container_of(listener, layer, surface_commit); | 201 | wl_container_of(listener, layer, surface_commit); |
@@ -233,6 +220,8 @@ static void unmap(struct wlr_layer_surface *layer_surface) { | |||
233 | static void handle_destroy(struct wl_listener *listener, void *data) { | 220 | static void handle_destroy(struct wl_listener *listener, void *data) { |
234 | struct sway_layer_surface *sway_layer = wl_container_of( | 221 | struct sway_layer_surface *sway_layer = wl_container_of( |
235 | listener, sway_layer, destroy); | 222 | listener, sway_layer, destroy); |
223 | wlr_log(L_DEBUG, "Layer surface destroyed (%s)", | ||
224 | sway_layer->layer_surface->namespace); | ||
236 | if (sway_layer->layer_surface->mapped) { | 225 | if (sway_layer->layer_surface->mapped) { |
237 | unmap(sway_layer->layer_surface); | 226 | unmap(sway_layer->layer_surface); |
238 | } | 227 | } |
@@ -243,12 +232,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
243 | wl_list_remove(&sway_layer->surface_commit.link); | 232 | wl_list_remove(&sway_layer->surface_commit.link); |
244 | if (sway_layer->layer_surface->output != NULL) { | 233 | if (sway_layer->layer_surface->output != NULL) { |
245 | wl_list_remove(&sway_layer->output_destroy.link); | 234 | wl_list_remove(&sway_layer->output_destroy.link); |
246 | wl_list_remove(&sway_layer->output_mode.link); | ||
247 | wl_list_remove(&sway_layer->output_transform.link); | ||
248 | } | 235 | } |
249 | struct sway_output *output = sway_layer->layer_surface->output->data; | 236 | struct sway_output *output = sway_layer->layer_surface->output->data; |
250 | arrange_layers(output); | ||
251 | free(sway_layer); | 237 | free(sway_layer); |
238 | arrange_layers(output); | ||
252 | } | 239 | } |
253 | 240 | ||
254 | static void handle_map(struct wl_listener *listener, void *data) { | 241 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -289,14 +276,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | |||
289 | wl_signal_add(&layer_surface->output->events.destroy, | 276 | wl_signal_add(&layer_surface->output->events.destroy, |
290 | &sway_layer->output_destroy); | 277 | &sway_layer->output_destroy); |
291 | 278 | ||
292 | sway_layer->output_mode.notify = handle_output_mode; | ||
293 | wl_signal_add(&layer_surface->output->events.mode, | ||
294 | &sway_layer->output_mode); | ||
295 | |||
296 | sway_layer->output_transform.notify = handle_output_transform; | ||
297 | wl_signal_add(&layer_surface->output->events.transform, | ||
298 | &sway_layer->output_transform); | ||
299 | |||
300 | sway_layer->destroy.notify = handle_destroy; | 279 | sway_layer->destroy.notify = handle_destroy; |
301 | wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); | 280 | wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); |
302 | sway_layer->map.notify = handle_map; | 281 | sway_layer->map.notify = handle_map; |