From d8f3547b8f545b439d9df7b41cfe872ce6c8f42d Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 27 Feb 2020 14:56:39 +0000 Subject: Unrelated style fixes, consistency changes and sorting, appropriate dosage/removal of wrappers, simplification of name queue, client cycle joins other kb/mb bound functions. --- kbfunc.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'kbfunc.c') diff --git a/kbfunc.c b/kbfunc.c index 4840487..a356197 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: kbfunc.c,v 1.167 2020/01/21 15:50:03 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.168 2020/02/27 14:56:39 okan Exp $ */ #include @@ -59,7 +59,7 @@ kbfunc_amount(int flags, int amt, int *mx, int *my) if (flags & CWM_BIGAMOUNT) amt *= CWM_FACTOR; - switch (flags & DIRECTIONMASK) { + switch (flags & (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)) { case CWM_UP: *my -= amt; break; @@ -84,8 +84,8 @@ kbfunc_ptrmove(void *ctx, struct cargs *cargs) kbfunc_amount(cargs->flag, Conf.mamount, &mx, &my); - xu_ptr_getpos(sc->rootwin, &x, &y); - xu_ptr_setpos(sc->rootwin, x + mx, y + my); + xu_ptr_get(sc->rootwin, &x, &y); + xu_ptr_set(sc->rootwin, x + mx, y + my); } void @@ -132,7 +132,7 @@ kbfunc_client_move_kb(void *ctx, struct cargs *cargs) area = screen_area(sc, cc->geom.x + cc->geom.w / 2, - cc->geom.y + cc->geom.h / 2, CWM_GAP); + cc->geom.y + cc->geom.h / 2, 1); cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), area.x, area.x + area.w, sc->snapdist); @@ -183,7 +183,7 @@ kbfunc_client_move_mb(void *ctx, struct cargs *cargs) area = screen_area(sc, cc->geom.x + cc->geom.w / 2, - cc->geom.y + cc->geom.h / 2, CWM_GAP); + cc->geom.y + cc->geom.h / 2, 1); cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), area.x, area.x + area.w, sc->snapdist); @@ -247,9 +247,9 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs) return; client_raise(cc); - client_ptrsave(cc); + client_ptr_save(cc); - xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h); + xu_ptr_set(cc->win, cc->geom.w, cc->geom.h); if (XGrabPointer(X_Dpy, cc->win, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, Conf.cursor[CF_RESIZE], @@ -269,7 +269,7 @@ kbfunc_client_resize_mb(void *ctx, struct cargs *cargs) cc->geom.w = ev.xmotion.x; cc->geom.h = ev.xmotion.y; - client_applysizehints(cc); + client_apply_sizehints(cc); client_resize(cc, 1); screen_prop_win_draw(sc, "%4d x %-4d", cc->dim.w, cc->dim.h); @@ -298,7 +298,7 @@ kbfunc_client_snap(void *ctx, struct cargs *cargs) area = screen_area(sc, cc->geom.x + cc->geom.w / 2, - cc->geom.y + cc->geom.h / 2, CWM_GAP); + cc->geom.y + cc->geom.h / 2, 1); flags = cargs->flag; while (flags) { @@ -334,7 +334,7 @@ kbfunc_client_close(void *ctx, struct cargs *cargs) void kbfunc_client_lower(void *ctx, struct cargs *cargs) { - client_ptrsave(ctx); + client_ptr_save(ctx); client_lower(ctx); } @@ -402,13 +402,55 @@ void kbfunc_client_cycle(void *ctx, struct cargs *cargs) { struct screen_ctx *sc = ctx; + struct client_ctx *newcc, *oldcc, *prevcc; + int again = 1, flags = cargs->flag; /* For X apps that ignore/steal events. */ if (cargs->xev == CWM_XEV_KEY) XGrabKeyboard(X_Dpy, sc->rootwin, True, GrabModeAsync, GrabModeAsync, CurrentTime); - client_cycle(sc, cargs->flag); + if (TAILQ_EMPTY(&sc->clientq)) + return; + + prevcc = TAILQ_FIRST(&sc->clientq); + oldcc = client_current(sc); + if (oldcc == NULL) + oldcc = (flags & CWM_CYCLE_REVERSE) ? + TAILQ_LAST(&sc->clientq, client_q) : + TAILQ_FIRST(&sc->clientq); + + newcc = oldcc; + while (again) { + again = 0; + + newcc = (flags & CWM_CYCLE_REVERSE) ? client_prev(newcc) : + client_next(newcc); + + /* Only cycle visible and non-ignored windows. */ + if ((newcc->flags & (CLIENT_SKIP_CYCLE)) || + ((flags & CWM_CYCLE_INGROUP) && + (newcc->gc != oldcc->gc))) + again = 1; + + /* Is oldcc the only non-hidden window? */ + if (newcc == oldcc) { + if (again) + return; /* No windows visible. */ + break; + } + } + + /* Reset when cycling mod is released. XXX I hate this hack */ + sc->cycling = 1; + client_ptr_save(oldcc); + client_raise(prevcc); + client_raise(newcc); + if (!client_inbound(newcc, newcc->ptr.x, newcc->ptr.y)) { + newcc->ptr.x = newcc->geom.w / 2; + newcc->ptr.y = newcc->geom.h / 2; + } + client_ptr_warp(newcc); } void @@ -489,8 +531,8 @@ kbfunc_menu_client(void *ctx, struct cargs *cargs) cc = (struct client_ctx *)mi->ctx; client_show(cc); if (old_cc) - client_ptrsave(old_cc); - client_ptrwarp(cc); + client_ptr_save(old_cc); + client_ptr_warp(cc); } menuq_clear(&menuq); -- cgit v1.2.3-2-gb3c3