mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 09:51:29 +00:00
Correctly determine default layout
This commit is contained in:
parent
8d700fe008
commit
d26658fb35
|
@ -67,4 +67,9 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
|
|||
void layout_log(const swayc_t *c, int depth);
|
||||
void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4)));
|
||||
|
||||
/**
|
||||
* Get default layout.
|
||||
*/
|
||||
enum swayc_layouts default_layout(swayc_t *output);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1760,9 +1760,8 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (strcasecmp(argv[0], "default") == 0) {
|
||||
// TODO: determine default from default_orientation and
|
||||
// cmd_workspace_layout
|
||||
parent->layout = L_HORIZ;
|
||||
swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
|
||||
parent->layout = default_layout(output);
|
||||
} else if (strcasecmp(argv[0], "tabbed") == 0) {
|
||||
if (parent->type != C_CONTAINER) {
|
||||
parent = new_container(parent, L_TABBED);
|
||||
|
|
|
@ -160,7 +160,7 @@ static void config_defaults(struct sway_config *config) {
|
|||
config->dragging_key = M_LEFT_CLICK;
|
||||
config->resizing_key = M_RIGHT_CLICK;
|
||||
config->floating_scroll = FSB_GAPS_INNER;
|
||||
config->default_layout = L_HORIZ;
|
||||
config->default_layout = L_NONE;
|
||||
config->default_orientation = L_NONE;
|
||||
config->font = strdup("monospace 10");
|
||||
config->font_height = get_font_text_height(config->font);
|
||||
|
|
|
@ -163,16 +163,8 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
|
|||
sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle);
|
||||
swayc_t *workspace = new_swayc(C_WORKSPACE);
|
||||
|
||||
// TODO: default_layout
|
||||
if (config->default_layout != L_NONE) {
|
||||
workspace->layout = config->default_layout;
|
||||
} else if (config->default_orientation != L_NONE) {
|
||||
workspace->layout = config->default_orientation;
|
||||
} else if (output->width >= output->height) {
|
||||
workspace->layout = L_HORIZ;
|
||||
} else {
|
||||
workspace->layout = L_VERT;
|
||||
}
|
||||
workspace->layout = default_layout(output);
|
||||
|
||||
workspace->x = output->x;
|
||||
workspace->y = output->y;
|
||||
workspace->width = output->width;
|
||||
|
|
|
@ -993,3 +993,15 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum swayc_layouts default_layout(swayc_t *output) {
|
||||
if (config->default_layout != L_NONE) {
|
||||
return config->default_layout;
|
||||
} else if (config->default_orientation != L_NONE) {
|
||||
return config->default_orientation;
|
||||
} else if (output->width >= output->height) {
|
||||
return L_HORIZ;
|
||||
} else {
|
||||
return L_VERT;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue