From 8d6bce02afc656bf792815ed68121f4e614cd175 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 28 Mar 2018 18:10:43 -0400 Subject: Address review feedback --- sway/config/output.c | 2 +- sway/desktop/layer_shell.c | 11 +++++++---- sway/desktop/output.c | 36 +++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 22 deletions(-) (limited to 'sway') diff --git a/sway/config/output.c b/sway/config/output.c index c4168b4f..9e211861 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include #include "sway/config.h" #include "sway/output.h" #include "log.h" diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index a2506d21..bd62f84a 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -192,9 +192,10 @@ void arrange_layers(struct sway_output *output) { static void handle_output_destroy(struct wl_listener *listener, void *data) { struct sway_layer_surface *sway_layer = wl_container_of(listener, sway_layer, output_destroy); - sway_layer->layer_surface->output = NULL; wl_list_remove(&sway_layer->output_destroy.link); wl_list_remove(&sway_layer->output_mode.link); + wl_list_remove(&sway_layer->output_transform.link); + sway_layer->layer_surface->output = NULL; wlr_layer_surface_close(sway_layer->layer_surface); } @@ -240,9 +241,11 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&sway_layer->map.link); wl_list_remove(&sway_layer->unmap.link); wl_list_remove(&sway_layer->surface_commit.link); - wl_list_remove(&sway_layer->output_destroy.link); - wl_list_remove(&sway_layer->output_mode.link); - wl_list_remove(&sway_layer->output_transform.link); + if (sway_layer->layer_surface->output != NULL) { + wl_list_remove(&sway_layer->output_destroy.link); + wl_list_remove(&sway_layer->output_mode.link); + wl_list_remove(&sway_layer->output_transform.link); + } struct sway_output *output = sway_layer->layer_surface->output->data; arrange_layers(output); free(sway_layer); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 59f79a81..9e7fbcc6 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -81,9 +81,7 @@ static void render_surface(struct wlr_surface *surface, rotate_child_position(&sx, &sy, sw, sh, width, height, rotation); render_surface(subsurface->surface, wlr_output, when, - lx + sx, - ly + sy, - rotation); + lx + sx, ly + sy, rotation); } } @@ -142,9 +140,15 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface, } } +struct render_data { + struct sway_output *output; + struct timespec *now; +}; static void output_frame_view(swayc_t *view, void *data) { - struct sway_output *output = data; + struct render_data *rdata = data; + struct sway_output *output = rdata->output; + struct timespec *now = rdata->now; struct wlr_output *wlr_output = output->wlr_output; struct sway_view *sway_view = view->sway_view; struct wlr_surface *surface = sway_view->surface; @@ -157,23 +161,18 @@ static void output_frame_view(swayc_t *view, void *data) { case SWAY_XDG_SHELL_V6_VIEW: { int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry.x; int window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry.y; - render_surface(surface, wlr_output, &output->last_frame, - view->x - window_offset_x, - view->y - window_offset_y, - 0); + render_surface(surface, wlr_output, now, + view->x - window_offset_x, view->y - window_offset_y, 0); render_xdg_v6_popups(sway_view->wlr_xdg_surface_v6, wlr_output, - &output->last_frame, - view->x - window_offset_x, view->y - window_offset_y, - 0); + now, view->x - window_offset_x, view->y - window_offset_y, 0); break; } case SWAY_WL_SHELL_VIEW: render_wl_shell_surface(sway_view->wlr_wl_shell_surface, wlr_output, - &output->last_frame, view->x, view->y, 0, false); + now, view->x, view->y, 0, false); break; case SWAY_XWAYLAND_VIEW: - render_surface(surface, wlr_output, &output->last_frame, view->x, - view->y, 0); + render_surface(surface, wlr_output, now, view->x, view->y, 0); break; default: break; @@ -224,7 +223,11 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { focus : swayc_parent_by_type(focus, C_WORKSPACE)); - swayc_descendants_of_type(workspace, C_VIEW, output_frame_view, soutput); + struct render_data rdata = { + .output = soutput, + .now = &now, + }; + swayc_descendants_of_type(workspace, C_VIEW, output_frame_view, &rdata); // render unmanaged views on top struct sway_view *view; @@ -246,8 +249,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); wlr_renderer_end(server->renderer); - wlr_output_swap_buffers(wlr_output, &soutput->last_frame, NULL); - + wlr_output_swap_buffers(wlr_output, &now, NULL); soutput->last_frame = now; } -- cgit v1.2.3-54-g00ecf