From 98fad060e28c81c8340afbb473615f7889a6097a Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 12:22:33 -0500 Subject: Added in glitchy disabling --- include/config.h | 1 + sway/commands.c | 5 +++++ sway/container.c | 4 ++++ sway/handlers.c | 11 +++++++++++ 4 files changed, 21 insertions(+) diff --git a/include/config.h b/include/config.h index c896b423..3d501cbe 100644 --- a/include/config.h +++ b/include/config.h @@ -24,6 +24,7 @@ struct sway_mode { struct output_config { char *name; + bool enabled; int width, height; int x, y; }; diff --git a/sway/commands.c b/sway/commands.c index 5de1fb0c..9a0bc076 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -372,8 +372,13 @@ static bool cmd_output(struct sway_config *config, int argc, char **argv) { struct output_config *output = calloc(1, sizeof(struct output_config)); output->x = output->y = output->width = output->height = -1; output->name = strdup(argv[0]); + output->enabled = true; // TODO: atoi doesn't handle invalid numbers + + if (strcmp(argv[1], "disable") == 0) { + output->enabled = false; + } int i; for (i = 1; i < argc; ++i) { diff --git a/sway/container.c b/sway/container.c index 127e1ecd..6debeea3 100644 --- a/sway/container.c +++ b/sway/container.c @@ -70,6 +70,10 @@ swayc_t *new_output(wlc_handle handle) { oc = NULL; } + if (oc && !oc->enabled) { + return NULL; + } + swayc_t *output = new_swayc(C_OUTPUT); if (oc && oc->width != -1 && oc->height != -1) { output->width = oc->width; diff --git a/sway/handlers.c b/sway/handlers.c index e4018811..9fca6387 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -86,11 +86,22 @@ swayc_t *container_under_pointer(void) { static bool handle_output_created(wlc_handle output) { swayc_t *op = new_output(output); + if (!op) { + return false; + } + + wlc_output_focus(output); // Switch to workspace if we need to if (swayc_active_workspace() == NULL) { + sway_log(L_INFO, "Focus switch"); swayc_t *ws = op->children->items[0]; workspace_switch(ws); } + /* + if (wlc_output_get_sleep(wlc_get_focused_output())) { + wlc_output_focus(output); + } + */ return true; } -- cgit v1.2.3-54-g00ecf From e01cf0b56654ff459a98a90e5e35615ad8d9203e Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 12:22:45 -0500 Subject: Added in glitchy disabling --- sway/commands.c | 10 +++++----- sway/container.c | 6 +++--- sway/handlers.c | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sway/commands.c b/sway/commands.c index 9a0bc076..ae75ec67 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -372,13 +372,13 @@ static bool cmd_output(struct sway_config *config, int argc, char **argv) { struct output_config *output = calloc(1, sizeof(struct output_config)); output->x = output->y = output->width = output->height = -1; output->name = strdup(argv[0]); - output->enabled = true; + output->enabled = true; // TODO: atoi doesn't handle invalid numbers - - if (strcmp(argv[1], "disable") == 0) { - output->enabled = false; - } + + if (strcmp(argv[1], "disable") == 0) { + output->enabled = false; + } int i; for (i = 1; i < argc; ++i) { diff --git a/sway/container.c b/sway/container.c index 6debeea3..d4f7c693 100644 --- a/sway/container.c +++ b/sway/container.c @@ -70,9 +70,9 @@ swayc_t *new_output(wlc_handle handle) { oc = NULL; } - if (oc && !oc->enabled) { - return NULL; - } + if (oc && !oc->enabled) { + return NULL; + } swayc_t *output = new_swayc(C_OUTPUT); if (oc && oc->width != -1 && oc->height != -1) { diff --git a/sway/handlers.c b/sway/handlers.c index 9fca6387..1ff430f2 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -86,22 +86,22 @@ swayc_t *container_under_pointer(void) { static bool handle_output_created(wlc_handle output) { swayc_t *op = new_output(output); - if (!op) { - return false; - } + if (!op) { + return false; + } - wlc_output_focus(output); + wlc_output_focus(output); // Switch to workspace if we need to if (swayc_active_workspace() == NULL) { - sway_log(L_INFO, "Focus switch"); + sway_log(L_INFO, "Focus switch"); swayc_t *ws = op->children->items[0]; workspace_switch(ws); } - /* - if (wlc_output_get_sleep(wlc_get_focused_output())) { - wlc_output_focus(output); - } - */ + /* + if (wlc_output_get_sleep(wlc_get_focused_output())) { + wlc_output_focus(output); + } + */ return true; } -- cgit v1.2.3-54-g00ecf From 5bfed9b2131761f29e2cc095fbdf2083d2665848 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 13:18:07 -0500 Subject: Cleanup and minor adjustments to disabling --- sway/handlers.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 1ff430f2..23db5c15 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -90,18 +90,11 @@ static bool handle_output_created(wlc_handle output) { return false; } - wlc_output_focus(output); // Switch to workspace if we need to if (swayc_active_workspace() == NULL) { - sway_log(L_INFO, "Focus switch"); swayc_t *ws = op->children->items[0]; workspace_switch(ws); } - /* - if (wlc_output_get_sleep(wlc_get_focused_output())) { - wlc_output_focus(output); - } - */ return true; } @@ -115,6 +108,8 @@ static void handle_output_destroyed(wlc_handle output) { } if (i < list->length) { destroy_output(list->items[i]); + } else { + return; } if (list->length > 0) { // switch to other outputs active workspace -- cgit v1.2.3-54-g00ecf From a65dca04e89282822fbda01aee00aadac8fb2540 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 13:19:47 -0500 Subject: Style fix --- include/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index 3d501cbe..6d36eb41 100644 --- a/include/config.h +++ b/include/config.h @@ -24,7 +24,7 @@ struct sway_mode { struct output_config { char *name; - bool enabled; + bool enabled; int width, height; int x, y; }; -- cgit v1.2.3-54-g00ecf From 3f1bb40769df708de8f488d432d56d8bce6edb5a Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 13:27:37 -0500 Subject: Man page update --- sway.5.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sway.5.txt b/sway.5.txt index e0052ee1..15a465c1 100644 --- a/sway.5.txt +++ b/sway.5.txt @@ -85,6 +85,9 @@ Commands arranged at the given position in the layout tree. You may omit either of these parameters if you only want to set one of them. +**output** disable:: + Disables the specified output. + **reload**:: Reloads the sway config file without restarting sway. -- cgit v1.2.3-54-g00ecf From 7a213889974daad72fd6b925edc3dc2cf1a394a1 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Sun, 23 Aug 2015 13:32:47 -0500 Subject: Minor fix --- sway/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index ae75ec67..7ee8c558 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -376,7 +376,7 @@ static bool cmd_output(struct sway_config *config, int argc, char **argv) { // TODO: atoi doesn't handle invalid numbers - if (strcmp(argv[1], "disable") == 0) { + if (strcasecmp(argv[1], "disable") == 0) { output->enabled = false; } -- cgit v1.2.3-54-g00ecf