Merge pull request #144 from Luminarys/master

Added in default_orientation handling
master
Drew DeVault 9 years ago
commit 930d136196

@ -5,6 +5,7 @@
#include <wlc/wlc.h>
#include <xkbcommon/xkbcommon.h>
#include "list.h"
#include "layout.h"
struct sway_variable {
char *name;
@ -42,6 +43,8 @@ struct sway_config {
list_t *output_configs;
struct sway_mode *current_mode;
uint32_t floating_mod;
enum swayc_layouts default_orientation;
enum swayc_layouts default_layout;
// Flags
bool focus_follows_mouse;

@ -388,6 +388,19 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
return true;
}
static bool cmd_orientation(struct sway_config *config, int argc, char **argv) {
if (strcasecmp(argv[0],"horizontal") == 0) {
config->default_orientation = L_HORIZ;
} else if (strcasecmp(argv[0], "vertical") == 0) {
config->default_orientation = L_VERT;
} else if (strcasecmp(argv[0], "auto") == 0) {
// Do nothing
} else {
return false;
}
return true;
}
static bool cmd_output(struct sway_config *config, int argc, char **argv) {
if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) {
return false;
@ -713,6 +726,7 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
/* Keep alphabetized */
static struct cmd_handler handlers[] = {
{ "bindsym", cmd_bindsym },
{ "default_orientation", cmd_orientation },
{ "exec", cmd_exec },
{ "exec_always", cmd_exec_always },
{ "exit", cmd_exit },

@ -27,6 +27,8 @@ void config_defaults(struct sway_config *config) {
config->current_mode->name = NULL;
config->current_mode->bindings = create_list();
list_add(config->modes, config->current_mode);
config->default_layout = L_NONE;
config->default_orientation = L_NONE;
// Flags
config->focus_follows_mouse = true;
config->mouse_warping = true;

@ -146,7 +146,16 @@ 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);
workspace->layout = L_HORIZ; // TODO: default layout
// 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->x = output->x;
workspace->y = output->y;
workspace->width = output->width;

@ -130,6 +130,13 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_
if (!c) return;
c->width = to->w;
c->height = to->h;
if (config->default_layout == L_NONE && config->default_orientation == L_NONE) {
if (c->width >= c->height) {
((swayc_t*)c->children->items[0])->layout = L_HORIZ;
} else {
((swayc_t*)c->children->items[0])->layout = L_VERT;
}
}
arrange_windows(&root_container, -1, -1);
}

Loading…
Cancel
Save