diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-27 22:55:07 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-27 22:55:07 -0400 |
commit | 930d136196f12fc13380c68058c52d86107561cd (patch) | |
tree | 7aac4f1730b810fbe620ba5e70e15a51c46d24d5 | |
parent | update visibility for moved workspaces (diff) | |
parent | Added in default_orientation handling (diff) | |
download | sway-930d136196f12fc13380c68058c52d86107561cd.tar.gz sway-930d136196f12fc13380c68058c52d86107561cd.tar.zst sway-930d136196f12fc13380c68058c52d86107561cd.zip |
Merge pull request #144 from Luminarys/master
Added in default_orientation handling
-rw-r--r-- | include/config.h | 3 | ||||
-rw-r--r-- | sway/commands.c | 14 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/container.c | 11 | ||||
-rw-r--r-- | sway/handlers.c | 7 |
5 files changed, 36 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h index 6d36eb41..d1a6d0ac 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <wlc/wlc.h> | 5 | #include <wlc/wlc.h> |
6 | #include <xkbcommon/xkbcommon.h> | 6 | #include <xkbcommon/xkbcommon.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "layout.h" | ||
8 | 9 | ||
9 | struct sway_variable { | 10 | struct sway_variable { |
10 | char *name; | 11 | char *name; |
@@ -42,6 +43,8 @@ struct sway_config { | |||
42 | list_t *output_configs; | 43 | list_t *output_configs; |
43 | struct sway_mode *current_mode; | 44 | struct sway_mode *current_mode; |
44 | uint32_t floating_mod; | 45 | uint32_t floating_mod; |
46 | enum swayc_layouts default_orientation; | ||
47 | enum swayc_layouts default_layout; | ||
45 | 48 | ||
46 | // Flags | 49 | // Flags |
47 | bool focus_follows_mouse; | 50 | bool focus_follows_mouse; |
diff --git a/sway/commands.c b/sway/commands.c index df48724a..1d88e724 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -388,6 +388,19 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) { | |||
388 | return true; | 388 | return true; |
389 | } | 389 | } |
390 | 390 | ||
391 | static bool cmd_orientation(struct sway_config *config, int argc, char **argv) { | ||
392 | if (strcasecmp(argv[0],"horizontal") == 0) { | ||
393 | config->default_orientation = L_HORIZ; | ||
394 | } else if (strcasecmp(argv[0], "vertical") == 0) { | ||
395 | config->default_orientation = L_VERT; | ||
396 | } else if (strcasecmp(argv[0], "auto") == 0) { | ||
397 | // Do nothing | ||
398 | } else { | ||
399 | return false; | ||
400 | } | ||
401 | return true; | ||
402 | } | ||
403 | |||
391 | static bool cmd_output(struct sway_config *config, int argc, char **argv) { | 404 | static bool cmd_output(struct sway_config *config, int argc, char **argv) { |
392 | if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) { | 405 | if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) { |
393 | return false; | 406 | return false; |
@@ -713,6 +726,7 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) { | |||
713 | /* Keep alphabetized */ | 726 | /* Keep alphabetized */ |
714 | static struct cmd_handler handlers[] = { | 727 | static struct cmd_handler handlers[] = { |
715 | { "bindsym", cmd_bindsym }, | 728 | { "bindsym", cmd_bindsym }, |
729 | { "default_orientation", cmd_orientation }, | ||
716 | { "exec", cmd_exec }, | 730 | { "exec", cmd_exec }, |
717 | { "exec_always", cmd_exec_always }, | 731 | { "exec_always", cmd_exec_always }, |
718 | { "exit", cmd_exit }, | 732 | { "exit", cmd_exit }, |
diff --git a/sway/config.c b/sway/config.c index 53fc860a..08b14f84 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -27,6 +27,8 @@ void config_defaults(struct sway_config *config) { | |||
27 | config->current_mode->name = NULL; | 27 | config->current_mode->name = NULL; |
28 | config->current_mode->bindings = create_list(); | 28 | config->current_mode->bindings = create_list(); |
29 | list_add(config->modes, config->current_mode); | 29 | list_add(config->modes, config->current_mode); |
30 | config->default_layout = L_NONE; | ||
31 | config->default_orientation = L_NONE; | ||
30 | // Flags | 32 | // Flags |
31 | config->focus_follows_mouse = true; | 33 | config->focus_follows_mouse = true; |
32 | config->mouse_warping = true; | 34 | config->mouse_warping = true; |
diff --git a/sway/container.c b/sway/container.c index 05bb6abb..abbd5504 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -146,7 +146,16 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { | |||
146 | sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); | 146 | sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); |
147 | swayc_t *workspace = new_swayc(C_WORKSPACE); | 147 | swayc_t *workspace = new_swayc(C_WORKSPACE); |
148 | 148 | ||
149 | workspace->layout = L_HORIZ; // TODO: default layout | 149 | // TODO: default_layout |
150 | if (config->default_layout != L_NONE) { | ||
151 | workspace->layout = config->default_layout; | ||
152 | } else if (config->default_orientation != L_NONE) { | ||
153 | workspace->layout = config->default_orientation; | ||
154 | } else if (output->width >= output->height) { | ||
155 | workspace->layout = L_HORIZ; | ||
156 | } else { | ||
157 | workspace->layout = L_VERT; | ||
158 | } | ||
150 | workspace->x = output->x; | 159 | workspace->x = output->x; |
151 | workspace->y = output->y; | 160 | workspace->y = output->y; |
152 | workspace->width = output->width; | 161 | workspace->width = output->width; |
diff --git a/sway/handlers.c b/sway/handlers.c index 2223a98c..aa336e8d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -130,6 +130,13 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_ | |||
130 | if (!c) return; | 130 | if (!c) return; |
131 | c->width = to->w; | 131 | c->width = to->w; |
132 | c->height = to->h; | 132 | c->height = to->h; |
133 | if (config->default_layout == L_NONE && config->default_orientation == L_NONE) { | ||
134 | if (c->width >= c->height) { | ||
135 | ((swayc_t*)c->children->items[0])->layout = L_HORIZ; | ||
136 | } else { | ||
137 | ((swayc_t*)c->children->items[0])->layout = L_VERT; | ||
138 | } | ||
139 | } | ||
133 | arrange_windows(&root_container, -1, -1); | 140 | arrange_windows(&root_container, -1, -1); |
134 | } | 141 | } |
135 | 142 | ||