warp: dragmfact + dragcfact compatibility

These set of changes introduce:
   a) a flag to ignore warp from happening while dragmfact or
      dragcfact is being used and
   b) a flag to force warp when killclient or showhideclient
      is used, to make for a more intuitive experience

ref. https://github.com/bakkeby/patches/issues/11
pull/74/head
bakkeby 4 years ago
parent c47f61387d
commit 56c81ddbfa

12
dwm.c

@ -671,6 +671,10 @@ static int lrpad; /* sum of left and right padding for text */
* when moving (or resizing) client windows from one monitor to another. This variable is used * when moving (or resizing) client windows from one monitor to another. This variable is used
* internally to ignore such configure requests while movemouse or resizemouse are being used. */ * internally to ignore such configure requests while movemouse or resizemouse are being used. */
static int ignoreconfigurerequests = 0; static int ignoreconfigurerequests = 0;
#if WARP_PATCH
static int force_warp = 0; // force warp in some situations, e.g. killclient
static int ignore_warp = 0; // force skip warp in some situations, e.g. dragmfact, dragcfact
#endif // WARP_PATCH
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0; static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = { static void (*handler[LASTEvent]) (XEvent *) = {
@ -2112,10 +2116,11 @@ killclient(const Arg *arg)
#endif // ISPERMANENT_PATCH #endif // ISPERMANENT_PATCH
return; return;
#if BAR_SYSTRAY_PATCH #if BAR_SYSTRAY_PATCH
if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) { if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0))
#else #else
if (!sendevent(selmon->sel, wmatom[WMDelete])) { if (!sendevent(selmon->sel, wmatom[WMDelete]))
#endif // BAR_SYSTRAY_PATCH #endif // BAR_SYSTRAY_PATCH
{
XGrabServer(dpy); XGrabServer(dpy);
XSetErrorHandler(xerrordummy); XSetErrorHandler(xerrordummy);
XSetCloseDownMode(dpy, DestroyAll); XSetCloseDownMode(dpy, DestroyAll);
@ -2123,6 +2128,9 @@ killclient(const Arg *arg)
XSync(dpy, False); XSync(dpy, False);
XSetErrorHandler(xerror); XSetErrorHandler(xerror);
XUngrabServer(dpy); XUngrabServer(dpy);
#if WARP_PATCH
force_warp = 1;
#endif // WARP_PATCH
} }
#if SWAPFOCUS_PATCH && PERTAG_PATCH #if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = NULL; selmon->pertag->prevclient[selmon->pertag->curtag] = NULL;

@ -80,6 +80,9 @@ showhideclient(const Arg *arg)
if (!c) if (!c)
return; return;
#if WARP_PATCH
force_warp = 1;
#endif // WARP_PATCH
if (HIDDEN(c)) { if (HIDDEN(c)) {
show(c); show(c);
focus(c); focus(c);

@ -27,6 +27,11 @@ dragcfact(const Arg *arg)
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess) None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess)
return; return;
#if WARP_PATCH
ignore_warp = 1;
#endif // WARP_PATCH
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);
prev_x = prev_y = -999999; prev_x = prev_y = -999999;
@ -66,6 +71,9 @@ dragcfact(const Arg *arg)
} }
} while (ev.type != ButtonRelease); } while (ev.type != ButtonRelease);
#if WARP_PATCH
ignore_warp = 0;
#endif // WARP_PATCH
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);

@ -152,6 +152,11 @@ dragmfact(const Arg *arg)
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[horizontal ? CurResizeVertArrow : CurResizeHorzArrow]->cursor, CurrentTime) != GrabSuccess) None, cursor[horizontal ? CurResizeVertArrow : CurResizeHorzArrow]->cursor, CurrentTime) != GrabSuccess)
return; return;
#if WARP_PATCH
ignore_warp = 1;
#endif // WARP_PATCH
XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py); XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py);
do { do {
@ -217,6 +222,10 @@ dragmfact(const Arg *arg)
} }
} while (ev.type != ButtonRelease); } while (ev.type != ButtonRelease);
#if WARP_PATCH
ignore_warp = 0;
#endif // WARP_PATCH
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }

@ -5,26 +5,32 @@ warp(const Client *c)
Bar *bar; Bar *bar;
int x, y; int x, y;
if (ignore_warp)
return;
if (!c) { if (!c) {
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2); XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
return; return;
} }
if (!getrootptr(&x, &y) || if (!force_warp) {
(x > c->x - c->bw && if (!getrootptr(&x, &y) ||
y > c->y - c->bw && (x > c->x - c->bw &&
x < c->x + c->w + c->bw*2 && y > c->y - c->bw &&
y < c->y + c->h + c->bw*2) x < c->x + c->w + c->bw*2 &&
) y < c->y + c->h + c->bw*2)
return; )
return;
for (m = mons; m; m = m->next) for (m = mons; m; m = m->next)
for (bar = m->bar; bar; bar = bar->next) for (bar = m->bar; bar; bar = bar->next)
if (x > bar->bx && if (x > bar->bx &&
x < bar->bx + bar->bw && x < bar->bx + bar->bw &&
y > bar->by && y > bar->by &&
y < bar->by + bar->bh) y < bar->by + bar->bh)
return; return;
} else
force_warp = 0;
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);
} }

Loading…
Cancel
Save