Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

sowm: Window splitting #76

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ static struct key keys[] = {
{MOD, XK_q, win_kill, {0}},
{MOD, XK_c, win_center, {0}},
{MOD, XK_f, win_fs, {0}},

{MOD|Mod1Mask, XK_k, win_half, {.com = (const char*[]){"n"}}},
{MOD|Mod1Mask, XK_j, win_half, {.com = (const char*[]){"s"}}},
{MOD|Mod1Mask, XK_l, win_half, {.com = (const char*[]){"e"}}},
{MOD|Mod1Mask, XK_h, win_half, {.com = (const char*[]){"w"}}},


{Mod1Mask, XK_Tab, win_next, {0}},
{Mod1Mask|ShiftMask, XK_Tab, win_prev, {0}},
Expand Down
12 changes: 12 additions & 0 deletions sowm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ static void (*events[LASTEvent])(XEvent *e) = {

#include "config.h"

void win_half(const Arg arg) {
char m = arg.com[0][0];

win_size(cur->w, &wx, &wy, &ww, &wh);

XMoveResizeWindow(d, cur->w, \
(m == 'w' ? wx : m == 'e' ? (wx + ww / 2) : wx),
(m == 'n' ? wy : m == 's' ? (wy + wh / 2) : wy),
(m == 'w' ? (ww / 2) : m == 'e' ? (ww / 2) : ww),
(m == 'n' ? (wh / 2) : m == 's' ? (wh / 2) : wh));
}

void win_focus(client *c) {
cur = c;
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
Expand Down
1 change: 1 addition & 0 deletions sowm.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void win_focus(client *c);
void win_kill(const Arg arg);
void win_prev(const Arg arg);
void win_next(const Arg arg);
void win_half(const Arg arg);
void win_to_ws(const Arg arg);
void ws_go(const Arg arg);

Expand Down