Merge pull request #2273 from swaywm/debug-flags

Add extended debugging flags
master
Drew DeVault 6 years ago committed by GitHub
commit f4edf84b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,15 @@
#ifndef SWAY_DEBUG_H #ifndef SWAY_DEBUG_H
#define SWAY_DEBUG_H #define SWAY_DEBUG_H
// Tree
extern bool enable_debug_tree; extern bool enable_debug_tree;
void update_debug_tree(); void update_debug_tree();
// Damage
extern const char *damage_debug;
// Transactions
extern int txn_timeout_ms;
extern bool txn_debug;
#endif #endif

@ -15,6 +15,7 @@
#include <wlr/util/region.h> #include <wlr/util/region.h>
#include "log.h" #include "log.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"
@ -786,6 +787,8 @@ static void render_floating(struct sway_output *soutput,
} }
} }
const char *damage_debug = NULL;
void output_render(struct sway_output *output, struct timespec *when, void output_render(struct sway_output *output, struct timespec *when,
pixman_region32_t *damage) { pixman_region32_t *damage) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
@ -805,7 +808,6 @@ void output_render(struct sway_output *output, struct timespec *when,
goto renderer_end; goto renderer_end;
} }
const char *damage_debug = getenv("SWAY_DAMAGE_DEBUG");
if (damage_debug != NULL) { if (damage_debug != NULL) {
if (strcmp(damage_debug, "highlight") == 0) { if (strcmp(damage_debug, "highlight") == 0) {
wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1}); wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});

@ -19,14 +19,14 @@
* How long we should wait for views to respond to the configure before giving * How long we should wait for views to respond to the configure before giving
* up and applying the transaction anyway. * up and applying the transaction anyway.
*/ */
#define TIMEOUT_MS 200 int txn_timeout_ms = 200;
/** /**
* If enabled, sway will always wait for the transaction timeout before * If enabled, sway will always wait for the transaction timeout before
* applying it, rather than applying it when the views are ready. This allows us * applying it, rather than applying it when the views are ready. This allows us
* to observe the rendered state while a transaction is in progress. * to observe the rendered state while a transaction is in progress.
*/ */
#define TRANSACTION_DEBUG false bool txn_debug = false;
struct sway_transaction { struct sway_transaction {
struct wl_event_source *timer; struct wl_event_source *timer;
@ -330,7 +330,7 @@ void transaction_commit(struct sway_transaction *transaction) {
// Set up a timer which the views must respond within // Set up a timer which the views must respond within
transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, transaction->timer = wl_event_loop_add_timer(server.wl_event_loop,
handle_timeout, transaction); handle_timeout, transaction);
wl_event_source_timer_update(transaction->timer, TIMEOUT_MS); wl_event_source_timer_update(transaction->timer, txn_timeout_ms);
} }
// The debug tree shows the pending/live tree. Here is a good place to // The debug tree shows the pending/live tree. Here is a good place to
@ -361,11 +361,11 @@ static void set_instruction_ready(
// If all views are ready, apply the transaction. // If all views are ready, apply the transaction.
// If the transaction has timed out then its num_waiting will be 0 already. // If the transaction has timed out then its num_waiting will be 0 already.
if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) {
#if !TRANSACTION_DEBUG if (!txn_debug) {
wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction);
wl_event_source_timer_update(transaction->timer, 0); wl_event_source_timer_update(transaction->timer, 0);
transaction_progress_queue(); transaction_progress_queue();
#endif }
} }
} }

@ -251,6 +251,18 @@ static void drop_permissions(bool keep_caps) {
#endif #endif
} }
void enable_debug_flag(const char *flag) {
if (strcmp(flag, "render-tree") == 0) {
enable_debug_tree = true;
} else if (strncmp(flag, "damage=", 7) == 0) {
damage_debug = &flag[7];
} else if (strcmp(flag, "txn-debug") == 0) {
txn_debug = true;
} else if (strncmp(flag, "txn-timeout=", 12) == 0) {
txn_timeout_ms = atoi(&flag[12]);
}
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
static int verbose = 0, debug = 0, validate = 0; static int verbose = 0, debug = 0, validate = 0;
@ -290,7 +302,7 @@ int main(int argc, char **argv) {
int c; int c;
while (1) { while (1) {
int option_index = 0; int option_index = 0;
c = getopt_long(argc, argv, "hCdDvVc:", long_options, &option_index); c = getopt_long(argc, argv, "hCdD:vVc:", long_options, &option_index);
if (c == -1) { if (c == -1) {
break; break;
} }
@ -309,7 +321,7 @@ int main(int argc, char **argv) {
debug = 1; debug = 1;
break; break;
case 'D': // extended debug options case 'D': // extended debug options
enable_debug_tree = true; enable_debug_flag(optarg);
break; break;
case 'v': // version case 'v': // version
fprintf(stdout, "sway version " SWAY_VERSION "\n"); fprintf(stdout, "sway version " SWAY_VERSION "\n");

Loading…
Cancel
Save