aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-07-14 11:24:22 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-07-14 20:44:32 -0400
commitb1afcc69fa70c20d815940fc25189063ed59ae0f (patch)
treeb5876df0592a14729b09de80fc7fabfaf01065b4 /sway/main.c
parentMerge pull request #2271 from RedSoxFan/implement-1569 (diff)
downloadsway-b1afcc69fa70c20d815940fc25189063ed59ae0f.tar.gz
sway-b1afcc69fa70c20d815940fc25189063ed59ae0f.tar.zst
sway-b1afcc69fa70c20d815940fc25189063ed59ae0f.zip
Add extended debugging flags
We currently have several ways of setting debug flags, including command line arguments, environment variables, and compile-time macros. This replaces the lot with command line flags.
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c16
1 files changed, 14 insertions, 2 deletions
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
254void 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
254int main(int argc, char **argv) { 266int 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");