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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
void
resizemouse(const Arg *arg)
{
Client *c;
Monitor *m;
XEvent ev;
#if LOCK_MOVE_RESIZE_REFRESH_RATE
Time lasttime = 0;
#endif
if (!(c = selmon->sel) || c->isfullscreen)
return;
restack(selmon);
int orig_x = c->x;
int orig_y = c->y;
int orig_w = c->w;
int orig_h = c->h;
int rx, ry;
Window junkwin;
int junk_signed;
unsigned int junk;
if (!XQueryPointer(dpy, c->win, &junkwin, &junkwin, &junk_signed, &junk_signed, &rx, &ry, &junk))
return;
int left = rx < orig_w / 3;
int right = rx > orig_w * 2 / 3;
int top = ry < orig_h / 3;
int bottom = ry > orig_h * 2 / 3;
#if BR_CHANGE_CURSOR
Cursor cur;
if (top && left) cur = cursor[CurNW]->cursor;
else if (top && right) cur = cursor[CurNE]->cursor;
else if (bottom && left) cur = cursor[CurSW]->cursor;
else if (bottom && right) cur = cursor[CurSE]->cursor;
else if (top) cur = cursor[CurN]->cursor;
else if (bottom) cur = cursor[CurS]->cursor;
else if (left) cur = cursor[CurW]->cursor;
else if (right) cur = cursor[CurE]->cursor;
else cur = cursor[CurResize]->cursor; // fallback
#else
Cursor cur = cursor[CurResize]->cursor;
#endif
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cur, CurrentTime) != GrabSuccess)
return;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
if (ev.type == MotionNotify) {
#if LOCK_MOVE_RESIZE_REFRESH_RATE
if (ev.xmotion.time - lasttime <= (1000 / refreshrate))
continue;
lasttime = ev.xmotion.time;
#endif
int dx = ev.xmotion.x_root - (orig_x + rx);
int dy = ev.xmotion.y_root - (orig_y + ry);
int nx = orig_x;
int ny = orig_y;
int nw = orig_w;
int nh = orig_h;
if (left) nw = orig_w - dx;
else if (right) nw = orig_w + dx;
if (top) nh = orig_h - dy;
else if (bottom) nh = orig_h + dy;
int min_w = MAX(1, c->minw);
int min_h = MAX(1, c->minh);
if (nw < min_w) nw = min_w;
if (nh < min_h) nh = min_h;
if (left) nx = orig_x + (orig_w - nw);
if (top) ny = orig_y + (orig_h - nh);
int dx_final = nw - orig_w;
int dy_final = nh - orig_h;
#if !RESIZINIG_WINDOWS_IN_ALL_LAYOUTS_FLOATS_THEM
if (!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
(abs(dx_final) > snap || abs(dy_final) > snap)) {
#else
if (!c->isfloating && (abs(dx_final) > snap || abs(dy_final) > snap)) {
#endif
if (nx >= selmon->wx && nx + nw <= selmon->wx + selmon->ww &&
ny >= selmon->wy && ny + nh <= selmon->wy + selmon->wh) {
togglefloating(NULL);
orig_x = c->x;
orig_y = c->y;
orig_w = c->w;
orig_h = c->h;
}
}
#if USE_RESIZECLIENT_FUNC
resizeclient(c, nx, ny, nw, nh);
#else
resize(c, nx, ny, nw, nh, 1);
#endif
drawbar(selmon); //fix for issue 1
}
} while (ev.type != ButtonRelease);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
sendmon(c, m);
selmon = m;
focus(NULL);
}
#if ENHANCED_TOGGLE_FLOATING && RESTORE_SIZE_AND_POS_ETF
c->wasmanuallyedited = 1;
if (c->isfloating) {
c->sfx = c->x;
c->sfy = c->y;
c->sfw = c->w;
c->sfh = c->h;
}
#endif
}
|