Compare commits

...

5 Commits

Author SHA1 Message Date
yosh cc11b498c7 magnet patch 2023-04-15 13:51:04 -04:00
yosh 080591fb08 fair layout patch update 2023-04-15 13:51:04 -04:00
yosh 1a709b1e34 warp on move to group patch 2023-04-15 13:51:04 -04:00
yosh 27f167782b update README 2023-04-15 13:51:04 -04:00
yosh 947657dacf add patch files 2023-04-15 13:51:04 -04:00
7 changed files with 544 additions and 0 deletions

18
README
View File

@ -1,3 +1,21 @@
The patches applied in the patched branch include:
* romannumerals.diff - renames "one", "two", etc. to roman numerals
- this can easily be changed in conf.c before compiling
* forcetile.diff - when you have the master window focused in a tile layout
and attempt to tile in the other direction, nothing will happen. this patch
forces the tiling to happen
* fairlayout.diff - adds two new keybinds, window-vfair and window-hfair, which
mimic the layout of awesomewm's fair layouts, because I like those layouts
* warp-on-close.diff - when closing a window with window-close, the pointer
automatically focuses the next available window in the group
* warp-on-movetogroup.diff - when moving a window to another group with
window-movetogroup-n, the pointer automatically focuses the next available
window in the group
* magnet-tiles.diff - taken from https://github.com/mlukow/OpenBSD-patches,
refer to that repository to see what it adds
you can clone the linux branch of this repository and apply patches individually
if you don't want all the patches the patched branch offers
This is a port of OpenBSD's excellent cwm[0] to Linux and other Unices.
cwm is a window manager for X11 which contains many features that

238
patches/fairlayout.diff Normal file
View File

@ -0,0 +1,238 @@
diff --git a/Makefile b/Makefile
index 1f56cd4..4e295ac 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ CPPFLAGS+= `${PKG_CONFIG} --cflags x11 xft xrandr`
CFLAGS?= -Wall -O2 -g -D_GNU_SOURCE
-LDFLAGS+= `${PKG_CONFIG} --libs x11 xft xrandr`
+LDFLAGS+= `${PKG_CONFIG} --libs x11 xft xrandr` -lm
MANPREFIX?= ${PREFIX}/share/man
diff --git a/calmwm.h b/calmwm.h
index b3992c3..42ed9a4 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -429,6 +429,7 @@ struct client_ctx *client_find(Window);
void client_get_sizehints(struct client_ctx *);
void client_hide(struct client_ctx *);
void client_htile(struct client_ctx *);
+void client_hfair(struct client_ctx *);
int client_inbound(struct client_ctx *, int, int);
struct client_ctx *client_init(Window, struct screen_ctx *);
void client_lower(struct client_ctx *);
@@ -458,6 +459,7 @@ void client_toggle_vmaximize(struct client_ctx *);
void client_transient(struct client_ctx *);
void client_urgency(struct client_ctx *);
void client_vtile(struct client_ctx *);
+void client_vfair(struct client_ctx *);
void client_wm_hints(struct client_ctx *);
void group_assign(struct group_ctx *, struct client_ctx *);
@@ -528,7 +530,9 @@ void kbfunc_client_toggle_maximize(void *, struct cargs *);
void kbfunc_client_toggle_hmaximize(void *, struct cargs *);
void kbfunc_client_toggle_vmaximize(void *, struct cargs *);
void kbfunc_client_htile(void *, struct cargs *);
+void kbfunc_client_hfair(void *, struct cargs *);
void kbfunc_client_vtile(void *, struct cargs *);
+void kbfunc_client_vfair(void *, struct cargs *);
void kbfunc_client_cycle(void *, struct cargs *);
void kbfunc_client_toggle_group(void *, struct cargs *);
void kbfunc_client_movetogroup(void *, struct cargs *);
diff --git a/client.c b/client.c
index 59bc7b0..dab0ce9 100644
--- a/client.c
+++ b/client.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <math.h>
#include "calmwm.h"
@@ -1047,3 +1048,127 @@ client_vtile(struct client_ctx *cc)
client_resize(ci, 1);
}
}
+
+void
+client_vfair(struct client_ctx *cc)
+{
+ struct client_ctx *ci;
+ struct screen_ctx *sc = cc->sc;
+ struct geom area;
+ int i, n, w, h, rows, cols, rh, t;
+
+ i = n = 0;
+ area = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, 1);
+
+ TAILQ_FOREACH(ci, &sc->clientq, entry) {
+ if (ci->gc != cc->gc)
+ continue;
+ if (ci->flags & CLIENT_HIDDEN ||
+ ci->flags & CLIENT_IGNORE ||
+ ci->geom.x < area.x ||
+ ci->geom.x > (area.x + area.w) ||
+ ci->geom.y < area.y ||
+ ci->geom.y > (area.y + area.h))
+ continue;
+ n++;
+ }
+ if (n == 0)
+ return;
+
+ cc->flags &= ~CLIENT_MAXIMIZED;
+ rows = (n == 2) ? 1 : ceil(sqrt(n));
+ cols = ceil((double)n / rows);
+ w = area.w / cols;
+ h = area.h / rows;
+ rh = area.h / (n % rows == 0 ? rows : n % rows);
+ t = rows * (cols - 1);
+
+ TAILQ_FOREACH(ci, &sc->clientq, entry) {
+ if (ci->gc != cc->gc)
+ continue;
+ if (ci->flags & CLIENT_HIDDEN ||
+ ci->flags & CLIENT_IGNORE ||
+ ci->geom.x < area.x ||
+ ci->geom.x > (area.x + area.w) ||
+ ci->geom.y < area.y ||
+ ci->geom.y > (area.y + area.h))
+ continue;
+ ci->bwidth = Conf.bwidth;
+ ci->geom.x = area.x + (i / rows) * w;
+ ci->geom.y = area.y + (i % rows) * (i < t ? h : rh);
+ ci->geom.w = (i < t)
+ ? w - (ci->bwidth * 2)
+ : area.x + area.w - ci->geom.x - (ci->bwidth * 2);
+ ci->geom.h = (i < t ? h : rh) - (ci->bwidth * 2);
+ if ((i + 1) == n || (i + 1) % rows == 0)
+ ci->geom.h = area.y + area.h -
+ ci->geom.y - (ci->bwidth * 2);
+ i++;
+ client_resize(ci, 1);
+ }
+ client_ptr_warp(cc);
+}
+
+void
+client_hfair(struct client_ctx *cc)
+{
+ struct client_ctx *ci;
+ struct screen_ctx *sc = cc->sc;
+ struct geom area;
+ int i, n, w, h, rows, cols, rw, t;
+
+ i = n = 0;
+ area = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, 1);
+
+ TAILQ_FOREACH(ci, &sc->clientq, entry) {
+ if (ci->gc != cc->gc)
+ continue;
+ if (ci->flags & CLIENT_HIDDEN ||
+ ci->flags & CLIENT_IGNORE ||
+ ci->geom.x < area.x ||
+ ci->geom.x > (area.x + area.w) ||
+ ci->geom.y < area.y ||
+ ci->geom.y > (area.y + area.h))
+ continue;
+ n++;
+ }
+ if (n == 0)
+ return;
+
+ cc->flags &= ~CLIENT_MAXIMIZED;
+ cols = (n == 2) ? 1 : ceil(sqrt(n));
+ rows = ceil((double)n / cols);
+ w = area.w / cols;
+ h = area.h / rows;
+ rw = area.w / (n % cols == 0 ? cols : n % cols);
+ t = cols * (rows - 1);
+
+ TAILQ_FOREACH(ci, &sc->clientq, entry) {
+ if (ci->gc != cc->gc)
+ continue;
+ if (ci->flags & CLIENT_HIDDEN ||
+ ci->flags & CLIENT_IGNORE ||
+ ci->geom.x < area.x ||
+ ci->geom.x > (area.x + area.w) ||
+ ci->geom.y < area.y ||
+ ci->geom.y > (area.y + area.h))
+ continue;
+ ci->bwidth = Conf.bwidth;
+ ci->geom.y = area.y + (i / cols) * h;
+ ci->geom.x = area.x + (i % cols) * (i < t ? w : rw);
+ ci->geom.h = (i < t)
+ ? h - (ci->bwidth * 2)
+ : area.y + area.h - ci->geom.y - (ci->bwidth * 2);
+ ci->geom.w = (i < t ? w : rw) - (ci->bwidth * 2);
+ if ((i + 1) == n || (i + 1) % cols == 0)
+ ci->geom.w = area.x + area.w -
+ ci->geom.x - (ci->bwidth * 2);
+ i++;
+ client_resize(ci, 1);
+ }
+ client_ptr_warp(cc);
+}
diff --git a/conf.c b/conf.c
index 7d3ae6e..dbd9ed0 100644
--- a/conf.c
+++ b/conf.c
@@ -86,6 +86,8 @@ static const struct {
{ FUNC_CC(window-delete, client_close, 0) },
{ FUNC_CC(window-htile, client_htile, 0) },
{ FUNC_CC(window-vtile, client_vtile, 0) },
+ { FUNC_CC(window-hfair, client_hfair, 0) },
+ { FUNC_CC(window-vfair, client_vfair, 0) },
{ FUNC_CC(window-stick, client_toggle_sticky, 0) },
{ FUNC_CC(window-fullscreen, client_toggle_fullscreen, 0) },
{ FUNC_CC(window-maximize, client_toggle_maximize, 0) },
diff --git a/cwmrc.5 b/cwmrc.5
index 7075288..4046a97 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -329,6 +329,14 @@ and resized to
.Ar vtile
(default half) of the horizontal screen space.
Other windows in its group share remaining screen space.
+.It window-hfair
+Current window is placed at the top left of the screen, and all windows
+attempt to occupy the screen space fairly, with remainder windows being
+distributed evenly along the bottom.
+.It window-vfair
+Current window is placed at the top left of the screen, and all windows
+attempt to occupy the screen space fairly, with remainder windows being
+distributed evenly along the right side.
.It window-move
Move current window.
.It window-resize
diff --git a/kbfunc.c b/kbfunc.c
index ed1d7cb..bb12595 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -401,6 +401,18 @@ kbfunc_client_vtile(void *ctx, struct cargs *cargs)
client_vtile(ctx);
}
+void
+kbfunc_client_vfair(void *ctx, struct cargs *cargs)
+{
+ client_vfair(ctx);
+}
+
+void
+kbfunc_client_hfair(void *ctx, struct cargs *cargs)
+{
+ client_hfair(ctx);
+}
+
void
kbfunc_client_cycle(void *ctx, struct cargs *cargs)
{

30
patches/forcetile.diff Normal file
View File

@ -0,0 +1,30 @@
diff --git a/client.c b/client.c
index 59bc7b0..8fa4f6b 100644
--- a/client.c
+++ b/client.c
@@ -938,11 +938,7 @@ client_htile(struct client_ctx *cc)
if (n == 0)
return;
- if (cc->flags & CLIENT_VMAXIMIZED ||
- cc->geom.h + (cc->bwidth * 2) >= area.h)
- return;
-
- cc->flags &= ~CLIENT_HMAXIMIZED;
+ cc->flags &= ~CLIENT_MAXIMIZED;
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.w = area.w - (cc->bwidth * 2);
@@ -1007,11 +1003,7 @@ client_vtile(struct client_ctx *cc)
if (n == 0)
return;
- if (cc->flags & CLIENT_HMAXIMIZED ||
- cc->geom.w + (cc->bwidth * 2) >= area.w)
- return;
-
- cc->flags &= ~CLIENT_VMAXIMIZED;
+ cc->flags &= ~CLIENT_MAXIMIZED;
cc->geom.x = area.x;
cc->geom.y = area.y;
if (Conf.vtile > 0)

168
patches/magnet-tiles.diff Normal file
View File

@ -0,0 +1,168 @@
diff --git a/calmwm.h b/calmwm.h
index 95e3c8d..4026764 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -506,6 +506,7 @@ void kbfunc_ptrmove(void *, struct cargs *);
void kbfunc_client_snap(void *, struct cargs *);
void kbfunc_client_move(void *, struct cargs *);
void kbfunc_client_resize(void *, struct cargs *);
+void kbfunc_client_tile(void *, struct cargs *);
void kbfunc_client_close(void *, struct cargs *);
void kbfunc_client_lower(void *, struct cargs *);
void kbfunc_client_raise(void *, struct cargs *);
diff --git a/conf.c b/conf.c
index 53ca295..19d0e95 100644
--- a/conf.c
+++ b/conf.c
@@ -102,6 +102,7 @@ static const struct {
{ FUNC_CC(window-movetogroup-7, client_movetogroup, 7) },
{ FUNC_CC(window-movetogroup-8, client_movetogroup, 8) },
{ FUNC_CC(window-movetogroup-9, client_movetogroup, 9) },
+ { FUNC_CC(window-center, client_snap, 0) },
{ FUNC_CC(window-snap-up, client_snap, (CWM_UP)) },
{ FUNC_CC(window-snap-down, client_snap, (CWM_DOWN)) },
{ FUNC_CC(window-snap-right, client_snap, (CWM_RIGHT)) },
@@ -128,6 +129,14 @@ static const struct {
{ FUNC_CC(window-resize-down-big, client_resize, (CWM_DOWN_BIG)) },
{ FUNC_CC(window-resize-right-big, client_resize, (CWM_RIGHT_BIG)) },
{ FUNC_CC(window-resize-left-big, client_resize, (CWM_LEFT_BIG)) },
+ { FUNC_CC(window-tile-up, client_tile, (CWM_UP)) },
+ { FUNC_CC(window-tile-down, client_tile, (CWM_DOWN)) },
+ { FUNC_CC(window-tile-left, client_tile, (CWM_LEFT)) },
+ { FUNC_CC(window-tile-right, client_tile, (CWM_RIGHT)) },
+ { FUNC_CC(window-tile-up-left, client_tile, (CWM_UP_LEFT)) },
+ { FUNC_CC(window-tile-up-right, client_tile, (CWM_UP_RIGHT)) },
+ { FUNC_CC(window-tile-down-left, client_tile, (CWM_DOWN_LEFT)) },
+ { FUNC_CC(window-tile-down-right, client_tile, (CWM_DOWN_RIGHT)) },
{ FUNC_CC(window-menu-label, client_menu_label, 0) },
{ FUNC_SC(window-cycle, client_cycle, (CWM_CYCLE_FORWARD)) },
diff --git a/cwmrc.5 b/cwmrc.5
index ab70d25..80d6f03 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -411,6 +411,24 @@ Snap window to top-left corner.
Snap window to bottom-right corner.
.It window-snap-down-left
Snap window to bottom-left corner.
+.It window-tile-up
+Fill the top half of the screen with the window.
+.It window-tile-down
+Fill the bottom half of the screen with the window.
+.It window-tile-left
+Fill the left half of the screen with the window.
+.It window-tile-right
+Fill the right half of the screen with the window.
+.It window-tile-up-left
+Fill the top left quarter of the screen with the window.
+.It window-tile-up-right
+Fill the top right quarter of the screen with the window.
+.It window-tile-down-left
+Fill the down left quarter of the screen with the window.
+.It window-tile-down-right
+Fill the down right quarter of the screen with the window.
+.It window-center
+Centers the window on the screen.
.It pointer-move-up
Move pointer
.Ar moveamount
diff --git a/kbfunc.c b/kbfunc.c
index 2d5d1ce..24f27ad 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -304,28 +304,77 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs)
cc->geom.y + cc->geom.h / 2, 1);
flags = cargs->flag;
- while (flags) {
- if (flags & CWM_UP) {
- cc->geom.y = area.y;
- flags &= ~CWM_UP;
- }
- if (flags & CWM_LEFT) {
- cc->geom.x = area.x;
- flags &= ~CWM_LEFT;
- }
- if (flags & CWM_RIGHT) {
- cc->geom.x = area.x + area.w - cc->geom.w -
- (cc->bwidth * 2);
- flags &= ~CWM_RIGHT;
- }
- if (flags & CWM_DOWN) {
- cc->geom.y = area.y + area.h - cc->geom.h -
- (cc->bwidth * 2);
- flags &= ~CWM_DOWN;
+
+ if (flags) {
+ while (flags) {
+ if (flags & CWM_UP) {
+ cc->geom.y = area.y;
+ flags &= ~CWM_UP;
+ }
+ if (flags & CWM_LEFT) {
+ cc->geom.x = area.x;
+ flags &= ~CWM_LEFT;
+ }
+ if (flags & CWM_RIGHT) {
+ cc->geom.x = area.x + area.w - cc->geom.w -
+ (cc->bwidth * 2);
+ flags &= ~CWM_RIGHT;
+ }
+ if (flags & CWM_DOWN) {
+ cc->geom.y = area.y + area.h - cc->geom.h -
+ (cc->bwidth * 2);
+ flags &= ~CWM_DOWN;
+ }
}
+ } else {
+ cc->geom.x = area.x + (area.w - cc->geom.w) / 2 - cc->bwidth;
+ cc->geom.y = area.y + (area.h - cc->geom.h) / 2 - cc->bwidth;
+ }
+
+ client_move(cc);
+ client_ptr_inbound(cc, 1);
+}
+
+void
+kbfunc_client_tile(void *ctx, struct cargs *cargs)
+{
+ struct client_ctx *cc = ctx;
+ struct screen_ctx *sc = cc->sc;
+ struct geom area;
+ int flags;
+
+ area = screen_area(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, 1);
+
+ flags = cargs->flag;
+
+ if (flags & CWM_UP) {
+ cc->geom.y = area.y;
+ cc->geom.h = area.h / 2 - (cc->bwidth * 2);
+ } else if (flags & CWM_DOWN) {
+ cc->geom.y = area.y + area.h / 2;
+ cc->geom.h = area.h / 2 - (cc->bwidth * 2);
+ } else {
+ cc->geom.y = area.y;
+ cc->geom.h = area.h - (cc->bwidth * 2);
+ }
+
+ if (flags & CWM_LEFT) {
+ cc->geom.x = area.x;
+ cc->geom.w = area.w / 2 - (cc->bwidth * 2);
+ } else if (flags & CWM_RIGHT) {
+ cc->geom.x = area.x + area.w / 2;
+ cc->geom.w = area.w / 2 - (cc->bwidth * 2);
+ } else {
+ cc->geom.x = area.x;
+ cc->geom.w = area.w - (cc->bwidth * 2);
}
+
+ client_resize(cc, 1);
client_move(cc);
client_ptr_inbound(cc, 1);
+ XSync(X_Dpy, True);
}
void

View File

@ -0,0 +1,31 @@
diff --git a/conf.c b/conf.c
index 7d3ae6e..68bf157 100644
--- a/conf.c
+++ b/conf.c
@@ -40,16 +40,16 @@ static const struct {
int num;
const char *name;
} group_binds[] = {
- { 0, "nogroup" },
- { 1, "one" },
- { 2, "two" },
- { 3, "three" },
- { 4, "four" },
- { 5, "five" },
- { 6, "six" },
- { 7, "seven" },
- { 8, "eight" },
- { 9, "nine" },
+ { 0, "0" },
+ { 1, "I" },
+ { 2, "II" },
+ { 3, "III" },
+ { 4, "IV" },
+ { 5, "V" },
+ { 6, "VI" },
+ { 7, "VII" },
+ { 8, "VIII" },
+ { 9, "IX" },
};
static int cursor_binds[] = {
XC_left_ptr, /* CF_NORMAL */

View File

@ -0,0 +1,30 @@
diff --git a/client.c b/client.c
index 59bc7b0..9c04175 100644
--- a/client.c
+++ b/client.c
@@ -652,6 +652,25 @@ client_wm_hints(struct client_ctx *cc)
void
client_close(struct client_ctx *cc)
{
+ struct client_ctx *newcc = cc;
+ struct screen_ctx *sc = cc->sc;
+
+ TAILQ_FOREACH(newcc, &sc->clientq, entry) {
+ if (newcc->gc != cc->gc)
+ continue;
+ if (newcc->flags & CLIENT_HIDDEN ||
+ newcc->flags & CLIENT_IGNORE || (newcc == cc))
+ continue;
+ break;
+ }
+ if (newcc != NULL) {
+ if (newcc->ptr.x < 0 || newcc->ptr.x > newcc->geom.w ||
+ newcc->ptr.y < 0 || newcc->ptr.y > newcc->geom.h) {
+ newcc->ptr.x = newcc->geom.w / 2;
+ newcc->ptr.y = newcc->geom.h / 2;
+ }
+ client_ptr_warp(newcc);
+ }
if (cc->flags & CLIENT_WM_DELETE_WINDOW)
xu_send_clientmsg(cc->win, cwmh[WM_DELETE_WINDOW], CurrentTime);
else

View File

@ -0,0 +1,29 @@
diff --git a/group.c b/group.c
index af4c759..9c93497 100644
--- a/group.c
+++ b/group.c
@@ -152,6 +152,24 @@ group_movetogroup(struct client_ctx *cc, int idx)
{
struct screen_ctx *sc = cc->sc;
struct group_ctx *gc;
+ struct client_ctx *newcc = cc;
+
+ TAILQ_FOREACH(newcc, &sc->clientq, entry) {
+ if (newcc->gc != cc->gc)
+ continue;
+ if (newcc->flags & CLIENT_HIDDEN ||
+ newcc->flags & CLIENT_IGNORE || (newcc == cc))
+ continue;
+ break;
+ }
+ if (newcc != NULL) {
+ if (newcc->ptr.x < 0 || newcc->ptr.x > newcc->geom.w ||
+ newcc->ptr.y < 0 || newcc->ptr.y > newcc->geom.h) {
+ newcc->ptr.x = newcc->geom.w / 2;
+ newcc->ptr.y = newcc->geom.h / 2;
+ }
+ client_ptr_warp(newcc);
+ }
TAILQ_FOREACH(gc, &sc->groupq, entry) {
if (gc->num == idx) {