# Start dmenu (Mod1+p)
bindsym Mod1+p exec /usr/bin/dmenu_run
+# Default orientation
+new_container_orientation horizontal
+
+# Horizontal orientation
bindsym Mod1+h split h
+
+# Vertical orientation
bindsym Mod1+v split v
# Fullscreen (Mod1+f)
int container_stack_limit;
int container_stack_limit_value;
+ /** Default orientation for new containers */
+ int default_orientation;
+
/** By default, focus follows mouse. If the user explicitly wants to
* turn this off (and instead rely only on the keyboard for changing
* focus), we allow him to do this with this relatively special option.
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
restart_state { BEGIN(BIND_AWS_COND); return TOKRESTARTSTATE; }
+new_container_orientation { return TOK_ORIENTATION; }
+horizontal { return TOK_HORIZ; }
+vertical { return TOK_VERT; }
+auto { return TOK_AUTO; }
new_container { return TOKNEWCONTAINER; }
new_window { return TOKNEWWINDOW; }
normal { return TOK_NORMAL; }
%token TOKCOLOR
%token TOKARROW "→"
%token TOKMODE "mode"
+%token TOK_ORIENTATION "new_container_orientation"
+%token TOK_HORIZ "horizontal"
+%token TOK_VERT "vertical"
+%token TOK_AUTO "auto"
%token TOKNEWCONTAINER "new_container"
%token TOKNEWWINDOW "new_window"
%token TOK_NORMAL "normal"
bindline
| mode
| floating_modifier
+ | orientation
| new_container
| new_window
| focus_follows_mouse
}
;
+orientation:
+ TOK_ORIENTATION WHITESPACE direction
+ {
+ DLOG("New containers should start with split direction %d\n", $<number>3);
+ config.default_orientation = $<number>3;
+ }
+ ;
+
+direction:
+ TOK_HORIZ { $<number>$ = HORIZ; }
+ | TOK_VERT { $<number>$ = VERT; }
+ | TOK_AUTO { $<number>$ = NO_ORIENTATION; }
+ ;
+
new_container:
TOKNEWCONTAINER WHITESPACE TOKCONTAINERMODE
{
/* 3: While the layout is irrelevant in stacked/tabbed mode, it needs
* to be set. Otherwise, this con will not be interpreted as a split
* container. */
- new->orientation = HORIZ;
+ if (config.default_orientation == NO_ORIENTATION) {
+ new->orientation = (con->rect.height > con->rect.width) ? VERT : HORIZ;
+ } else {
+ new->orientation = config.default_orientation;
+ }
Con *old_focused = TAILQ_FIRST(&(con->focus_head));
if (old_focused == TAILQ_END(&(con->focus_head)))
INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff");
config.default_border = BS_NORMAL;
+ /* Set default_orientation to NO_ORIENTATION for auto orientation. */
+ config.default_orientation = NO_ORIENTATION;
parse_configuration(override_configpath);
free(name);
ws->fullscreen_mode = CF_OUTPUT;
- ws->orientation = HORIZ;
+
+ /* If default_orientation is set to NO_ORIENTATION we determine
+ * orientation depending on output resolution. */
+ if (config.default_orientation == NO_ORIENTATION) {
+ ws->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
+ DLOG("Auto orientation. Workspace size set to (%d,%d), setting orientation to %d.\n",
+ output->rect.width, output->rect.height, ws->orientation);
+ } else {
+ ws->orientation = config.default_orientation;
+ }
+
/* TODO: Set focus in main.c */
con_focus(ws);
DLOG("Output mode changed, updating rect\n");
assert(output->con != NULL);
output->con->rect = output->rect;
+
+ Con *current,*workspace,*child;
+
+ /* Point current to the container of the workspaces */
+ current = output->con->nodes_head.tqh_first->nodes.tqe_next;
+
+ /* If default_orientation is NO_ORIENTATION, we change the orientation of
+ * the workspaces and their childs depending on output resolution. This is
+ * only done for workspaces with maximum one child. */
+ if (config.default_orientation == NO_ORIENTATION) {
+ TAILQ_FOREACH(workspace, &(current->nodes_head), nodes) {
+
+ /* Check if this workspace has <= 1 childs. */
+ child = workspace->nodes_head.tqh_first;
+ if (child != NULL)
+ if (child->nodes.tqe_next == NULL) {
+ workspace->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
+ DLOG("Setting workspace [%d,%s]'s orientation to %d.\n", workspace->num, workspace->name, workspace->orientation);
+ child->orientation = workspace->orientation;
+ DLOG("Setting child [%d,%s]'s orientation to %d.\n", child->num, child->name, child->orientation);
+ }
+ }
+ }
+
#if 0
Rect bar_rect = {output->rect.x,
output->rect.y + output->rect.height - (font->height + 6),
workspace->num = -1;
else workspace->num = parsed_num;
LOG("num = %d\n", workspace->num);
- workspace->orientation = HORIZ;
+
+ /* If default_orientation is set to NO_ORIENTATION we
+ * determine workspace orientation from workspace size.
+ * Otherwise we just set the orientation to default_orientation. */
+ if (config.default_orientation == NO_ORIENTATION) {
+ workspace->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
+ DLOG("Auto orientation. Output resolution set to (%d,%d), setting orientation to %d.\n",
+ workspace->rect.width, workspace->rect.height, workspace->orientation);
+ } else {
+ workspace->orientation = config.default_orientation;
+ }
+
con_attach(workspace, content, false);
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");