summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorProsperousPotato <ProsperousPotato@users.noreply.github.com>2024-08-27 15:35:25 +0000
committerProsperousPotato <ProsperousPotato@users.noreply.github.com>2025-03-31 18:31:28 +0100
commit16bd06387bb05008d7176bec542ac52315cf367b (patch)
tree5ed031dd798b7bd20a1ea206568ecb8baacbd977
parentf1d700307223a557337d2f50cdf5cc6b5cc92778 (diff)
resize floating windows from nearest corner
-rw-r--r--README3
-rw-r--r--config.h9
-rw-r--r--dwmbin76472 -> 76480 bytes
-rw-r--r--dwm.c33
-rw-r--r--dwm.obin66432 -> 66952 bytes
5 files changed, 34 insertions, 11 deletions
diff --git a/README b/README
index 6d3df51..882a35d 100644
--- a/README
+++ b/README
@@ -5,7 +5,8 @@ dwm is an extremely fast, small, and dynamic window manager for X.
Requirements
------------
-In order to build dwm you need the Xlib header files, libXft and libXinerama, and obviously, xorg-server
+In order to build dwm you need the Xlib header files, libXft and libXinerama
+And obviously, you'll need xorg-server, xorg-xinit, and xorg-xauthority
Installation
diff --git a/config.h b/config.h
index dd8c229..a713e8c 100644
--- a/config.h
+++ b/config.h
@@ -72,7 +72,6 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { TERMINAL, NULL };
-static const char *cmdprintscreen[] = { "scrot", "~/Pictures/%Y-%m.jpg", NULL };
static const char *volumeup[] = { "amixer", "sset", "Master", "5%+", NULL };
static const char *volumedown[] = { "amixer", "sset", "Master", "5%-", NULL };
static const char *volumetoggle[] = { "amixer", "sset", "Master", "toggle", NULL };
@@ -126,17 +125,17 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_m, spawn, {.v = (const char*[]){ TERMINAL, "-e", "neomutt", NULL } }},
- { ControlMask|ShiftMask, XK_Escape, spawn, {.v = (const char*[]){ TERMINAL, "-e", "htop", NULL } }},
+ { MODKEY|ShiftMask, XK_h, spawn, {.v = (const char*[]){ TERMINAL, "-e", "htop", NULL } }},
{ MODKEY|ShiftMask, XK_e, spawn, {.v = (const char*[]){ TERMINAL, "-e", "lfub", NULL } }},
- { MODKEY, XK_Print, spawn, {.v = cmdprintscreen } },
- { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volumeup } },
- { 0, XF86XK_AudioLowerVolume, spawn, {.v = volumedown } },
+ { MODKEY, XK_Print, spawn, SHCMD("scrot -q 100 ~/Pictures/%Y-%m.jpg") },
{ MODKEY, XK_Up, spawn, {.v = volumeup } },
{ MODKEY, XK_Down, spawn, {.v = volumedown } },
{ MODKEY, XK_Right, spawn, {.v = fasterbrightnessup } },
{ MODKEY, XK_Left, spawn, {.v = fasterbrightnessdown } },
{ MODKEY|ControlMask, XK_Right, spawn, {.v = brightnessup } },
{ MODKEY|ControlMask, XK_Left, spawn, {.v = brightnessdown } },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volumeup } },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = volumedown } },
{ 0, XF86XK_AudioMute, spawn, {.v = volumetoggle } },
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = fasterbrightnessup } },
{ 0, XF86XK_MonBrightnessDown, spawn, {.v = fasterbrightnessdown } },
diff --git a/dwm b/dwm
index 959f10f..6971ff1 100644
--- a/dwm
+++ b/dwm
Binary files differ
diff --git a/dwm.c b/dwm.c
index 4c65301..f559af3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1415,9 +1415,14 @@ void
resizemouse(const Arg *arg)
{
int ocx, ocy, nw, nh;
+ int ocx2, ocy2, nx, ny;
Client *c;
Monitor *m;
XEvent ev;
+ int horizcorner, vertcorner;
+ int di;
+ unsigned int dui;
+ Window dummy;
Time lasttime = 0;
if (!(c = selmon->sel))
@@ -1427,10 +1432,18 @@ resizemouse(const Arg *arg)
restack(selmon);
ocx = c->x;
ocy = c->y;
+ ocx2 = c->x + c->w;
+ ocy2 = c->y + c->h;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return;
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+ if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
+ return;
+ horizcorner = nx < c->w / 2;
+ vertcorner = ny < c->h / 2;
+ XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
+ horizcorner ? (-c->bw) : (c->w + c->bw -1),
+ vertcorner ? (-c->bw) : (c->h + c->bw -1));
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@@ -1444,8 +1457,16 @@ resizemouse(const Arg *arg)
continue;
lasttime = ev.xmotion.time;
- nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
- nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
+ nx = horizcorner && ocx2 - ev.xmotion.x >= c->minw ? ev.xmotion.x : c->x;
+ ny = vertcorner && ocy2 - ev.xmotion.y >= c->minh ? ev.xmotion.y : c->y;
+ nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
+ nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
+
+ if (horizcorner && ev.xmotion.x > ocx2)
+ nx = ocx2 - (nw = c->minw);
+ if (vertcorner && ev.xmotion.y > ocy2)
+ ny = ocy2 - (nh = c->minh);
+
if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
{
@@ -1454,11 +1475,13 @@ resizemouse(const Arg *arg)
togglefloating(NULL);
}
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh, 1);
+ resize(c, nx, ny, nw, nh, 1);
break;
}
} while (ev.type != ButtonRelease);
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
+ horizcorner ? (-c->bw) : (c->w + c->bw - 1),
+ vertcorner ? (-c->bw) : (c->h + c->bw - 1));
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
diff --git a/dwm.o b/dwm.o
index 12c7d8f..528069e 100644
--- a/dwm.o
+++ b/dwm.o
Binary files differ