Last active
April 7, 2024 10:05
-
-
Save TaylanTatli/30e24ecac20f9ebb0ee146801750ff84 to your computer and use it in GitHub Desktop.
CWM patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/calmwm.h b/calmwm.h | |
index b28b454..0793c92 100644 | |
--- a/calmwm.h | |
+++ b/calmwm.h | |
@@ -78,6 +78,16 @@ size_t strlcpy(char *, const char *, size_t); | |
#define CWM_BIGAMOUNT 0x0010 | |
#define DIRECTIONMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) | |
+#define CWM_TOP_LEFT 0x0001 | |
+#define CWM_BOTTOM_LEFT 0x0002 | |
+#define CWM_TOP_RIGHT 0x0004 | |
+#define CWM_BOTTOM_RIGHT 0x0008 | |
+#define CWM_CENTER 0x0010 | |
+#define CWM_TOP_CENTER 0x0020 | |
+#define CWM_BOTTOM_CENTER 0x0040 | |
+#define CWM_RIGHT_CENTER 0x0080 | |
+#define CWM_LEFT_CENTER 0x0100 | |
+ | |
#define CWM_CYCLE_FORWARD 0x0001 | |
#define CWM_CYCLE_REVERSE 0x0002 | |
#define CWM_CYCLE_INGROUP 0x0004 | |
@@ -497,6 +507,7 @@ 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_vtile(void *, struct cargs *); | |
+void kbfunc_client_move_edge(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 6a66847..cc6244a 100644 | |
--- a/client.c | |
+++ b/client.c | |
@@ -315,6 +315,8 @@ client_toggle_maximize(struct client_ctx *cc) | |
return; | |
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) { | |
+ if (!(cc->flags & CLIENT_IGNORE)) | |
+ cc->bwidth = Conf.bwidth; | |
cc->geom = cc->savegeom; | |
cc->flags &= ~CLIENT_MAXIMIZED; | |
goto resize; | |
@@ -339,6 +341,7 @@ client_toggle_maximize(struct client_ctx *cc) | |
cc->geom.x + cc->geom.w / 2, | |
cc->geom.y + cc->geom.h / 2, CWM_GAP); | |
+ cc->bwidth = 0; | |
cc->geom.x = area.x; | |
cc->geom.y = area.y; | |
cc->geom.w = area.w - (cc->bwidth * 2); | |
diff --git a/conf.c b/conf.c | |
index a321a99..3072c73 100644 | |
--- a/conf.c | |
+++ b/conf.c | |
@@ -184,6 +184,25 @@ static const struct { | |
{ "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, 0 }, | |
{ "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_EXEC_WM }, | |
{ "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, CWM_QUIT }, | |
+ { "movetopleft", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_TOP_LEFT) }, | |
+ { "movebottomleft", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_BOTTOM_LEFT) }, | |
+ { "movetopright", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_TOP_RIGHT) }, | |
+ { "movebottomright", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_BOTTOM_RIGHT) }, | |
+ { "movecenter", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_CENTER) }, | |
+ { "movetopcenter", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_TOP_CENTER) }, | |
+ { "movebottomcenter", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_BOTTOM_CENTER) }, | |
+ { "moverightcenter", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_RIGHT_CENTER) }, | |
+ { "moveleftcenter", kbfunc_client_move_edge, CWM_CONTEXT_CC, | |
+ (CWM_LEFT_CENTER) }, | |
+ | |
}; | |
static unsigned int ignore_mods[] = { | |
@@ -254,6 +273,15 @@ static const struct { | |
{ "CMS-j", "window-resize-down-big" }, | |
{ "CMS-k", "window-resize-up-big" }, | |
{ "CMS-l", "window-resize-right-big" }, | |
+ { "CS-y", "movetopleft" }, | |
+ { "CS-b", "movebottomleft" }, | |
+ { "CS-u", "movetopright" }, | |
+ { "CS-n", "movebottomright" }, | |
+ { "CS-g", "movecenter" }, | |
+ { "CS-k", "movetopcenter" }, | |
+ { "CS-j", "movebottomcenter" }, | |
+ { "CS-l", "moverightcenter" }, | |
+ { "CS-h", "moveleftcenter" }, | |
}, | |
mouse_binds[] = { | |
{ "1", "menu-window" }, | |
diff --git a/cwm.1 b/cwm.1 | |
index 2898a52..16b932a 100644 | |
--- a/cwm.1 | |
+++ b/cwm.1 | |
@@ -127,6 +127,24 @@ Resize window by a small amount. | |
.It Ic CMS-[hjkl] | |
Resize window by a large amount; see | |
.Xr cwmrc 5 . | |
+.It Ic CS-y | |
+Move window to the top left corner of screen. | |
+.It Ic CS-b | |
+Move window to the bottom left corner of screen. | |
+.It Ic CS-u | |
+Move window to the top right corner of screen. | |
+.It Ic CS-n | |
+Move window to the bottom right corner of screen. | |
+.It Ic CS-h | |
+Move window to the left center of screen. | |
+.It Ic CS-j | |
+Move window to the bottom center of screen. | |
+.It Ic CS-k | |
+Move window to the top center of screen. | |
+.It Ic CS-l | |
+Move window to the right center of screen. | |
+.It Ic CS-g | |
+Move window to the center of screen. | |
.It Ic M-question | |
Spawn | |
.Dq exec program | |
diff --git a/cwmrc.5 b/cwmrc.5 | |
index a29fd12..e59b35d 100644 | |
--- a/cwmrc.5 | |
+++ b/cwmrc.5 | |
@@ -430,6 +430,24 @@ pixels right. | |
Move pointer 10 times | |
.Ar moveamount | |
pixels left. | |
+.It movetopleft | |
+Move window to the top left corner of screen. | |
+.It movebottomleft | |
+Move window to the bottom left corner of screen. | |
+.It movetopright | |
+Move window to the top right corner of screen. | |
+.It movebottomright | |
+Move window to the bottom right corner of screen. | |
+.It movetopcenter | |
+Move window to the top center of screen. | |
+.It movebottomcenter | |
+Move window to the bottom center of screen. | |
+.It moverightcenter | |
+Move window to the right center of screen. | |
+.It moveleftcenter | |
+Move window to the left center of screen. | |
+.It movecenter | |
+Move window to the center of screen. | |
.El | |
.Sh FILES | |
.Bl -tag -width "~/.cwmrcXXX" -compact | |
diff --git a/kbfunc.c b/kbfunc.c | |
index 9af37df..c5e8099 100644 | |
--- a/kbfunc.c | |
+++ b/kbfunc.c | |
@@ -571,3 +571,82 @@ kbfunc_exec_lock(void *ctx, struct cargs *cargs) | |
u_spawn(cmd->path); | |
} | |
} | |
+ | |
+void | |
+kbfunc_client_move_edge(void *ctx, struct cargs *cargs) | |
+{ | |
+ struct client_ctx *cc = ctx; | |
+ struct screen_ctx *sc = cc->sc; | |
+ struct geom area; | |
+ int flags; | |
+ | |
+ /* | |
+ * pick screen that the middle of the window is on. | |
+ * that's probably more fair than if just the origin of | |
+ * a window is poking over a boundary | |
+ */ | |
+ area = screen_area(sc, | |
+ cc->geom.x + cc->geom.w / 2, | |
+ cc->geom.y + cc->geom.h / 2, CWM_GAP); | |
+ | |
+ flags = cargs->flag; | |
+ | |
+ switch (flags) { | |
+ case CWM_TOP_LEFT: | |
+ cc->geom.x = area.x; | |
+ cc->geom.y = area.y; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_BOTTOM_LEFT: | |
+ cc->geom.x = area.x; | |
+ cc->geom.y = area.y + area.h - cc->geom.h - cc->bwidth * 2; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_TOP_RIGHT: | |
+ cc->geom.x = area.x + area.w - cc->geom.w - cc->bwidth * 2; | |
+ cc->geom.y = area.y; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_BOTTOM_RIGHT: | |
+ cc->geom.x = area.x + area.w - cc->geom.w - cc->bwidth * 2; | |
+ cc->geom.y = area.y + area.h - cc->geom.h - cc->bwidth * 2; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_CENTER: | |
+ cc->geom.x = area.x + (area.w) / 2 - (cc->geom.w / 2) - cc->bwidth; | |
+ cc->geom.y = area.y + (area.h) / 2 - (cc->geom.h / 2) - cc->bwidth; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_TOP_CENTER: | |
+ cc->geom.x = area.x + (area.w) / 2 - (cc->geom.w / 2) - cc->bwidth; | |
+ cc->geom.y = area.y; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_BOTTOM_CENTER: | |
+ cc->geom.x = area.x + (area.w) / 2 - (cc->geom.w / 2) - cc->bwidth; | |
+ cc->geom.y = area.y + area.h - cc->geom.h - cc->bwidth * 2; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_RIGHT_CENTER: | |
+ cc->geom.x = area.x + area.w - cc->geom.w - cc->bwidth * 2; | |
+ cc->geom.y = area.y + (area.h) / 2 - (cc->geom.h / 2) - cc->bwidth; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ case CWM_LEFT_CENTER: | |
+ cc->geom.x = area.x; | |
+ cc->geom.y = area.y + (area.h) / 2 - (cc->geom.h / 2) - cc->bwidth; | |
+ client_move(cc); | |
+ client_ptrwarp(cc); | |
+ break; | |
+ default: | |
+ warnx("invalid flags passed to kbfunc_client_move_edge"); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Patch for CWM Window Manager