summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-04-01 15:58:29 +0200
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-04-25 00:00:49 +0200
commitd26658fb355fdf7feee2d6aa801e487502e6ce8b (patch)
tree1879cf81d8e55b676bbd4a5b44dd23d5d93e8b5f
parentFix problems with floating windows (diff)
downloadsway-d26658fb355fdf7feee2d6aa801e487502e6ce8b.tar.gz
sway-d26658fb355fdf7feee2d6aa801e487502e6ce8b.tar.zst
sway-d26658fb355fdf7feee2d6aa801e487502e6ce8b.zip
Correctly determine default layout
-rw-r--r--include/layout.h5
-rw-r--r--sway/commands.c5
-rw-r--r--sway/config.c2
-rw-r--r--sway/container.c12
-rw-r--r--sway/layout.c12
5 files changed, 22 insertions, 14 deletions
diff --git a/include/layout.h b/include/layout.h
index b7731031..84552754 100644
--- a/include/layout.h
+++ b/include/layout.h
@@ -67,4 +67,9 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
67void layout_log(const swayc_t *c, int depth); 67void layout_log(const swayc_t *c, int depth);
68void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4))); 68void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4)));
69 69
70/**
71 * Get default layout.
72 */
73enum swayc_layouts default_layout(swayc_t *output);
74
70#endif 75#endif
diff --git a/sway/commands.c b/sway/commands.c
index 12d60854..ce1fe8a3 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1760,9 +1760,8 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
1760 } 1760 }
1761 1761
1762 if (strcasecmp(argv[0], "default") == 0) { 1762 if (strcasecmp(argv[0], "default") == 0) {
1763 // TODO: determine default from default_orientation and 1763 swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
1764 // cmd_workspace_layout 1764 parent->layout = default_layout(output);
1765 parent->layout = L_HORIZ;
1766 } else if (strcasecmp(argv[0], "tabbed") == 0) { 1765 } else if (strcasecmp(argv[0], "tabbed") == 0) {
1767 if (parent->type != C_CONTAINER) { 1766 if (parent->type != C_CONTAINER) {
1768 parent = new_container(parent, L_TABBED); 1767 parent = new_container(parent, L_TABBED);
diff --git a/sway/config.c b/sway/config.c
index c11ccf53..ebcee95b 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -160,7 +160,7 @@ static void config_defaults(struct sway_config *config) {
160 config->dragging_key = M_LEFT_CLICK; 160 config->dragging_key = M_LEFT_CLICK;
161 config->resizing_key = M_RIGHT_CLICK; 161 config->resizing_key = M_RIGHT_CLICK;
162 config->floating_scroll = FSB_GAPS_INNER; 162 config->floating_scroll = FSB_GAPS_INNER;
163 config->default_layout = L_HORIZ; 163 config->default_layout = L_NONE;
164 config->default_orientation = L_NONE; 164 config->default_orientation = L_NONE;
165 config->font = strdup("monospace 10"); 165 config->font = strdup("monospace 10");
166 config->font_height = get_font_text_height(config->font); 166 config->font_height = get_font_text_height(config->font);
diff --git a/sway/container.c b/sway/container.c
index 2b100f40..5579fddb 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -163,16 +163,8 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
163 sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); 163 sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle);
164 swayc_t *workspace = new_swayc(C_WORKSPACE); 164 swayc_t *workspace = new_swayc(C_WORKSPACE);
165 165
166 // TODO: default_layout 166 workspace->layout = default_layout(output);
167 if (config->default_layout != L_NONE) { 167
168 workspace->layout = config->default_layout;
169 } else if (config->default_orientation != L_NONE) {
170 workspace->layout = config->default_orientation;
171 } else if (output->width >= output->height) {
172 workspace->layout = L_HORIZ;
173 } else {
174 workspace->layout = L_VERT;
175 }
176 workspace->x = output->x; 168 workspace->x = output->x;
177 workspace->y = output->y; 169 workspace->y = output->y;
178 workspace->width = output->width; 170 workspace->width = output->width;
diff --git a/sway/layout.c b/sway/layout.c
index 527579d9..261e2138 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -993,3 +993,15 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
993 } 993 }
994 } 994 }
995} 995}
996
997enum swayc_layouts default_layout(swayc_t *output) {
998 if (config->default_layout != L_NONE) {
999 return config->default_layout;
1000 } else if (config->default_orientation != L_NONE) {
1001 return config->default_orientation;
1002 } else if (output->width >= output->height) {
1003 return L_HORIZ;
1004 } else {
1005 return L_VERT;
1006 }
1007}