summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-23 14:34:20 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-23 14:34:20 -0400
commit663f53b22a0d97a300345090a92b8567b6a0af82 (patch)
tree45f2c39c1f883e1b80877c29848003c8ee2c1efc
parentPrefix log events from wlc with [wlc] (diff)
parentMinor fix (diff)
downloadsway-663f53b22a0d97a300345090a92b8567b6a0af82.tar.gz
sway-663f53b22a0d97a300345090a92b8567b6a0af82.tar.zst
sway-663f53b22a0d97a300345090a92b8567b6a0af82.zip
Merge pull request #123 from Luminarys/master
Added in output disabling
-rw-r--r--include/config.h1
-rw-r--r--sway.5.txt3
-rw-r--r--sway/commands.c5
-rw-r--r--sway/container.c4
-rw-r--r--sway/handlers.c6
5 files changed, 19 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index c896b423..6d36eb41 100644
--- a/include/config.h
+++ b/include/config.h
@@ -24,6 +24,7 @@ struct sway_mode {
24 24
25struct output_config { 25struct output_config {
26 char *name; 26 char *name;
27 bool enabled;
27 int width, height; 28 int width, height;
28 int x, y; 29 int x, y;
29}; 30};
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
85 arranged at the given position in the layout tree. You may omit either of 85 arranged at the given position in the layout tree. You may omit either of
86 these parameters if you only want to set one of them. 86 these parameters if you only want to set one of them.
87 87
88**output** <name> disable::
89 Disables the specified output.
90
88**reload**:: 91**reload**::
89 Reloads the sway config file without restarting sway. 92 Reloads the sway config file without restarting sway.
90 93
diff --git a/sway/commands.c b/sway/commands.c
index 5de1fb0c..7ee8c558 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) {
372 struct output_config *output = calloc(1, sizeof(struct output_config)); 372 struct output_config *output = calloc(1, sizeof(struct output_config));
373 output->x = output->y = output->width = output->height = -1; 373 output->x = output->y = output->width = output->height = -1;
374 output->name = strdup(argv[0]); 374 output->name = strdup(argv[0]);
375 output->enabled = true;
375 376
376 // TODO: atoi doesn't handle invalid numbers 377 // TODO: atoi doesn't handle invalid numbers
378
379 if (strcasecmp(argv[1], "disable") == 0) {
380 output->enabled = false;
381 }
377 382
378 int i; 383 int i;
379 for (i = 1; i < argc; ++i) { 384 for (i = 1; i < argc; ++i) {
diff --git a/sway/container.c b/sway/container.c
index 127e1ecd..d4f7c693 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -70,6 +70,10 @@ swayc_t *new_output(wlc_handle handle) {
70 oc = NULL; 70 oc = NULL;
71 } 71 }
72 72
73 if (oc && !oc->enabled) {
74 return NULL;
75 }
76
73 swayc_t *output = new_swayc(C_OUTPUT); 77 swayc_t *output = new_swayc(C_OUTPUT);
74 if (oc && oc->width != -1 && oc->height != -1) { 78 if (oc && oc->width != -1 && oc->height != -1) {
75 output->width = oc->width; 79 output->width = oc->width;
diff --git a/sway/handlers.c b/sway/handlers.c
index e4018811..23db5c15 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -86,6 +86,10 @@ swayc_t *container_under_pointer(void) {
86static bool handle_output_created(wlc_handle output) { 86static bool handle_output_created(wlc_handle output) {
87 swayc_t *op = new_output(output); 87 swayc_t *op = new_output(output);
88 88
89 if (!op) {
90 return false;
91 }
92
89 // Switch to workspace if we need to 93 // Switch to workspace if we need to
90 if (swayc_active_workspace() == NULL) { 94 if (swayc_active_workspace() == NULL) {
91 swayc_t *ws = op->children->items[0]; 95 swayc_t *ws = op->children->items[0];
@@ -104,6 +108,8 @@ static void handle_output_destroyed(wlc_handle output) {
104 } 108 }
105 if (i < list->length) { 109 if (i < list->length) {
106 destroy_output(list->items[i]); 110 destroy_output(list->items[i]);
111 } else {
112 return;
107 } 113 }
108 if (list->length > 0) { 114 if (list->length > 0) {
109 // switch to other outputs active workspace 115 // switch to other outputs active workspace