Add resizepoint patch to ease resizing
This commit is contained in:
parent
abbfde67e9
commit
526be6ce7e
2
dwm/.gitignore
vendored
2
dwm/.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
*.o
|
*.o
|
||||||
dwm
|
dwm
|
||||||
config.h
|
config.h
|
||||||
|
*.orig
|
||||||
|
*.rej
|
||||||
|
|
32
dwm/dwm.c
32
dwm/dwm.c
|
@ -72,7 +72,7 @@
|
||||||
#define MWM_DECOR_TITLE (1 << 3)
|
#define MWM_DECOR_TITLE (1 << 3)
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurResizeBR, CurResizeBL, CurResizeTR, CurResizeTL, CurNormal, CurMove, CurLast }; /* cursor */
|
||||||
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||||
enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck,
|
enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck,
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
|
@ -1596,10 +1596,13 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
void
|
void
|
||||||
resizemouse(const Arg *arg)
|
resizemouse(const Arg *arg)
|
||||||
{
|
{
|
||||||
int ocx, ocy, nw, nh;
|
int opx, opy, ocx, ocy, och, ocw, nx, ny, nw, nh;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
int horizcorner, vertcorner;
|
||||||
|
unsigned int dui;
|
||||||
|
Window dummy;
|
||||||
Time lasttime = 0;
|
Time lasttime = 0;
|
||||||
|
|
||||||
if (!(c = selmon->sel))
|
if (!(c = selmon->sel))
|
||||||
|
@ -1609,10 +1612,15 @@ resizemouse(const Arg *arg)
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
ocy = c->y;
|
ocy = c->y;
|
||||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
och = c->h;
|
||||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
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[horizcorner | (vertcorner << 1)]->cursor, CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
|
||||||
do {
|
do {
|
||||||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
|
@ -1626,8 +1634,10 @@ resizemouse(const Arg *arg)
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
|
nx = horizcorner ? (ocx + ev.xmotion.x - opx) : c->x;
|
||||||
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
|
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
|
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)
|
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
|
||||||
{
|
{
|
||||||
|
@ -1636,11 +1646,10 @@ resizemouse(const Arg *arg)
|
||||||
togglefloating(NULL);
|
togglefloating(NULL);
|
||||||
}
|
}
|
||||||
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
|
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
|
||||||
resize(c, c->x, c->y, nw, nh, 1);
|
resizeclient(c, nx, ny, nw, nh);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (ev.type != ButtonRelease);
|
} 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);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
||||||
|
@ -1928,7 +1937,10 @@ setup(void)
|
||||||
motifatom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
|
motifatom = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
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);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||||
|
|
Loading…
Reference in a new issue