Don't allow noop output to be configured

master
Ryan Dwyer 6 years ago committed by emersion
parent e815e48cee
commit 7f8ea60e71

@ -1,3 +1,4 @@
#include <strings.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/output.h" #include "sway/output.h"
@ -26,6 +27,13 @@ struct cmd_results *cmd_output(int argc, char **argv) {
return error; return error;
} }
// The NOOP-1 output is a dummy output used when there's no outputs
// connected. It should never be configured.
if (strcasecmp(argv[0], "NOOP-1") == 0) {
return cmd_results_new(CMD_FAILURE,
"Refusing to configure the no op output");
}
struct output_config *output = new_output_config(argv[0]); struct output_config *output = new_output_config(argv[0]);
if (!output) { if (!output) {
sway_log(SWAY_ERROR, "Failed to allocate output config"); sway_log(SWAY_ERROR, "Failed to allocate output config");

@ -1,4 +1,3 @@
#include <strings.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
@ -7,14 +6,6 @@ struct cmd_results *output_cmd_enable(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE, "Missing output config"); return cmd_results_new(CMD_FAILURE, "Missing output config");
} }
// The NOOP-1 output is a dummy output used when there's no outputs
// connected. It should never be enabled.
char *output_name = config->handler_context.output_config->name;
if (strcasecmp(output_name, "NOOP-1") == 0) {
return cmd_results_new(CMD_FAILURE,
"Refusing to enable the no op output");
}
config->handler_context.output_config->enabled = 1; config->handler_context.output_config->enabled = 1;
config->handler_context.leftovers.argc = argc; config->handler_context.leftovers.argc = argc;

@ -176,6 +176,10 @@ void terminate_swaybg(pid_t pid) {
} }
bool apply_output_config(struct output_config *oc, struct sway_output *output) { bool apply_output_config(struct output_config *oc, struct sway_output *output) {
if (output == root->noop_output) {
return false;
}
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
if (oc && !oc->enabled) { if (oc && !oc->enabled) {

Loading…
Cancel
Save