From 1e018e72b4d57c8f354b9be9686a7a75797cdcab Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 6 Apr 2023 22:23:53 +0200 Subject: Delete old damage tracking code The new scene graph abstraction handles this for us. --- sway/commands/client.c | 5 - sway/commands/opacity.c | 1 - sway/commands/show_marks.c | 5 - sway/commands/title_align.c | 5 - sway/commands/titlebar_border_thickness.c | 1 - sway/commands/titlebar_padding.c | 1 - sway/config/output.c | 4 - sway/desktop/desktop.c | 40 ----- sway/desktop/output.c | 240 ------------------------------ sway/desktop/transaction.c | 18 --- sway/desktop/xdg_shell.c | 20 --- sway/input/seatop_move_floating.c | 3 - sway/meson.build | 1 - sway/tree/container.c | 6 - sway/tree/view.c | 30 ---- sway/tree/workspace.c | 1 - 16 files changed, 381 deletions(-) delete mode 100644 sway/desktop/desktop.c (limited to 'sway') diff --git a/sway/commands/client.c b/sway/commands/client.c index 7a9cff2c..fd2ac7a8 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -51,11 +51,6 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, if (config->active) { root_for_each_container(container_update_iterator, NULL); - - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_whole(output); - } } return cmd_results_new(CMD_SUCCESS, NULL); diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index 96e6228e..1c44a646 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c @@ -37,6 +37,5 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { } con->alpha = val; - container_damage_whole(con); return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c index f738144f..fecb5ade 100644 --- a/sway/commands/show_marks.c +++ b/sway/commands/show_marks.c @@ -26,10 +26,5 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) { root_for_each_container(title_bar_update_iterator, NULL); } - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_whole(output); - } - return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/title_align.c b/sway/commands/title_align.c index 7f5dd3ae..be298a29 100644 --- a/sway/commands/title_align.c +++ b/sway/commands/title_align.c @@ -27,10 +27,5 @@ struct cmd_results *cmd_title_align(int argc, char **argv) { root_for_each_container(arrange_title_bar_iterator, NULL); - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_whole(output); - } - return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/titlebar_border_thickness.c b/sway/commands/titlebar_border_thickness.c index 7c27c163..fa3db3c5 100644 --- a/sway/commands/titlebar_border_thickness.c +++ b/sway/commands/titlebar_border_thickness.c @@ -27,7 +27,6 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) { "Expected output to have a workspace"); } arrange_workspace(ws); - output_damage_whole(output); } return cmd_results_new(CMD_SUCCESS, NULL); diff --git a/sway/commands/titlebar_padding.c b/sway/commands/titlebar_padding.c index 29ce59ff..6999f7a2 100644 --- a/sway/commands/titlebar_padding.c +++ b/sway/commands/titlebar_padding.c @@ -33,7 +33,6 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) { for (int i = 0; i < root->outputs->length; ++i) { struct sway_output *output = root->outputs->items[i]; arrange_workspace(output_get_active_workspace(output)); - output_damage_whole(output); } return cmd_results_new(CMD_SUCCESS, NULL); diff --git a/sway/config/output.c b/sway/config/output.c index 3316085a..66baf194 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -538,10 +538,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { return true; } - if (config->reloading) { - output_damage_whole(output); - } - if (oc) { enum scale_filter_mode scale_filter_old = output->scale_filter; switch (oc->scale_filter) { diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c deleted file mode 100644 index c8d4502c..00000000 --- a/sway/desktop/desktop.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "sway/tree/container.h" -#include "sway/desktop.h" -#include "sway/output.h" - -void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly, - bool whole) { - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - struct wlr_box output_box; - wlr_output_layout_get_box(root->output_layout, - output->wlr_output, &output_box); - output_damage_surface(output, lx - output_box.x, - ly - output_box.y, surface, whole); - } -} - -void desktop_damage_whole_container(struct sway_container *con) { - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_whole_container(output, con); - } -} - -void desktop_damage_box(struct wlr_box *box) { - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_box(output, box); - } -} - -void desktop_damage_view(struct sway_view *view) { - desktop_damage_whole_container(view->container); - struct wlr_box box = { - .x = view->container->current.content_x - view->geometry.x, - .y = view->container->current.content_y - view->geometry.y, - .width = view->surface->current.width, - .height = view->surface->current.height, - }; - desktop_damage_box(&box); -} diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 36c8f52c..aea2a8d7 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -71,127 +71,6 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id) { return NULL; } -struct surface_iterator_data { - sway_surface_iterator_func_t user_iterator; - void *user_data; - - struct sway_output *output; - struct sway_view *view; - double ox, oy; - int width, height; -}; - -static bool get_surface_box(struct surface_iterator_data *data, - struct wlr_surface *surface, int sx, int sy, - struct wlr_box *surface_box) { - struct sway_output *output = data->output; - - if (!wlr_surface_has_buffer(surface)) { - return false; - } - - int sw = surface->current.width; - int sh = surface->current.height; - - struct wlr_box box = { - .x = floor(data->ox + sx), - .y = floor(data->oy + sy), - .width = sw, - .height = sh, - }; - if (surface_box != NULL) { - memcpy(surface_box, &box, sizeof(struct wlr_box)); - } - - struct wlr_box output_box = { - .width = output->width, - .height = output->height, - }; - - struct wlr_box intersection; - return wlr_box_intersection(&intersection, &output_box, &box); -} - -static void output_for_each_surface_iterator(struct wlr_surface *surface, - int sx, int sy, void *_data) { - struct surface_iterator_data *data = _data; - - struct wlr_box box; - bool intersects = get_surface_box(data, surface, sx, sy, &box); - if (!intersects) { - return; - } - - data->user_iterator(data->output, data->view, surface, &box, - data->user_data); -} - -void output_surface_for_each_surface(struct sway_output *output, - struct wlr_surface *surface, double ox, double oy, - sway_surface_iterator_func_t iterator, void *user_data) { - struct surface_iterator_data data = { - .user_iterator = iterator, - .user_data = user_data, - .output = output, - .view = NULL, - .ox = ox, - .oy = oy, - .width = surface->current.width, - .height = surface->current.height, - }; - - wlr_surface_for_each_surface(surface, - output_for_each_surface_iterator, &data); -} - -void output_view_for_each_surface(struct sway_output *output, - struct sway_view *view, sway_surface_iterator_func_t iterator, - void *user_data) { - struct surface_iterator_data data = { - .user_iterator = iterator, - .user_data = user_data, - .output = output, - .view = view, - .ox = view->container->surface_x - output->lx - - view->geometry.x, - .oy = view->container->surface_y - output->ly - - view->geometry.y, - .width = view->container->current.content_width, - .height = view->container->current.content_height, - }; - - view_for_each_surface(view, output_for_each_surface_iterator, &data); -} - -void output_view_for_each_popup_surface(struct sway_output *output, - struct sway_view *view, sway_surface_iterator_func_t iterator, - void *user_data) { - struct surface_iterator_data data = { - .user_iterator = iterator, - .user_data = user_data, - .output = output, - .view = view, - .ox = view->container->surface_x - output->lx - - view->geometry.x, - .oy = view->container->surface_y - output->ly - - view->geometry.y, - .width = view->container->current.content_width, - .height = view->container->current.content_height, - }; - - view_for_each_popup_surface(view, output_for_each_surface_iterator, &data); -} - -static int scale_length(int length, int offset, float scale) { - return roundf((offset + length) * scale) - roundf(offset * scale); -} - -void scale_box(struct wlr_box *box, float scale) { - box->width = scale_length(box->width, box->x, scale); - box->height = scale_length(box->height, box->y, scale); - box->x = roundf(box->x * scale); - box->y = roundf(box->y * scale); -} struct sway_workspace *output_get_active_workspace(struct sway_output *output) { struct sway_seat *seat = input_manager_current_seat(); @@ -339,9 +218,6 @@ static int output_repaint_timer_handler(void *data) { } wlr_scene_output_commit(output->scene_output, NULL); - - wlr_damage_ring_rotate(&output->damage_ring); - return 0; } @@ -409,107 +285,6 @@ static void handle_frame(struct wl_listener *listener, void *user_data) { wlr_scene_output_for_each_buffer(output->scene_output, send_frame_done_iterator, &data); } -void output_damage_whole(struct sway_output *output) { - // The output can exist with no wlr_output if it's just been disconnected - // and the transaction to evacuate it has't completed yet. - if (output != NULL && output->wlr_output != NULL) { - wlr_damage_ring_add_whole(&output->damage_ring); - wlr_output_schedule_frame(output->wlr_output); - } -} - -static void damage_surface_iterator(struct sway_output *output, - struct sway_view *view, struct wlr_surface *surface, - struct wlr_box *_box, void *_data) { - bool *data = _data; - bool whole = *data; - - struct wlr_box box = *_box; - scale_box(&box, output->wlr_output->scale); - - pixman_region32_t damage; - pixman_region32_init(&damage); - wlr_surface_get_effective_damage(surface, &damage); - wlr_region_scale(&damage, &damage, output->wlr_output->scale); - if (ceilf(output->wlr_output->scale) > surface->current.scale) { - // When scaling up a surface, it'll become blurry so we need to - // expand the damage region - wlr_region_expand(&damage, &damage, - ceilf(output->wlr_output->scale) - surface->current.scale); - } - pixman_region32_translate(&damage, box.x, box.y); - if (wlr_damage_ring_add(&output->damage_ring, &damage)) { - wlr_output_schedule_frame(output->wlr_output); - } - pixman_region32_fini(&damage); - - if (whole) { - if (wlr_damage_ring_add_box(&output->damage_ring, &box)) { - wlr_output_schedule_frame(output->wlr_output); - } - } - - if (!wl_list_empty(&surface->current.frame_callback_list)) { - wlr_output_schedule_frame(output->wlr_output); - } -} - -void output_damage_surface(struct sway_output *output, double ox, double oy, - struct wlr_surface *surface, bool whole) { - output_surface_for_each_surface(output, surface, ox, oy, - damage_surface_iterator, &whole); -} - -void output_damage_from_view(struct sway_output *output, - struct sway_view *view) { - if (!view_is_visible(view)) { - return; - } - bool whole = false; - output_view_for_each_surface(output, view, damage_surface_iterator, &whole); -} - -// Expecting an unscaled box in layout coordinates -void output_damage_box(struct sway_output *output, struct wlr_box *_box) { - struct wlr_box box; - memcpy(&box, _box, sizeof(struct wlr_box)); - box.x -= output->lx; - box.y -= output->ly; - scale_box(&box, output->wlr_output->scale); - if (wlr_damage_ring_add_box(&output->damage_ring, &box)) { - wlr_output_schedule_frame(output->wlr_output); - } -} - -static void damage_child_views_iterator(struct sway_container *con, - void *data) { - if (!con->view || !view_is_visible(con->view)) { - return; - } - struct sway_output *output = data; - bool whole = true; - output_view_for_each_surface(output, con->view, damage_surface_iterator, - &whole); -} - -void output_damage_whole_container(struct sway_output *output, - struct sway_container *con) { - // Pad the box by 1px, because the width is a double and might be a fraction - struct wlr_box box = { - .x = con->current.x - output->lx - 1, - .y = con->current.y - output->ly - 1, - .width = con->current.width + 2, - .height = con->current.height + 2, - }; - scale_box(&box, output->wlr_output->scale); - // Damage subsurfaces as well, which may extend outside the box - if (con->view) { - damage_child_views_iterator(con, output); - } else { - container_for_each_child(con, damage_child_views_iterator, output); - } -} - static void update_output_manager_config(struct sway_server *server) { struct wlr_output_configuration_v1 *config = wlr_output_configuration_v1_create(); @@ -553,8 +328,6 @@ static void begin_destroy(struct sway_output *output) { wl_list_remove(&output->frame.link); wl_list_remove(&output->request_state.link); - wlr_damage_ring_finish(&output->damage_ring); - wlr_scene_output_destroy(output->scene_output); output->scene_output = NULL; output->wlr_output->data = NULL; @@ -594,15 +367,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { update_output_manager_config(output->server); } - if (event->state->committed & ( - WLR_OUTPUT_STATE_MODE | - WLR_OUTPUT_STATE_TRANSFORM)) { - int width, height; - wlr_output_transformed_resolution(output->wlr_output, &width, &height); - wlr_damage_ring_set_bounds(&output->damage_ring, width, height); - wlr_output_schedule_frame(output->wlr_output); - } - // Next time the output is enabled, try to re-apply the gamma LUT if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { output->gamma_lut_changed = true; @@ -684,7 +448,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { output->server = server; output->scene_output = scene_output; - wlr_damage_ring_init(&output->damage_ring); wl_signal_add(&root->output_layout->events.destroy, &output->layout_destroy); output->layout_destroy.notify = handle_layout_destroy; @@ -712,9 +475,6 @@ void handle_new_output(struct wl_listener *listener, void *data) { transaction_commit_dirty(); - int width, height; - wlr_output_transformed_resolution(output->wlr_output, &width, &height); - wlr_damage_ring_set_bounds(&output->damage_ring, width, height); update_output_manager_config(server); } diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 1ae6642b..5f104aa3 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -5,7 +5,6 @@ #include #include #include "sway/config.h" -#include "sway/desktop.h" #include "sway/desktop/idle_inhibit_v1.h" #include "sway/desktop/transaction.h" #include "sway/input/cursor.h" @@ -214,19 +213,15 @@ static void transaction_add_node(struct sway_transaction *transaction, static void apply_output_state(struct sway_output *output, struct sway_output_state *state) { - output_damage_whole(output); list_free(output->current.workspaces); memcpy(&output->current, state, sizeof(struct sway_output_state)); - output_damage_whole(output); } static void apply_workspace_state(struct sway_workspace *ws, struct sway_workspace_state *state) { - output_damage_whole(ws->current.output); list_free(ws->current.floating); list_free(ws->current.tiling); memcpy(&ws->current, state, sizeof(struct sway_workspace_state)); - output_damage_whole(ws->current.output); } static void apply_container_state(struct sway_container *container, @@ -256,19 +251,6 @@ static void apply_container_state(struct sway_container *container, } } - // Damage the new location - desktop_damage_whole_container(container); - if (view && view->surface) { - struct wlr_surface *surface = view->surface; - struct wlr_box box = { - .x = container->current.content_x - view->geometry.x, - .y = container->current.content_y - view->geometry.y, - .width = surface->current.width, - .height = surface->current.height, - }; - desktop_damage_box(&box); - } - if (!container->node.destroying) { container_discover_outputs(container); } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 95b5cb9d..48b7b4c7 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -214,24 +214,6 @@ static bool wants_floating(struct sway_view *view) { || toplevel->parent; } -static void for_each_surface(struct sway_view *view, - wlr_surface_iterator_func_t iterator, void *user_data) { - if (xdg_shell_view_from_view(view) == NULL) { - return; - } - wlr_xdg_surface_for_each_surface(view->wlr_xdg_toplevel->base, iterator, - user_data); -} - -static void for_each_popup_surface(struct sway_view *view, - wlr_surface_iterator_func_t iterator, void *user_data) { - if (xdg_shell_view_from_view(view) == NULL) { - return; - } - wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_toplevel->base, - iterator, user_data); -} - static bool is_transient_for(struct sway_view *child, struct sway_view *ancestor) { if (xdg_shell_view_from_view(child) == NULL) { @@ -279,8 +261,6 @@ static const struct sway_view_impl view_impl = { .set_fullscreen = set_fullscreen, .set_resizing = set_resizing, .wants_floating = wants_floating, - .for_each_surface = for_each_surface, - .for_each_popup_surface = for_each_popup_surface, .is_transient_for = is_transient_for, .close = _close, .close_popups = close_popups, diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index ddcd4c53..21d048ce 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c @@ -1,6 +1,5 @@ #define _POSIX_C_SOURCE 200809L #include -#include "sway/desktop.h" #include "sway/desktop/transaction.h" #include "sway/input/cursor.h" #include "sway/input/seat.h" @@ -39,9 +38,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { struct seatop_move_floating_event *e = seat->seatop_data; struct wlr_cursor *cursor = seat->cursor->cursor; - desktop_damage_whole_container(e->con); container_floating_move_to(e->con, cursor->x - e->dx, cursor->y - e->dy); - desktop_damage_whole_container(e->con); transaction_commit_dirty(); } diff --git a/sway/meson.build b/sway/meson.build index 110de58c..1079c749 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -15,7 +15,6 @@ sway_sources = files( 'xdg_activation_v1.c', 'xdg_decoration.c', - 'desktop/desktop.c', 'desktop/idle_inhibit_v1.c', 'desktop/layer_shell.c', 'desktop/output.c', diff --git a/sway/tree/container.c b/sway/tree/container.c index 4aae4d32..cde9dff5 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -597,12 +597,6 @@ bool container_has_ancestor(struct sway_container *descendant, return false; } -void container_damage_whole(struct sway_container *container) { - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_whole_container(output, container); - } -} /** * Return the output which will be used for scale purposes. diff --git a/sway/tree/view.c b/sway/tree/view.c index 402fa179..2874e88b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -16,7 +16,6 @@ #include "log.h" #include "sway/criteria.h" #include "sway/commands.h" -#include "sway/desktop.h" #include "sway/desktop/transaction.h" #include "sway/desktop/idle_inhibit_v1.h" #include "sway/desktop/launcher.h" @@ -456,34 +455,6 @@ void view_close_popups(struct sway_view *view) { } } -void view_damage_from(struct sway_view *view) { - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - output_damage_from_view(output, view); - } -} - -void view_for_each_surface(struct sway_view *view, - wlr_surface_iterator_func_t iterator, void *user_data) { - if (!view->surface) { - return; - } - if (view->impl->for_each_surface) { - view->impl->for_each_surface(view, iterator, user_data); - } else { - wlr_surface_for_each_surface(view->surface, iterator, user_data); - } -} - -void view_for_each_popup_surface(struct sway_view *view, - wlr_surface_iterator_func_t iterator, void *user_data) { - if (!view->surface) { - return; - } - if (view->impl->for_each_popup_surface) { - view->impl->for_each_popup_surface(view, iterator, user_data); - } -} static bool view_has_executed_criteria(struct sway_view *view, struct criteria *criteria) { for (int i = 0; i < view->executed_criteria->length; ++i) { @@ -1143,7 +1114,6 @@ void view_set_urgent(struct sway_view *view, bool enable) { view->urgent_timer = NULL; } } - container_damage_whole(view->container); ipc_event_window(view->container, "urgent"); diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index f60b2366..40d33435 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -686,7 +686,6 @@ void workspace_detect_urgent(struct sway_workspace *workspace) { if (workspace->urgent != new_urgent) { workspace->urgent = new_urgent; ipc_event_workspace(NULL, workspace, "urgent"); - output_damage_whole(workspace->output); } } -- cgit v1.2.3