From e9a476244df7a8886fc6fc6785251198ed76e601 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 18 Mar 2019 20:52:56 +1000 Subject: [PATCH] Remove debug tree This feature has served its purpose. It's better to use IPC now. --- include/sway/debug.h | 22 ----- include/sway/server.h | 14 ++++ include/sway/tree/root.h | 2 - sway/debug-tree.c | 161 ------------------------------------- sway/desktop/render.c | 7 -- sway/desktop/transaction.c | 6 -- sway/input/seat.c | 4 - sway/main.c | 3 - sway/meson.build | 1 - 9 files changed, 14 insertions(+), 206 deletions(-) delete mode 100644 include/sway/debug.h delete mode 100644 sway/debug-tree.c diff --git a/include/sway/debug.h b/include/sway/debug.h deleted file mode 100644 index 0e9bb0565..000000000 --- a/include/sway/debug.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SWAY_DEBUG_H -#define SWAY_DEBUG_H -#include - -struct sway_debug { - bool noatomic; // Ignore atomic layout updates - bool render_tree; // Render the tree overlay - bool txn_timings; // Log verbose messages about transactions - bool txn_wait; // Always wait for the timeout before applying - - enum { - DAMAGE_DEFAULT, // Default behaviour - DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged - DAMAGE_RERENDER, // Render the full output when any damage occurs - } damage; -}; - -extern struct sway_debug debug; - -void update_debug_tree(void); - -#endif diff --git a/include/sway/server.h b/include/sway/server.h index 5eef7c1a9..39cf4f18b 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -74,6 +74,20 @@ struct sway_server { struct sway_server server; +struct sway_debug { + bool noatomic; // Ignore atomic layout updates + bool txn_timings; // Log verbose messages about transactions + bool txn_wait; // Always wait for the timeout before applying + + enum { + DAMAGE_DEFAULT, // Default behaviour + DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged + DAMAGE_RERENDER, // Render the full output when any damage occurs + } damage; +}; + +struct sway_debug debug; + /* Prepares an unprivileged server_init by performing all privileged operations in advance */ bool server_privileged_prepare(struct sway_server *server); bool server_init(struct sway_server *server); diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index 9ff45eb5f..9f6cd3bb6 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h @@ -21,8 +21,6 @@ struct sway_root { #endif struct wl_list drag_icons; // sway_drag_icon::link - struct wlr_texture *debug_tree; - // Includes disabled outputs struct wl_list all_outputs; // sway_output::link diff --git a/sway/debug-tree.c b/sway/debug-tree.c deleted file mode 100644 index 0444bb3fd..000000000 --- a/sway/debug-tree.c +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include -#include -#include "config.h" -#include "sway/debug.h" -#include "sway/input/input-manager.h" -#include "sway/input/seat.h" -#include "sway/output.h" -#include "sway/server.h" -#include "sway/tree/container.h" -#include "sway/tree/root.h" -#include "sway/tree/workspace.h" -#include "cairo.h" -#include "config.h" -#include "pango.h" - -struct sway_debug debug; - -static const char *layout_to_str(enum sway_container_layout layout) { - switch (layout) { - case L_HORIZ: - return "L_HORIZ"; - case L_VERT: - return "L_VERT"; - case L_STACKED: - return "L_STACKED"; - case L_TABBED: - return "L_TABBED"; - case L_NONE: - return "L_NONE"; - } - return "L_NONE"; -} - -static char *get_string(struct sway_node *node) { - char *buffer = malloc(512); - switch (node->type) { - case N_ROOT: - snprintf(buffer, 512, "N_ROOT id:%zd %.fx%.f@%.f,%.f", node->id, - root->width, root->height, root->x, root->y); - break; - case N_OUTPUT: - snprintf(buffer, 512, "N_OUTPUT id:%zd '%s' %dx%d@%d,%d", node->id, - node->sway_output->wlr_output->name, - node->sway_output->width, - node->sway_output->height, - node->sway_output->lx, - node->sway_output->ly); - break; - case N_WORKSPACE: - snprintf(buffer, 512, "N_WORKSPACE id:%zd '%s' %s %dx%d@%.f,%.f", - node->id, node->sway_workspace->name, - layout_to_str(node->sway_workspace->layout), - node->sway_workspace->width, node->sway_workspace->height, - node->sway_workspace->x, node->sway_workspace->y); - break; - case N_CONTAINER: - snprintf(buffer, 512, "N_CONTAINER id:%zd '%s' %s %.fx%.f@%.f,%.f", - node->id, node->sway_container->title, - layout_to_str(node->sway_container->layout), - node->sway_container->width, node->sway_container->height, - node->sway_container->x, node->sway_container->y); - break; - } - return buffer; -} - -static list_t *get_children(struct sway_node *node) { - switch (node->type) { - case N_ROOT: - return root->outputs; - case N_OUTPUT: - return node->sway_output->workspaces; - case N_WORKSPACE: - return node->sway_workspace->tiling; - case N_CONTAINER: - return node->sway_container->children; - } - return NULL; -} - -static int draw_node(cairo_t *cairo, struct sway_node *node, - struct sway_node *focus, int x, int y) { - int text_width, text_height; - char *buffer = get_string(node); - get_text_size(cairo, "monospace", &text_width, &text_height, NULL, - 1, false, buffer); - cairo_save(cairo); - cairo_rectangle(cairo, x + 2, y, text_width - 2, text_height); - cairo_set_source_u32(cairo, 0xFFFFFFE0); - cairo_fill(cairo); - int height = text_height; - list_t *children = get_children(node); - if (children) { - for (int i = 0; i < children->length; ++i) { - // This is really dirty - the list contains specific structs but - // we're casting them as nodes. This works because node is the first - // item in each specific struct. This is acceptable because this is - // debug code. - struct sway_node *child = children->items[i]; - if (node_get_parent(child) == node) { - cairo_set_source_u32(cairo, 0x000000FF); - } else { - cairo_set_source_u32(cairo, 0xFF0000FF); - } - height += draw_node(cairo, child, focus, x + 10, y + height); - } - } - cairo_set_source_u32(cairo, 0xFFFFFFE0); - cairo_rectangle(cairo, x, y, 2, height); - cairo_fill(cairo); - cairo_restore(cairo); - cairo_move_to(cairo, x, y); - if (focus == node) { - cairo_set_source_u32(cairo, 0x0000FFFF); - } - pango_printf(cairo, "monospace", 1, false, buffer); - free(buffer); - return height; -} - -void update_debug_tree(void) { - if (!debug.render_tree) { - return; - } - - int width = 640, height = 480; - for (int i = 0; i < root->outputs->length; ++i) { - struct sway_output *output = root->outputs->items[i]; - if (output->width > width) { - width = output->width; - } - if (output->height > height) { - height = output->height; - } - } - cairo_surface_t *surface = - cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - cairo_t *cairo = cairo_create(surface); - PangoContext *pango = pango_cairo_create_context(cairo); - - struct sway_seat *seat = input_manager_current_seat(); - struct sway_node *focus = seat_get_focus(seat); - - cairo_set_source_u32(cairo, 0x000000FF); - draw_node(cairo, &root->node, focus, 0, 0); - - cairo_surface_flush(surface); - struct wlr_renderer *renderer = wlr_backend_get_renderer(server.backend); - if (root->debug_tree) { - wlr_texture_destroy(root->debug_tree); - } - unsigned char *data = cairo_image_surface_get_data(surface); - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); - struct wlr_texture *texture = wlr_texture_from_pixels(renderer, - WL_SHM_FORMAT_ARGB8888, stride, width, height, data); - root->debug_tree = texture; - cairo_surface_destroy(surface); - g_object_unref(pango); - cairo_destroy(cairo); -} diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 9e936bb53..7216e30bb 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -16,7 +16,6 @@ #include "log.h" #include "config.h" #include "sway/config.h" -#include "sway/debug.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "sway/layers.h" @@ -1075,12 +1074,6 @@ render_overlay: render_drag_icons(output, damage, &root->drag_icons); renderer_end: - if (debug.render_tree) { - wlr_renderer_scissor(renderer, NULL); - wlr_render_texture(renderer, root->debug_tree, - wlr_output->transform_matrix, 0, 40, 1); - } - wlr_renderer_scissor(renderer, NULL); wlr_output_render_software_cursors(wlr_output, damage); wlr_renderer_end(renderer); diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 4098ed22c..e5f0ee3d1 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -5,7 +5,6 @@ #include #include #include "sway/config.h" -#include "sway/debug.h" #include "sway/desktop.h" #include "sway/desktop/idle_inhibit_v1.h" #include "sway/desktop/transaction.h" @@ -465,11 +464,6 @@ static void transaction_commit(struct sway_transaction *transaction) { transaction->num_waiting = 0; } } - - // The debug tree shows the pending/live tree. Here is a good place to - // update it, because we make a transaction every time we change the pending - // tree. - update_debug_tree(); } static void set_instruction_ready( diff --git a/sway/input/seat.c b/sway/input/seat.c index 2d3552753..7fc87ee4a 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -10,7 +10,6 @@ #include #include "config.h" #include "log.h" -#include "sway/debug.h" #include "sway/desktop.h" #include "sway/input/cursor.h" #include "sway/input/input-manager.h" @@ -812,7 +811,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { } seat_send_unfocus(last_focus, seat); seat->has_focus = false; - update_debug_tree(); return; } @@ -937,8 +935,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { // the workspace needs to be arranged arrange_workspace(new_workspace); } - - update_debug_tree(); } void seat_set_focus_container(struct sway_seat *seat, diff --git a/sway/main.c b/sway/main.c index f3cc1bc8b..ba4e25624 100644 --- a/sway/main.c +++ b/sway/main.c @@ -15,7 +15,6 @@ #include #include "sway/commands.h" #include "sway/config.h" -#include "sway/debug.h" #include "sway/server.h" #include "sway/swaynag.h" #include "sway/tree/root.h" @@ -206,8 +205,6 @@ void enable_debug_flag(const char *flag) { debug.damage = DAMAGE_RERENDER; } else if (strcmp(flag, "noatomic") == 0) { debug.noatomic = true; - } else if (strcmp(flag, "render-tree") == 0) { - debug.render_tree = true; } else if (strcmp(flag, "txn-wait") == 0) { debug.txn_wait = true; } else if (strcmp(flag, "txn-timings") == 0) { diff --git a/sway/meson.build b/sway/meson.build index cb1f8e258..1138bc73f 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -2,7 +2,6 @@ sway_sources = files( 'commands.c', 'config.c', 'criteria.c', - 'debug-tree.c', 'decoration.c', 'ipc-json.c', 'ipc-server.c',