mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 01:41:30 +00:00
Remove debug tree
This feature has served its purpose. It's better to use IPC now.
This commit is contained in:
parent
38bd60c4b3
commit
e9a476244d
|
@ -1,22 +0,0 @@
|
||||||
#ifndef SWAY_DEBUG_H
|
|
||||||
#define SWAY_DEBUG_H
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
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
|
|
|
@ -74,6 +74,20 @@ struct sway_server {
|
||||||
|
|
||||||
struct sway_server 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 */
|
/* Prepares an unprivileged server_init by performing all privileged operations in advance */
|
||||||
bool server_privileged_prepare(struct sway_server *server);
|
bool server_privileged_prepare(struct sway_server *server);
|
||||||
bool server_init(struct sway_server *server);
|
bool server_init(struct sway_server *server);
|
||||||
|
|
|
@ -21,8 +21,6 @@ struct sway_root {
|
||||||
#endif
|
#endif
|
||||||
struct wl_list drag_icons; // sway_drag_icon::link
|
struct wl_list drag_icons; // sway_drag_icon::link
|
||||||
|
|
||||||
struct wlr_texture *debug_tree;
|
|
||||||
|
|
||||||
// Includes disabled outputs
|
// Includes disabled outputs
|
||||||
struct wl_list all_outputs; // sway_output::link
|
struct wl_list all_outputs; // sway_output::link
|
||||||
|
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
#include <pango/pangocairo.h>
|
|
||||||
#include <wlr/backend.h>
|
|
||||||
#include <wlr/render/wlr_texture.h>
|
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/debug.h"
|
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "sway/layers.h"
|
#include "sway/layers.h"
|
||||||
|
@ -1075,12 +1074,6 @@ render_overlay:
|
||||||
render_drag_icons(output, damage, &root->drag_icons);
|
render_drag_icons(output, damage, &root->drag_icons);
|
||||||
|
|
||||||
renderer_end:
|
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_renderer_scissor(renderer, NULL);
|
||||||
wlr_output_render_software_cursors(wlr_output, damage);
|
wlr_output_render_software_cursors(wlr_output, damage);
|
||||||
wlr_renderer_end(renderer);
|
wlr_renderer_end(renderer);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wlr/types/wlr_buffer.h>
|
#include <wlr/types/wlr_buffer.h>
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/debug.h"
|
|
||||||
#include "sway/desktop.h"
|
#include "sway/desktop.h"
|
||||||
#include "sway/desktop/idle_inhibit_v1.h"
|
#include "sway/desktop/idle_inhibit_v1.h"
|
||||||
#include "sway/desktop/transaction.h"
|
#include "sway/desktop/transaction.h"
|
||||||
|
@ -465,11 +464,6 @@ static void transaction_commit(struct sway_transaction *transaction) {
|
||||||
transaction->num_waiting = 0;
|
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(
|
static void set_instruction_ready(
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sway/debug.h"
|
|
||||||
#include "sway/desktop.h"
|
#include "sway/desktop.h"
|
||||||
#include "sway/input/cursor.h"
|
#include "sway/input/cursor.h"
|
||||||
#include "sway/input/input-manager.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_send_unfocus(last_focus, seat);
|
||||||
seat->has_focus = false;
|
seat->has_focus = false;
|
||||||
update_debug_tree();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,8 +935,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
|
||||||
// the workspace needs to be arranged
|
// the workspace needs to be arranged
|
||||||
arrange_workspace(new_workspace);
|
arrange_workspace(new_workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_debug_tree();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void seat_set_focus_container(struct sway_seat *seat,
|
void seat_set_focus_container(struct sway_seat *seat,
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/debug.h"
|
|
||||||
#include "sway/server.h"
|
#include "sway/server.h"
|
||||||
#include "sway/swaynag.h"
|
#include "sway/swaynag.h"
|
||||||
#include "sway/tree/root.h"
|
#include "sway/tree/root.h"
|
||||||
|
@ -206,8 +205,6 @@ void enable_debug_flag(const char *flag) {
|
||||||
debug.damage = DAMAGE_RERENDER;
|
debug.damage = DAMAGE_RERENDER;
|
||||||
} else if (strcmp(flag, "noatomic") == 0) {
|
} else if (strcmp(flag, "noatomic") == 0) {
|
||||||
debug.noatomic = true;
|
debug.noatomic = true;
|
||||||
} else if (strcmp(flag, "render-tree") == 0) {
|
|
||||||
debug.render_tree = true;
|
|
||||||
} else if (strcmp(flag, "txn-wait") == 0) {
|
} else if (strcmp(flag, "txn-wait") == 0) {
|
||||||
debug.txn_wait = true;
|
debug.txn_wait = true;
|
||||||
} else if (strcmp(flag, "txn-timings") == 0) {
|
} else if (strcmp(flag, "txn-timings") == 0) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ sway_sources = files(
|
||||||
'commands.c',
|
'commands.c',
|
||||||
'config.c',
|
'config.c',
|
||||||
'criteria.c',
|
'criteria.c',
|
||||||
'debug-tree.c',
|
|
||||||
'decoration.c',
|
'decoration.c',
|
||||||
'ipc-json.c',
|
'ipc-json.c',
|
||||||
'ipc-server.c',
|
'ipc-server.c',
|
||||||
|
|
Loading…
Reference in a new issue