Merge pull request #123 from Luminarys/master

Added in output disabling
This commit is contained in:
Drew DeVault 2015-08-23 14:34:20 -04:00
commit 663f53b22a
5 changed files with 19 additions and 0 deletions

View file

@ -24,6 +24,7 @@ struct sway_mode {
struct output_config { struct output_config {
char *name; char *name;
bool enabled;
int width, height; int width, height;
int x, y; int x, y;
}; };

View file

@ -85,6 +85,9 @@ Commands
arranged at the given position in the layout tree. You may omit either of 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. these parameters if you only want to set one of them.
**output** <name> disable::
Disables the specified output.
**reload**:: **reload**::
Reloads the sway config file without restarting sway. Reloads the sway config file without restarting sway.

View file

@ -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)); struct output_config *output = calloc(1, sizeof(struct output_config));
output->x = output->y = output->width = output->height = -1; output->x = output->y = output->width = output->height = -1;
output->name = strdup(argv[0]); output->name = strdup(argv[0]);
output->enabled = true;
// TODO: atoi doesn't handle invalid numbers // TODO: atoi doesn't handle invalid numbers
if (strcasecmp(argv[1], "disable") == 0) {
output->enabled = false;
}
int i; int i;
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {

View file

@ -70,6 +70,10 @@ swayc_t *new_output(wlc_handle handle) {
oc = NULL; oc = NULL;
} }
if (oc && !oc->enabled) {
return NULL;
}
swayc_t *output = new_swayc(C_OUTPUT); swayc_t *output = new_swayc(C_OUTPUT);
if (oc && oc->width != -1 && oc->height != -1) { if (oc && oc->width != -1 && oc->height != -1) {
output->width = oc->width; output->width = oc->width;

View file

@ -86,6 +86,10 @@ swayc_t *container_under_pointer(void) {
static bool handle_output_created(wlc_handle output) { static bool handle_output_created(wlc_handle output) {
swayc_t *op = new_output(output); swayc_t *op = new_output(output);
if (!op) {
return false;
}
// Switch to workspace if we need to // Switch to workspace if we need to
if (swayc_active_workspace() == NULL) { if (swayc_active_workspace() == NULL) {
swayc_t *ws = op->children->items[0]; swayc_t *ws = op->children->items[0];
@ -104,6 +108,8 @@ static void handle_output_destroyed(wlc_handle output) {
} }
if (i < list->length) { if (i < list->length) {
destroy_output(list->items[i]); destroy_output(list->items[i]);
} else {
return;
} }
if (list->length > 0) { if (list->length > 0) {
// switch to other outputs active workspace // switch to other outputs active workspace