mirror of
https://github.com/bakkeby/dwm-flexipatch
synced 2024-11-10 19:10:48 +00:00
Adding cursor icons for resizecorners, resizepoint, dragmfact and dragcfact
This commit is contained in:
parent
5a4c350b9c
commit
c14a51524b
65
dwm.c
65
dwm.c
@ -96,7 +96,25 @@
|
|||||||
#endif // PANGO_PATCH
|
#endif // PANGO_PATCH
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum {
|
||||||
|
#if RESIZEPOINT_PATCH || RESIZECORNERS_PATCH
|
||||||
|
CurResizeBR,
|
||||||
|
CurResizeBL,
|
||||||
|
CurResizeTR,
|
||||||
|
CurResizeTL,
|
||||||
|
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
||||||
|
#if DRAGMFACT_PATCH
|
||||||
|
CurResizeHorzArrow,
|
||||||
|
CurResizeVertArrow,
|
||||||
|
#endif // DRAGMFACT_PATCH
|
||||||
|
#if DRAGCFACT_PATCH
|
||||||
|
CurIronCross,
|
||||||
|
#endif // DRAGCFACT_PATCH
|
||||||
|
CurNormal,
|
||||||
|
CurResize,
|
||||||
|
CurMove,
|
||||||
|
CurLast
|
||||||
|
}; /* cursor */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SchemeNorm
|
SchemeNorm
|
||||||
@ -2685,17 +2703,11 @@ void
|
|||||||
resizemouse(const Arg *arg)
|
resizemouse(const Arg *arg)
|
||||||
{
|
{
|
||||||
int ocx, ocy, nw, nh;
|
int ocx, ocy, nw, nh;
|
||||||
#if RESIZEPOINT_PATCH
|
#if RESIZEPOINT_PATCH || RESIZECORNERS_PATCH
|
||||||
int opx, opy, och, ocw, nx, ny;
|
int opx, opy, och, ocw, nx, ny;
|
||||||
int horizcorner, vertcorner;
|
int horizcorner, vertcorner;
|
||||||
unsigned int dui;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
#elif RESIZECORNERS_PATCH
|
|
||||||
int ocx2, ocy2, nx, ny;
|
|
||||||
int horizcorner, vertcorner;
|
|
||||||
int di;
|
|
||||||
unsigned int dui;
|
|
||||||
Window dummy;
|
|
||||||
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
@ -2720,26 +2732,26 @@ resizemouse(const Arg *arg)
|
|||||||
och = c->h;
|
och = c->h;
|
||||||
ocw = c->w;
|
ocw = c->w;
|
||||||
#elif RESIZECORNERS_PATCH
|
#elif RESIZECORNERS_PATCH
|
||||||
ocx2 = c->x + c->w;
|
och = c->y + c->h;
|
||||||
ocy2 = c->y + c->h;
|
ocw = c->x + c->w;
|
||||||
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
||||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
#if RESIZEPOINT_PATCH || RESIZECORNERS_PATCH
|
||||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
#if RESIZEPOINT_PATCH
|
|
||||||
if (!XQueryPointer(dpy, c->win, &dummy, &dummy, &opx, &opy, &nx, &ny, &dui))
|
if (!XQueryPointer(dpy, c->win, &dummy, &dummy, &opx, &opy, &nx, &ny, &dui))
|
||||||
return;
|
return;
|
||||||
horizcorner = nx < c->w / 2;
|
horizcorner = nx < c->w / 2;
|
||||||
vertcorner = ny < c->h / 2;
|
vertcorner = ny < c->h / 2;
|
||||||
#elif RESIZECORNERS_PATCH
|
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
|
None, cursor[horizcorner | (vertcorner << 1)]->cursor, CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
horizcorner = nx < c->w / 2;
|
#if RESIZECORNERS_PATCH
|
||||||
vertcorner = ny < c->h / 2;
|
|
||||||
XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
|
XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
|
||||||
horizcorner ? (-c->bw) : (c->w + c->bw - 1),
|
horizcorner ? (-c->bw) : (c->w + c->bw - 1),
|
||||||
vertcorner ? (-c->bw) : (c->h + c->bw - 1));
|
vertcorner ? (-c->bw) : (c->h + c->bw - 1));
|
||||||
|
#endif // RESIZECORNERS_PATCH
|
||||||
#else
|
#else
|
||||||
|
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);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||||
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
||||||
do {
|
do {
|
||||||
@ -2763,8 +2775,8 @@ resizemouse(const Arg *arg)
|
|||||||
#elif RESIZECORNERS_PATCH
|
#elif RESIZECORNERS_PATCH
|
||||||
nx = horizcorner ? ev.xmotion.x : c->x;
|
nx = horizcorner ? ev.xmotion.x : c->x;
|
||||||
ny = vertcorner ? ev.xmotion.y : c->y;
|
ny = vertcorner ? ev.xmotion.y : c->y;
|
||||||
nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
|
nw = MAX(horizcorner ? (ocw - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
|
||||||
nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
|
nh = MAX(vertcorner ? (och - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
|
||||||
#else
|
#else
|
||||||
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
|
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
|
||||||
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
|
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
|
||||||
@ -3232,6 +3244,19 @@ setup(void)
|
|||||||
/* 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[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
|
#if RESIZEPOINT_PATCH || RESIZECORNERS_PATCH
|
||||||
|
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);
|
||||||
|
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
|
||||||
|
#if DRAGMFACT_PATCH
|
||||||
|
cursor[CurResizeHorzArrow] = drw_cur_create(drw, XC_sb_h_double_arrow);
|
||||||
|
cursor[CurResizeVertArrow] = drw_cur_create(drw, XC_sb_v_double_arrow);
|
||||||
|
#endif // DRAGMFACT_PATCH
|
||||||
|
#if DRAGCFACT_PATCH
|
||||||
|
cursor[CurIronCross] = drw_cur_create(drw, XC_iron_cross);
|
||||||
|
#endif // DRAGCFACT_PATCH
|
||||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
#if VTCOLORS_PATCH
|
#if VTCOLORS_PATCH
|
||||||
|
@ -25,7 +25,7 @@ dragcfact(const Arg *arg)
|
|||||||
restack(selmon);
|
restack(selmon);
|
||||||
|
|
||||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ dragmfact(const Arg *arg)
|
|||||||
|
|
||||||
if (layout == SPLIT_HORIZONTAL || layout == SPLIT_HORIZONTAL_DUAL_STACK)
|
if (layout == SPLIT_HORIZONTAL || layout == SPLIT_HORIZONTAL_DUAL_STACK)
|
||||||
horizontal = 1;
|
horizontal = 1;
|
||||||
else if (layout == SPLIT_CENTERED_VERTICAL)
|
else if (layout == SPLIT_CENTERED_VERTICAL && (n - m->nmaster) > 1)
|
||||||
center = 1;
|
center = 1;
|
||||||
else if (layout == FLOATING_MASTER) {
|
else if (layout == FLOATING_MASTER) {
|
||||||
center = 1;
|
center = 1;
|
||||||
@ -75,7 +75,7 @@ dragmfact(const Arg *arg)
|
|||||||
}
|
}
|
||||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||||
#if CENTEREDMASTER_LAYOUT
|
#if CENTEREDMASTER_LAYOUT
|
||||||
else if (m->lt[m->sellt]->arrange == ¢eredmaster)
|
else if (m->lt[m->sellt]->arrange == ¢eredmaster && (n - m->nmaster) > 1)
|
||||||
center = 1;
|
center = 1;
|
||||||
#endif // CENTEREDMASTER_LAYOUT
|
#endif // CENTEREDMASTER_LAYOUT
|
||||||
#if CENTEREDFLOATINGMASTER_LAYOUT
|
#if CENTEREDFLOATINGMASTER_LAYOUT
|
||||||
@ -91,10 +91,6 @@ dragmfact(const Arg *arg)
|
|||||||
horizontal = 1;
|
horizontal = 1;
|
||||||
#endif // BSTACKHORIZ_LAYOUT
|
#endif // BSTACKHORIZ_LAYOUT
|
||||||
|
|
||||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
|
||||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if VANITYGAPS_PATCH
|
#if VANITYGAPS_PATCH
|
||||||
ay += oh;
|
ay += oh;
|
||||||
ax += ov;
|
ax += ov;
|
||||||
@ -148,6 +144,9 @@ dragmfact(const Arg *arg)
|
|||||||
py = ay + ah / 2;
|
py = ay + ah / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
|
None, cursor[horizontal ? CurResizeVertArrow : CurResizeHorzArrow]->cursor, CurrentTime) != GrabSuccess)
|
||||||
|
return;
|
||||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py);
|
XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
Loading…
Reference in New Issue
Block a user