diff options
-rw-r--r-- | include/sway/debug.h | 8 | ||||
-rw-r--r-- | sway/desktop/render.c | 4 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 16 | ||||
-rw-r--r-- | sway/main.c | 16 |
4 files changed, 33 insertions, 11 deletions
diff --git a/include/sway/debug.h b/include/sway/debug.h index 2430d319..38d4eccd 100644 --- a/include/sway/debug.h +++ b/include/sway/debug.h | |||
@@ -1,7 +1,15 @@ | |||
1 | #ifndef SWAY_DEBUG_H | 1 | #ifndef SWAY_DEBUG_H |
2 | #define SWAY_DEBUG_H | 2 | #define SWAY_DEBUG_H |
3 | 3 | ||
4 | // Tree | ||
4 | extern bool enable_debug_tree; | 5 | extern bool enable_debug_tree; |
5 | void update_debug_tree(); | 6 | void update_debug_tree(); |
6 | 7 | ||
8 | // Damage | ||
9 | extern const char *damage_debug; | ||
10 | |||
11 | // Transactions | ||
12 | extern int txn_timeout_ms; | ||
13 | extern bool txn_debug; | ||
14 | |||
7 | #endif | 15 | #endif |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index b370f8a2..4bfc573b 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <wlr/util/region.h> | 15 | #include <wlr/util/region.h> |
16 | #include "log.h" | 16 | #include "log.h" |
17 | #include "sway/config.h" | 17 | #include "sway/config.h" |
18 | #include "sway/debug.h" | ||
18 | #include "sway/input/input-manager.h" | 19 | #include "sway/input/input-manager.h" |
19 | #include "sway/input/seat.h" | 20 | #include "sway/input/seat.h" |
20 | #include "sway/layers.h" | 21 | #include "sway/layers.h" |
@@ -786,6 +787,8 @@ static void render_floating(struct sway_output *soutput, | |||
786 | } | 787 | } |
787 | } | 788 | } |
788 | 789 | ||
790 | const char *damage_debug = NULL; | ||
791 | |||
789 | void output_render(struct sway_output *output, struct timespec *when, | 792 | void output_render(struct sway_output *output, struct timespec *when, |
790 | pixman_region32_t *damage) { | 793 | pixman_region32_t *damage) { |
791 | struct wlr_output *wlr_output = output->wlr_output; | 794 | struct wlr_output *wlr_output = output->wlr_output; |
@@ -805,7 +808,6 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
805 | goto renderer_end; | 808 | goto renderer_end; |
806 | } | 809 | } |
807 | 810 | ||
808 | const char *damage_debug = getenv("SWAY_DAMAGE_DEBUG"); | ||
809 | if (damage_debug != NULL) { | 811 | if (damage_debug != NULL) { |
810 | if (strcmp(damage_debug, "highlight") == 0) { | 812 | if (strcmp(damage_debug, "highlight") == 0) { |
811 | wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1}); | 813 | wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1}); |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 2b3f87c3..5e42fde5 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -19,14 +19,14 @@ | |||
19 | * How long we should wait for views to respond to the configure before giving | 19 | * How long we should wait for views to respond to the configure before giving |
20 | * up and applying the transaction anyway. | 20 | * up and applying the transaction anyway. |
21 | */ | 21 | */ |
22 | #define TIMEOUT_MS 200 | 22 | int txn_timeout_ms = 200; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * If enabled, sway will always wait for the transaction timeout before | 25 | * If enabled, sway will always wait for the transaction timeout before |
26 | * applying it, rather than applying it when the views are ready. This allows us | 26 | * applying it, rather than applying it when the views are ready. This allows us |
27 | * to observe the rendered state while a transaction is in progress. | 27 | * to observe the rendered state while a transaction is in progress. |
28 | */ | 28 | */ |
29 | #define TRANSACTION_DEBUG false | 29 | bool txn_debug = false; |
30 | 30 | ||
31 | struct sway_transaction { | 31 | struct sway_transaction { |
32 | struct wl_event_source *timer; | 32 | struct wl_event_source *timer; |
@@ -330,7 +330,7 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
330 | // Set up a timer which the views must respond within | 330 | // Set up a timer which the views must respond within |
331 | transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, | 331 | transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, |
332 | handle_timeout, transaction); | 332 | handle_timeout, transaction); |
333 | wl_event_source_timer_update(transaction->timer, TIMEOUT_MS); | 333 | wl_event_source_timer_update(transaction->timer, txn_timeout_ms); |
334 | } | 334 | } |
335 | 335 | ||
336 | // The debug tree shows the pending/live tree. Here is a good place to | 336 | // The debug tree shows the pending/live tree. Here is a good place to |
@@ -361,11 +361,11 @@ static void set_instruction_ready( | |||
361 | // If all views are ready, apply the transaction. | 361 | // If all views are ready, apply the transaction. |
362 | // If the transaction has timed out then its num_waiting will be 0 already. | 362 | // If the transaction has timed out then its num_waiting will be 0 already. |
363 | if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { | 363 | if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { |
364 | #if !TRANSACTION_DEBUG | 364 | if (!txn_debug) { |
365 | wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); | 365 | wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); |
366 | wl_event_source_timer_update(transaction->timer, 0); | 366 | wl_event_source_timer_update(transaction->timer, 0); |
367 | transaction_progress_queue(); | 367 | transaction_progress_queue(); |
368 | #endif | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
diff --git a/sway/main.c b/sway/main.c index c6453226..1d772b48 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -251,6 +251,18 @@ static void drop_permissions(bool keep_caps) { | |||
251 | #endif | 251 | #endif |
252 | } | 252 | } |
253 | 253 | ||
254 | void enable_debug_flag(const char *flag) { | ||
255 | if (strcmp(flag, "render-tree") == 0) { | ||
256 | enable_debug_tree = true; | ||
257 | } else if (strncmp(flag, "damage=", 7) == 0) { | ||
258 | damage_debug = &flag[7]; | ||
259 | } else if (strcmp(flag, "txn-debug") == 0) { | ||
260 | txn_debug = true; | ||
261 | } else if (strncmp(flag, "txn-timeout=", 12) == 0) { | ||
262 | txn_timeout_ms = atoi(&flag[12]); | ||
263 | } | ||
264 | } | ||
265 | |||
254 | int main(int argc, char **argv) { | 266 | int main(int argc, char **argv) { |
255 | static int verbose = 0, debug = 0, validate = 0; | 267 | static int verbose = 0, debug = 0, validate = 0; |
256 | 268 | ||
@@ -290,7 +302,7 @@ int main(int argc, char **argv) { | |||
290 | int c; | 302 | int c; |
291 | while (1) { | 303 | while (1) { |
292 | int option_index = 0; | 304 | int option_index = 0; |
293 | c = getopt_long(argc, argv, "hCdDvVc:", long_options, &option_index); | 305 | c = getopt_long(argc, argv, "hCdD:vVc:", long_options, &option_index); |
294 | if (c == -1) { | 306 | if (c == -1) { |
295 | break; | 307 | break; |
296 | } | 308 | } |
@@ -309,7 +321,7 @@ int main(int argc, char **argv) { | |||
309 | debug = 1; | 321 | debug = 1; |
310 | break; | 322 | break; |
311 | case 'D': // extended debug options | 323 | case 'D': // extended debug options |
312 | enable_debug_tree = true; | 324 | enable_debug_flag(optarg); |
313 | break; | 325 | break; |
314 | case 'v': // version | 326 | case 'v': // version |
315 | fprintf(stdout, "sway version " SWAY_VERSION "\n"); | 327 | fprintf(stdout, "sway version " SWAY_VERSION "\n"); |