-
Notifications
You must be signed in to change notification settings - Fork 30
/
dwm-resizepoint-6.5.diff
97 lines (91 loc) · 3.62 KB
/
dwm-resizepoint-6.5.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From a75564fcee5aac39b17d630427e20dd47ce38d33 Mon Sep 17 00:00:00 2001
From: Bakkeby <bakkeby@gmail.com>
Date: Thu, 27 Jun 2024 21:34:40 +0200
Subject: [PATCH] resizepoint - Like resizecorners, but does not warp mouse
pointer
---
dwm.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/dwm.c b/dwm.c
index f1d86b2..9ccebed 100644
--- a/dwm.c
+++ b/dwm.c
@@ -58,7 +58,7 @@
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */
-enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
+enum { CurResizeBR, CurResizeBL, CurResizeTR, CurResizeTL, CurNormal, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
@@ -1300,10 +1300,13 @@ resizeclient(Client *c, int x, int y, int w, int h)
void
resizemouse(const Arg *arg)
{
- int ocx, ocy, nw, nh;
+ int opx, opy, ocx, ocy, och, ocw, nx, ny, nw, nh;
Client *c;
Monitor *m;
XEvent ev;
+ int horizcorner, vertcorner;
+ unsigned int dui;
+ Window dummy;
Time lasttime = 0;
if (!(c = selmon->sel))
@@ -1313,10 +1316,15 @@ resizemouse(const Arg *arg)
restack(selmon);
ocx = c->x;
ocy = c->y;
+ och = c->h;
+ ocw = c->w;
+ if (!XQueryPointer(dpy, c->win, &dummy, &dummy, &opx, &opy, &nx, &ny, &dui))
+ return;
+ horizcorner = nx < c->w / 2;
+ vertcorner = ny < c->h / 2;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
- None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
+ None, cursor[horizcorner | (vertcorner << 1)]->cursor, CurrentTime) != GrabSuccess)
return;
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@@ -1330,8 +1338,10 @@ 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 ? (ocx + ev.xmotion.x - opx) : c->x;
+ ny = vertcorner ? (ocy + ev.xmotion.y - opy) : c->y;
+ nw = MAX(horizcorner ? (ocx + ocw - nx) : (ocw + (ev.xmotion.x - opx)), 1);
+ nh = MAX(vertcorner ? (ocy + och - ny) : (och + (ev.xmotion.y - opy)), 1);
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)
{
@@ -1340,11 +1350,10 @@ resizemouse(const Arg *arg)
togglefloating(NULL);
}
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh, 1);
+ resizeclient(c, nx, ny, nw, nh);
break;
}
} while (ev.type != ButtonRelease);
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, 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) {
@@ -1581,7 +1590,10 @@ setup(void)
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
- cursor[CurResize] = drw_cur_create(drw, XC_sizing);
+ cursor[CurResizeBR] = drw_cur_create(drw, XC_bottom_right_corner);
+ cursor[CurResizeBL] = drw_cur_create(drw, XC_bottom_left_corner);
+ cursor[CurResizeTR] = drw_cur_create(drw, XC_top_right_corner);
+ cursor[CurResizeTL] = drw_cur_create(drw, XC_top_left_corner);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
--
2.45.2