diff --git a/include/desktop/output.h b/include/desktop/output.h index 8794ae2..cbcdbde 100644 --- a/include/desktop/output.h +++ b/include/desktop/output.h @@ -43,4 +43,6 @@ struct kiwmi_render_data { void new_output_notify(struct wl_listener *listener, void *data); +void output_damage(struct kiwmi_output *output); + #endif /* KIWMI_DESKTOP_OUTPUT_H */ diff --git a/kiwmi/desktop/layer_shell.c b/kiwmi/desktop/layer_shell.c index b00bced..d35ba6d 100644 --- a/kiwmi/desktop/layer_shell.c +++ b/kiwmi/desktop/layer_shell.c @@ -15,6 +15,7 @@ #include #include "desktop/desktop.h" +#include "desktop/output.h" #include "input/seat.h" #include "server.h" @@ -57,7 +58,7 @@ kiwmi_layer_commit_notify(struct wl_listener *listener, void *UNUSED(data)) } if (buffer_changed || layer_changed || geom_changed) { - output->damaged = 2; + output_damage(layer->output); } } @@ -66,7 +67,7 @@ kiwmi_layer_map_notify(struct wl_listener *listener, void *UNUSED(data)) { struct kiwmi_layer *layer = wl_container_of(listener, layer, map); - layer->output->damaged = 2; + output_damage(layer->output); } static void @@ -74,7 +75,7 @@ kiwmi_layer_unmap_notify(struct wl_listener *listener, void *UNUSED(data)) { struct kiwmi_layer *layer = wl_container_of(listener, layer, unmap); - layer->output->damaged = 2; + output_damage(layer->output); } static void diff --git a/kiwmi/desktop/output.c b/kiwmi/desktop/output.c index bb64f72..1df1b42 100644 --- a/kiwmi/desktop/output.c +++ b/kiwmi/desktop/output.c @@ -181,7 +181,7 @@ output_frame_notify(struct wl_listener *listener, void *data) } if (render_cursors(wlr_output)) { - output->damaged = 2; + output_damage(output); } wlr_output_commit(wlr_output); @@ -236,13 +236,14 @@ output_frame_notify(struct wl_listener *listener, void *data) render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &rdata); render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &rdata); - if (render_cursors(wlr_output)) { - output->damaged = 3; - } - + bool damaged = render_cursors(wlr_output); wlr_renderer_end(renderer); - --output->damaged; + if (damaged) { + output_damage(output); + } else { + --output->damaged; + } wlr_output_commit(wlr_output); } @@ -255,7 +256,7 @@ output_commit_notify(struct wl_listener *listener, void *data) if (event->committed & WLR_OUTPUT_STATE_TRANSFORM) { arrange_layers(output); - output->damaged = 2; + output_damage(output); wl_signal_emit(&output->events.resize, output); } @@ -284,7 +285,7 @@ output_mode_notify(struct wl_listener *listener, void *UNUSED(data)) struct kiwmi_output *output = wl_container_of(listener, output, mode); arrange_layers(output); - output->damaged = 2; + output_damage(output); wl_signal_emit(&output->events.resize, output); } @@ -303,8 +304,6 @@ output_create(struct wlr_output *wlr_output, struct kiwmi_desktop *desktop) output->usable_area.width = wlr_output->width; output->usable_area.height = wlr_output->height; - output->damaged = 2; - output->frame.notify = output_frame_notify; wl_signal_add(&wlr_output->events.frame, &output->frame); @@ -317,6 +316,8 @@ output_create(struct wlr_output *wlr_output, struct kiwmi_desktop *desktop) output->mode.notify = output_mode_notify; wl_signal_add(&wlr_output->events.mode, &output->mode); + output_damage(output); + return output; } @@ -370,3 +371,9 @@ new_output_notify(struct wl_listener *listener, void *data) wl_signal_emit(&desktop->events.new_output, output); } + +void +output_damage(struct kiwmi_output *output) +{ + output->damaged = 2; +} diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 1ccf00d..62023d0 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -88,7 +88,7 @@ view_set_size(struct kiwmi_view *view, uint32_t width, uint32_t height) struct kiwmi_output *output; wl_list_for_each (output, &view->desktop->outputs, link) { - output->damaged = 2; + output_damage(output); } } } @@ -101,7 +101,7 @@ view_set_pos(struct kiwmi_view *view, uint32_t x, uint32_t y) struct kiwmi_output *output; wl_list_for_each (output, &view->desktop->outputs, link) { - output->damaged = 2; + output_damage(output); } } diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index a90b563..b0e7302 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -16,6 +16,7 @@ #include #include "desktop/desktop.h" +#include "desktop/output.h" #include "desktop/view.h" #include "input/input.h" #include "input/seat.h" @@ -29,7 +30,7 @@ xdg_surface_map_notify(struct wl_listener *listener, void *UNUSED(data)) struct kiwmi_output *output; wl_list_for_each (output, &view->desktop->outputs, link) { - output->damaged = 2; + output_damage(output); } wl_signal_emit(&view->desktop->events.view_map, view); @@ -45,7 +46,7 @@ xdg_surface_unmap_notify(struct wl_listener *listener, void *UNUSED(data)) struct kiwmi_output *output; wl_list_for_each (output, &view->desktop->outputs, link) { - output->damaged = 2; + output_damage(output); } wl_signal_emit(&view->events.unmap, view); @@ -60,7 +61,7 @@ xdg_surface_commit_notify(struct wl_listener *listener, void *UNUSED(data)) if (pixman_region32_not_empty(&view->wlr_surface->buffer_damage)) { struct kiwmi_output *output; wl_list_for_each (output, &view->desktop->outputs, link) { - output->damaged = 2; + output_damage(output); } } diff --git a/kiwmi/input/seat.c b/kiwmi/input/seat.c index 73d5d8f..33bb5c3 100644 --- a/kiwmi/input/seat.c +++ b/kiwmi/input/seat.c @@ -116,7 +116,7 @@ request_set_cursor_notify(struct wl_listener *listener, void *data) struct kiwmi_output *output; wl_list_for_each (output, &server->desktop.outputs, link) { - output->damaged = 2; + output_damage(output); } wlr_cursor_set_surface(