diff options
-rw-r--r-- | include/sway/debug.h | 22 | ||||
-rw-r--r-- | include/sway/server.h | 14 | ||||
-rw-r--r-- | include/sway/tree/root.h | 2 | ||||
-rw-r--r-- | sway/debug-tree.c | 161 | ||||
-rw-r--r-- | sway/desktop/render.c | 7 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 6 | ||||
-rw-r--r-- | sway/input/seat.c | 4 | ||||
-rw-r--r-- | sway/main.c | 3 | ||||
-rw-r--r-- | sway/meson.build | 1 |
9 files changed, 14 insertions, 206 deletions
diff --git a/include/sway/debug.h b/include/sway/debug.h deleted file mode 100644 index 0e9bb056..00000000 --- a/include/sway/debug.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #ifndef SWAY_DEBUG_H | ||
2 | #define SWAY_DEBUG_H | ||
3 | #include <stdbool.h> | ||
4 | |||
5 | struct sway_debug { | ||
6 | bool noatomic; // Ignore atomic layout updates | ||
7 | bool render_tree; // Render the tree overlay | ||
8 | bool txn_timings; // Log verbose messages about transactions | ||
9 | bool txn_wait; // Always wait for the timeout before applying | ||
10 | |||
11 | enum { | ||
12 | DAMAGE_DEFAULT, // Default behaviour | ||
13 | DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged | ||
14 | DAMAGE_RERENDER, // Render the full output when any damage occurs | ||
15 | } damage; | ||
16 | }; | ||
17 | |||
18 | extern struct sway_debug debug; | ||
19 | |||
20 | void update_debug_tree(void); | ||
21 | |||
22 | #endif | ||
diff --git a/include/sway/server.h b/include/sway/server.h index 5eef7c1a..39cf4f18 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -74,6 +74,20 @@ struct sway_server { | |||
74 | 74 | ||
75 | struct sway_server server; | 75 | struct sway_server server; |
76 | 76 | ||
77 | struct sway_debug { | ||
78 | bool noatomic; // Ignore atomic layout updates | ||
79 | bool txn_timings; // Log verbose messages about transactions | ||
80 | bool txn_wait; // Always wait for the timeout before applying | ||
81 | |||
82 | enum { | ||
83 | DAMAGE_DEFAULT, // Default behaviour | ||
84 | DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged | ||
85 | DAMAGE_RERENDER, // Render the full output when any damage occurs | ||
86 | } damage; | ||
87 | }; | ||
88 | |||
89 | struct sway_debug debug; | ||
90 | |||
77 | /* Prepares an unprivileged server_init by performing all privileged operations in advance */ | 91 | /* Prepares an unprivileged server_init by performing all privileged operations in advance */ |
78 | bool server_privileged_prepare(struct sway_server *server); | 92 | bool server_privileged_prepare(struct sway_server *server); |
79 | bool server_init(struct sway_server *server); | 93 | bool server_init(struct sway_server *server); |
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index 9ff45eb5..9f6cd3bb 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -21,8 +21,6 @@ struct sway_root { | |||
21 | #endif | 21 | #endif |
22 | struct wl_list drag_icons; // sway_drag_icon::link | 22 | struct wl_list drag_icons; // sway_drag_icon::link |
23 | 23 | ||
24 | struct wlr_texture *debug_tree; | ||
25 | |||
26 | // Includes disabled outputs | 24 | // Includes disabled outputs |
27 | struct wl_list all_outputs; // sway_output::link | 25 | struct wl_list all_outputs; // sway_output::link |
28 | 26 | ||
diff --git a/sway/debug-tree.c b/sway/debug-tree.c deleted file mode 100644 index 0444bb3f..00000000 --- a/sway/debug-tree.c +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | #include <pango/pangocairo.h> | ||
2 | #include <wlr/backend.h> | ||
3 | #include <wlr/render/wlr_texture.h> | ||
4 | #include "config.h" | ||
5 | #include "sway/debug.h" | ||
6 | #include "sway/input/input-manager.h" | ||
7 | #include "sway/input/seat.h" | ||
8 | #include "sway/output.h" | ||
9 | #include "sway/server.h" | ||
10 | #include "sway/tree/container.h" | ||
11 | #include "sway/tree/root.h" | ||
12 | #include "sway/tree/workspace.h" | ||
13 | #include "cairo.h" | ||
14 | #include "config.h" | ||
15 | #include "pango.h" | ||
16 | |||
17 | struct sway_debug debug; | ||
18 | |||
19 | static const char *layout_to_str(enum sway_container_layout layout) { | ||
20 | switch (layout) { | ||
21 | case L_HORIZ: | ||
22 | return "L_HORIZ"; | ||
23 | case L_VERT: | ||
24 | return "L_VERT"; | ||
25 | case L_STACKED: | ||
26 | return "L_STACKED"; | ||
27 | case L_TABBED: | ||
28 | return "L_TABBED"; | ||
29 | case L_NONE: | ||
30 | return "L_NONE"; | ||
31 | } | ||
32 | return "L_NONE"; | ||
33 | } | ||
34 | |||
35 | static char *get_string(struct sway_node *node) { | ||
36 | char *buffer = malloc(512); | ||
37 | switch (node->type) { | ||
38 | case N_ROOT: | ||
39 | snprintf(buffer, 512, "N_ROOT id:%zd %.fx%.f@%.f,%.f", node->id, | ||
40 | root->width, root->height, root->x, root->y); | ||
41 | break; | ||
42 | case N_OUTPUT: | ||
43 | snprintf(buffer, 512, "N_OUTPUT id:%zd '%s' %dx%d@%d,%d", node->id, | ||
44 | node->sway_output->wlr_output->name, | ||
45 | node->sway_output->width, | ||
46 | node->sway_output->height, | ||
47 | node->sway_output->lx, | ||
48 | node->sway_output->ly); | ||
49 | break; | ||
50 | case N_WORKSPACE: | ||
51 | snprintf(buffer, 512, "N_WORKSPACE id:%zd '%s' %s %dx%d@%.f,%.f", | ||
52 | node->id, node->sway_workspace->name, | ||
53 | layout_to_str(node->sway_workspace->layout), | ||
54 | node->sway_workspace->width, node->sway_workspace->height, | ||
55 | node->sway_workspace->x, node->sway_workspace->y); | ||
56 | break; | ||
57 | case N_CONTAINER: | ||
58 | snprintf(buffer, 512, "N_CONTAINER id:%zd '%s' %s %.fx%.f@%.f,%.f", | ||
59 | node->id, node->sway_container->title, | ||
60 | layout_to_str(node->sway_container->layout), | ||
61 | node->sway_container->width, node->sway_container->height, | ||
62 | node->sway_container->x, node->sway_container->y); | ||
63 | break; | ||
64 | } | ||
65 | return buffer; | ||
66 | } | ||
67 | |||
68 | static list_t *get_children(struct sway_node *node) { | ||
69 | switch (node->type) { | ||
70 | case N_ROOT: | ||
71 | return root->outputs; | ||
72 | case N_OUTPUT: | ||
73 | return node->sway_output->workspaces; | ||
74 | case N_WORKSPACE: | ||
75 | return node->sway_workspace->tiling; | ||
76 | case N_CONTAINER: | ||
77 | return node->sway_container->children; | ||
78 | } | ||
79 | return NULL; | ||
80 | } | ||
81 | |||
82 | static int draw_node(cairo_t *cairo, struct sway_node *node, | ||
83 | struct sway_node *focus, int x, int y) { | ||
84 | int text_width, text_height; | ||
85 | char *buffer = get_string(node); | ||
86 | get_text_size(cairo, "monospace", &text_width, &text_height, NULL, | ||
87 | 1, false, buffer); | ||
88 | cairo_save(cairo); | ||
89 | cairo_rectangle(cairo, x + 2, y, text_width - 2, text_height); | ||
90 | cairo_set_source_u32(cairo, 0xFFFFFFE0); | ||
91 | cairo_fill(cairo); | ||
92 | int height = text_height; | ||
93 | list_t *children = get_children(node); | ||
94 | if (children) { | ||
95 | for (int i = 0; i < children->length; ++i) { | ||
96 | // This is really dirty - the list contains specific structs but | ||
97 | // we're casting them as nodes. This works because node is the first | ||
98 | // item in each specific struct. This is acceptable because this is | ||
99 | // debug code. | ||
100 | struct sway_node *child = children->items[i]; | ||
101 | if (node_get_parent(child) == node) { | ||
102 | cairo_set_source_u32(cairo, 0x000000FF); | ||
103 | } else { | ||
104 | cairo_set_source_u32(cairo, 0xFF0000FF); | ||
105 | } | ||
106 | height += draw_node(cairo, child, focus, x + 10, y + height); | ||
107 | } | ||
108 | } | ||
109 | cairo_set_source_u32(cairo, 0xFFFFFFE0); | ||
110 | cairo_rectangle(cairo, x, y, 2, height); | ||
111 | cairo_fill(cairo); | ||
112 | cairo_restore(cairo); | ||
113 | cairo_move_to(cairo, x, y); | ||
114 | if (focus == node) { | ||
115 | cairo_set_source_u32(cairo, 0x0000FFFF); | ||
116 | } | ||
117 | pango_printf(cairo, "monospace", 1, false, buffer); | ||
118 | free(buffer); | ||
119 | return height; | ||
120 | } | ||
121 | |||
122 | void update_debug_tree(void) { | ||
123 | if (!debug.render_tree) { | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | int width = 640, height = 480; | ||
128 | for (int i = 0; i < root->outputs->length; ++i) { | ||
129 | struct sway_output *output = root->outputs->items[i]; | ||
130 | if (output->width > width) { | ||
131 | width = output->width; | ||
132 | } | ||
133 | if (output->height > height) { | ||
134 | height = output->height; | ||
135 | } | ||
136 | } | ||
137 | cairo_surface_t *surface = | ||
138 | cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); | ||
139 | cairo_t *cairo = cairo_create(surface); | ||
140 | PangoContext *pango = pango_cairo_create_context(cairo); | ||
141 | |||
142 | struct sway_seat *seat = input_manager_current_seat(); | ||
143 | struct sway_node *focus = seat_get_focus(seat); | ||
144 | |||
145 | cairo_set_source_u32(cairo, 0x000000FF); | ||
146 | draw_node(cairo, &root->node, focus, 0, 0); | ||
147 | |||
148 | cairo_surface_flush(surface); | ||
149 | struct wlr_renderer *renderer = wlr_backend_get_renderer(server.backend); | ||
150 | if (root->debug_tree) { | ||
151 | wlr_texture_destroy(root->debug_tree); | ||
152 | } | ||
153 | unsigned char *data = cairo_image_surface_get_data(surface); | ||
154 | int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); | ||
155 | struct wlr_texture *texture = wlr_texture_from_pixels(renderer, | ||
156 | WL_SHM_FORMAT_ARGB8888, stride, width, height, data); | ||
157 | root->debug_tree = texture; | ||
158 | cairo_surface_destroy(surface); | ||
159 | g_object_unref(pango); | ||
160 | cairo_destroy(cairo); | ||
161 | } | ||
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 9e936bb5..7216e30b 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include "log.h" | 16 | #include "log.h" |
17 | #include "config.h" | 17 | #include "config.h" |
18 | #include "sway/config.h" | 18 | #include "sway/config.h" |
19 | #include "sway/debug.h" | ||
20 | #include "sway/input/input-manager.h" | 19 | #include "sway/input/input-manager.h" |
21 | #include "sway/input/seat.h" | 20 | #include "sway/input/seat.h" |
22 | #include "sway/layers.h" | 21 | #include "sway/layers.h" |
@@ -1075,12 +1074,6 @@ render_overlay: | |||
1075 | render_drag_icons(output, damage, &root->drag_icons); | 1074 | render_drag_icons(output, damage, &root->drag_icons); |
1076 | 1075 | ||
1077 | renderer_end: | 1076 | renderer_end: |
1078 | if (debug.render_tree) { | ||
1079 | wlr_renderer_scissor(renderer, NULL); | ||
1080 | wlr_render_texture(renderer, root->debug_tree, | ||
1081 | wlr_output->transform_matrix, 0, 40, 1); | ||
1082 | } | ||
1083 | |||
1084 | wlr_renderer_scissor(renderer, NULL); | 1077 | wlr_renderer_scissor(renderer, NULL); |
1085 | wlr_output_render_software_cursors(wlr_output, damage); | 1078 | wlr_output_render_software_cursors(wlr_output, damage); |
1086 | wlr_renderer_end(renderer); | 1079 | wlr_renderer_end(renderer); |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 4098ed22..e5f0ee3d 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <time.h> | 5 | #include <time.h> |
6 | #include <wlr/types/wlr_buffer.h> | 6 | #include <wlr/types/wlr_buffer.h> |
7 | #include "sway/config.h" | 7 | #include "sway/config.h" |
8 | #include "sway/debug.h" | ||
9 | #include "sway/desktop.h" | 8 | #include "sway/desktop.h" |
10 | #include "sway/desktop/idle_inhibit_v1.h" | 9 | #include "sway/desktop/idle_inhibit_v1.h" |
11 | #include "sway/desktop/transaction.h" | 10 | #include "sway/desktop/transaction.h" |
@@ -465,11 +464,6 @@ static void transaction_commit(struct sway_transaction *transaction) { | |||
465 | transaction->num_waiting = 0; | 464 | transaction->num_waiting = 0; |
466 | } | 465 | } |
467 | } | 466 | } |
468 | |||
469 | // The debug tree shows the pending/live tree. Here is a good place to | ||
470 | // update it, because we make a transaction every time we change the pending | ||
471 | // tree. | ||
472 | update_debug_tree(); | ||
473 | } | 467 | } |
474 | 468 | ||
475 | static void set_instruction_ready( | 469 | static void set_instruction_ready( |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 2d355275..7fc87ee4 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <wlr/types/wlr_xcursor_manager.h> | 10 | #include <wlr/types/wlr_xcursor_manager.h> |
11 | #include "config.h" | 11 | #include "config.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | #include "sway/debug.h" | ||
14 | #include "sway/desktop.h" | 13 | #include "sway/desktop.h" |
15 | #include "sway/input/cursor.h" | 14 | #include "sway/input/cursor.h" |
16 | #include "sway/input/input-manager.h" | 15 | #include "sway/input/input-manager.h" |
@@ -812,7 +811,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
812 | } | 811 | } |
813 | seat_send_unfocus(last_focus, seat); | 812 | seat_send_unfocus(last_focus, seat); |
814 | seat->has_focus = false; | 813 | seat->has_focus = false; |
815 | update_debug_tree(); | ||
816 | return; | 814 | return; |
817 | } | 815 | } |
818 | 816 | ||
@@ -937,8 +935,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
937 | // the workspace needs to be arranged | 935 | // the workspace needs to be arranged |
938 | arrange_workspace(new_workspace); | 936 | arrange_workspace(new_workspace); |
939 | } | 937 | } |
940 | |||
941 | update_debug_tree(); | ||
942 | } | 938 | } |
943 | 939 | ||
944 | void seat_set_focus_container(struct sway_seat *seat, | 940 | void seat_set_focus_container(struct sway_seat *seat, |
diff --git a/sway/main.c b/sway/main.c index f3cc1bc8..ba4e2562 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <wlr/util/log.h> | 15 | #include <wlr/util/log.h> |
16 | #include "sway/commands.h" | 16 | #include "sway/commands.h" |
17 | #include "sway/config.h" | 17 | #include "sway/config.h" |
18 | #include "sway/debug.h" | ||
19 | #include "sway/server.h" | 18 | #include "sway/server.h" |
20 | #include "sway/swaynag.h" | 19 | #include "sway/swaynag.h" |
21 | #include "sway/tree/root.h" | 20 | #include "sway/tree/root.h" |
@@ -206,8 +205,6 @@ void enable_debug_flag(const char *flag) { | |||
206 | debug.damage = DAMAGE_RERENDER; | 205 | debug.damage = DAMAGE_RERENDER; |
207 | } else if (strcmp(flag, "noatomic") == 0) { | 206 | } else if (strcmp(flag, "noatomic") == 0) { |
208 | debug.noatomic = true; | 207 | debug.noatomic = true; |
209 | } else if (strcmp(flag, "render-tree") == 0) { | ||
210 | debug.render_tree = true; | ||
211 | } else if (strcmp(flag, "txn-wait") == 0) { | 208 | } else if (strcmp(flag, "txn-wait") == 0) { |
212 | debug.txn_wait = true; | 209 | debug.txn_wait = true; |
213 | } else if (strcmp(flag, "txn-timings") == 0) { | 210 | } else if (strcmp(flag, "txn-timings") == 0) { |
diff --git a/sway/meson.build b/sway/meson.build index cb1f8e25..1138bc73 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -2,7 +2,6 @@ sway_sources = files( | |||
2 | 'commands.c', | 2 | 'commands.c', |
3 | 'config.c', | 3 | 'config.c', |
4 | 'criteria.c', | 4 | 'criteria.c', |
5 | 'debug-tree.c', | ||
6 | 'decoration.c', | 5 | 'decoration.c', |
7 | 'ipc-json.c', | 6 | 'ipc-json.c', |
8 | 'ipc-server.c', | 7 | 'ipc-server.c', |