Correctly determine default layout

This commit is contained in:
Mikkel Oscar Lyderik 2016-04-01 15:58:29 +02:00
parent 8d700fe008
commit d26658fb35
5 changed files with 22 additions and 14 deletions

View file

@ -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 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))); 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 #endif

View file

@ -1760,9 +1760,8 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
} }
if (strcasecmp(argv[0], "default") == 0) { if (strcasecmp(argv[0], "default") == 0) {
// TODO: determine default from default_orientation and swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
// cmd_workspace_layout parent->layout = default_layout(output);
parent->layout = L_HORIZ;
} else if (strcasecmp(argv[0], "tabbed") == 0) { } else if (strcasecmp(argv[0], "tabbed") == 0) {
if (parent->type != C_CONTAINER) { if (parent->type != C_CONTAINER) {
parent = new_container(parent, L_TABBED); parent = new_container(parent, L_TABBED);

View file

@ -160,7 +160,7 @@ static void config_defaults(struct sway_config *config) {
config->dragging_key = M_LEFT_CLICK; config->dragging_key = M_LEFT_CLICK;
config->resizing_key = M_RIGHT_CLICK; config->resizing_key = M_RIGHT_CLICK;
config->floating_scroll = FSB_GAPS_INNER; config->floating_scroll = FSB_GAPS_INNER;
config->default_layout = L_HORIZ; config->default_layout = L_NONE;
config->default_orientation = L_NONE; config->default_orientation = L_NONE;
config->font = strdup("monospace 10"); config->font = strdup("monospace 10");
config->font_height = get_font_text_height(config->font); config->font_height = get_font_text_height(config->font);

View file

@ -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); sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle);
swayc_t *workspace = new_swayc(C_WORKSPACE); swayc_t *workspace = new_swayc(C_WORKSPACE);
// TODO: default_layout workspace->layout = default_layout(output);
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->x = output->x; workspace->x = output->x;
workspace->y = output->y; workspace->y = output->y;
workspace->width = output->width; workspace->width = output->width;

View file

@ -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;
}
}