aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-20 19:05:28 +1000
committerLibravatar emersion <contact@emersion.fr>2019-01-22 09:55:13 +0100
commit7f8ea60e71d3185f47954844d9e974bdb49b0c41 (patch)
tree4ded870c4991206856e49ea35ff5c2f42484be2d
parentHide noop output in IPC (diff)
downloadsway-7f8ea60e71d3185f47954844d9e974bdb49b0c41.tar.gz
sway-7f8ea60e71d3185f47954844d9e974bdb49b0c41.tar.zst
sway-7f8ea60e71d3185f47954844d9e974bdb49b0c41.zip
Don't allow noop output to be configured
-rw-r--r--sway/commands/output.c8
-rw-r--r--sway/commands/output/enable.c9
-rw-r--r--sway/config/output.c4
3 files changed, 12 insertions, 9 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 74ca9d0b..85b7fd23 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -1,3 +1,4 @@
1#include <strings.h>
1#include "sway/commands.h" 2#include "sway/commands.h"
2#include "sway/config.h" 3#include "sway/config.h"
3#include "sway/output.h" 4#include "sway/output.h"
@@ -26,6 +27,13 @@ struct cmd_results *cmd_output(int argc, char **argv) {
26 return error; 27 return error;
27 } 28 }
28 29
30 // The NOOP-1 output is a dummy output used when there's no outputs
31 // connected. It should never be configured.
32 if (strcasecmp(argv[0], "NOOP-1") == 0) {
33 return cmd_results_new(CMD_FAILURE,
34 "Refusing to configure the no op output");
35 }
36
29 struct output_config *output = new_output_config(argv[0]); 37 struct output_config *output = new_output_config(argv[0]);
30 if (!output) { 38 if (!output) {
31 sway_log(SWAY_ERROR, "Failed to allocate output config"); 39 sway_log(SWAY_ERROR, "Failed to allocate output config");
diff --git a/sway/commands/output/enable.c b/sway/commands/output/enable.c
index 0c98b481..bae3961f 100644
--- a/sway/commands/output/enable.c
+++ b/sway/commands/output/enable.c
@@ -1,4 +1,3 @@
1#include <strings.h>
2#include "sway/commands.h" 1#include "sway/commands.h"
3#include "sway/config.h" 2#include "sway/config.h"
4 3
@@ -7,14 +6,6 @@ struct cmd_results *output_cmd_enable(int argc, char **argv) {
7 return cmd_results_new(CMD_FAILURE, "Missing output config"); 6 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 7 }
9 8
10 // The NOOP-1 output is a dummy output used when there's no outputs
11 // connected. It should never be enabled.
12 char *output_name = config->handler_context.output_config->name;
13 if (strcasecmp(output_name, "NOOP-1") == 0) {
14 return cmd_results_new(CMD_FAILURE,
15 "Refusing to enable the no op output");
16 }
17
18 config->handler_context.output_config->enabled = 1; 9 config->handler_context.output_config->enabled = 1;
19 10
20 config->handler_context.leftovers.argc = argc; 11 config->handler_context.leftovers.argc = argc;
diff --git a/sway/config/output.c b/sway/config/output.c
index ec833ffe..cc5f29db 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -176,6 +176,10 @@ void terminate_swaybg(pid_t pid) {
176} 176}
177 177
178bool apply_output_config(struct output_config *oc, struct sway_output *output) { 178bool apply_output_config(struct output_config *oc, struct sway_output *output) {
179 if (output == root->noop_output) {
180 return false;
181 }
182
179 struct wlr_output *wlr_output = output->wlr_output; 183 struct wlr_output *wlr_output = output->wlr_output;
180 184
181 if (oc && !oc->enabled) { 185 if (oc && !oc->enabled) {