aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2022-10-15 11:42:04 +0200
committertslil clingman <tslil@posteo.de>2022-10-15 11:46:24 +0200
commit1576cfb84432107ba5985514a40781592a736043 (patch)
treee91ab42487c48298eaeaa493504530d758a562e6 /monsterwm.c
parenta31463d097e2b964801f11ed0b6ba40e43691583 (diff)
add RTILE for tiling with main on right, restore resize function
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/monsterwm.c b/monsterwm.c
index 61f10d5..fd064f2 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -23,7 +23,7 @@
#define ROOTMASK SubstructureRedirectMask|ButtonPressMask|SubstructureNotifyMask|PropertyChangeMask
enum { RESIZE, MOVE };
-enum { TILE, MONOCLE, BSTACK, GRID, FLOAT, MODES };
+enum { TILE, MONOCLE, BSTACK, RTILE, FLOAT, MODES };
enum { WM_PROTOCOLS, WM_DELETE_WINDOW, WM_COUNT };
enum { NET_SUPPORTED, NET_FULLSCREEN, NET_WM_STATE, NET_ACTIVE, NET_COUNT };
@@ -93,6 +93,7 @@ static void next_win();
static void prev_win();
static void quit(const Arg *arg);
static void resize_master(const Arg *arg);
+static void resize_stack(const Arg *arg);
static void spawn(const Arg *arg);
static void swap_master();
static void switch_mode(const Arg *arg);
@@ -154,7 +155,6 @@ static void focusin(XEvent *e);
static unsigned long getcolor(const char* color, const int screen);
static void grabbuttons(Client *c);
static void grabkeys(void);
-static void grid(int x, int y, int w, int h, const Desktop *d);
static void keypress(XEvent *e);
static void maprequest(XEvent *e);
static void monocle(int x, int y, int w, int h, const Desktop *d);
@@ -217,7 +217,7 @@ static void (*events[LASTEvent])(XEvent *e) = {
* d - the desktop to tile its clients
*/
static void (*layout[MODES])(int x, int y, int w, int h, const Desktop *d) = {
- [TILE] = stack, [BSTACK] = stack, [GRID] = grid, [MONOCLE] = monocle,
+ [TILE] = stack, [BSTACK] = stack, [RTILE] = stack, [MONOCLE] = monocle,
};
/**
@@ -1012,6 +1012,14 @@ void resize_master(const Arg *arg) {
}
/**
+ * resize the first stack window
+ */
+void resize_stack(const Arg *arg) {
+ desktops[currdeskidx].sasz += arg->i;
+ tile(&desktops[currdeskidx]);
+}
+
+/**
* main event loop
* on receival of an event call the appropriate handler
*/
@@ -1139,7 +1147,7 @@ void spawn(const Arg *arg) {
* bstack or bottom stack aka h-stack mode/layout
*/
void stack(int x, int y, int w, int h, const Desktop *d) {
- Client *c = NULL, *t = NULL; Bool b = (d->mode == BSTACK);
+ Client *c = NULL, *t = NULL; Bool b = (d->mode == BSTACK), r = (d->mode == RTILE);
int n = 0, p = 0, z = (b ? w:h), ma = (b ? h:w) * MASTER_SIZE + d->masz;
/* count stack windows and grab first non-floating, non-fullscreen window */
@@ -1178,14 +1186,15 @@ void stack(int x, int y, int w, int h, const Desktop *d) {
if (!c || !n) return; else if (n > 1) { p = (z - d->sasz)%n + d->sasz; z = (z - d->sasz)/n; }
/* tile the first non-floating, non-fullscreen window to cover the master area */
- if (b) XMoveResizeWindow(dis, c->win, x, y, w - 2*BORDER_WIDTH, ma - BORDER_WIDTH);
- else XMoveResizeWindow(dis, c->win, x, y, ma - BORDER_WIDTH, h - 2*BORDER_WIDTH);
+ if (b) XMoveResizeWindow(dis, c->win, x, y, w - 2*BORDER_WIDTH, ma - BORDER_WIDTH);
+ else if (r) XMoveResizeWindow(dis, c->win, w - ma + BORDER_WIDTH, y, ma, h - 2*BORDER_WIDTH);
+ else XMoveResizeWindow(dis, c->win, x, y, ma - BORDER_WIDTH, h - 2*BORDER_WIDTH);
/* tile the next non-floating, non-fullscreen (and first) stack window adding p */
for (c = c->next; c && ISFFT(c); c = c->next);
int cw = (b ? h:w) - 2*BORDER_WIDTH - ma, ch = z - BORDER_WIDTH;
if (b) XMoveResizeWindow(dis, c->win, x, y += ma, ch - BORDER_WIDTH + p, cw);
- else XMoveResizeWindow(dis, c->win, x += ma, y, cw, ch - BORDER_WIDTH + p);
+ else XMoveResizeWindow(dis, c->win, r ? x : (x += ma), y, cw, ch - BORDER_WIDTH + p);
/* tile the rest of the non-floating, non-fullscreen stack windows */
for (b ? (x += ch+p):(y += ch+p), c = c->next; c; c = c->next) {