view to left/right wrap around

This commit is contained in:
lilly-lizard 2026-04-14 08:20:14 +12:00
parent 0162b0011a
commit 1a86dc804b
No known key found for this signature in database
GPG key ID: B5857277126B5D1C

View file

@ -1099,14 +1099,6 @@ int32_t tag(const Arg *arg) {
return 0; return 0;
} }
int32_t tagmon(const Arg *arg) {
tagmon_general(arg, false);
}
int32_t tagmonsilent(const Arg *arg) {
tagmon_general(arg, true);
}
int32_t tagmon_general(const Arg *arg, bool silent) { int32_t tagmon_general(const Arg *arg, bool silent) {
Monitor *m = NULL, *cm = NULL; Monitor *m = NULL, *cm = NULL;
if (!selmon) if (!selmon)
@ -1154,6 +1146,10 @@ int32_t tagmon_general(const Arg *arg, bool silent) {
reset_foreign_tolevel(c); reset_foreign_tolevel(c);
if (silent) {
focusclient(focustop(selmon), 1);
}
c->float_geom.width = c->float_geom.width =
(int32_t)(c->float_geom.width * c->mon->w.width / selmon->w.width); (int32_t)(c->float_geom.width * c->mon->w.width / selmon->w.width);
c->float_geom.height = c->float_geom.height =
@ -1172,7 +1168,6 @@ int32_t tagmon_general(const Arg *arg, bool silent) {
} }
resize(c, c->geom, 1); resize(c, c->geom, 1);
} else { } else {
selmon = c->mon;
if (!silent) { if (!silent) {
target = get_tags_first_tag(c->tags); target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true); view(&(Arg){.ui = target}, true);
@ -1183,9 +1178,18 @@ int32_t tagmon_general(const Arg *arg, bool silent) {
if (config.warpcursor && !silent) { if (config.warpcursor && !silent) {
warp_cursor_to_selmon(c->mon); warp_cursor_to_selmon(c->mon);
} }
return 0; return 0;
} }
int32_t tagmon(const Arg *arg) {
return tagmon_general(arg, false);
}
int32_t tagmonsilent(const Arg *arg) {
return tagmon_general(arg, true);
}
int32_t tagsilent(const Arg *arg) { int32_t tagsilent(const Arg *arg) {
Client *fc = NULL; Client *fc = NULL;
Client *target_client = NULL; Client *target_client = NULL;
@ -1489,12 +1493,15 @@ int32_t viewtoleft(const Arg *arg) {
if (!selmon) if (!selmon)
return 0; return 0;
uint32_t target = selmon->tagset[selmon->seltags];
if (selmon->isoverview || selmon->pertag->curtag == 0) { if (selmon->isoverview || selmon->pertag->curtag == 0) {
return 0; return 0;
} }
uint32_t target = selmon->tagset[selmon->seltags];
if (target & 1) {
// 1 wraps around to 9
target |= 1 << LENGTH(tags);
}
target >>= 1; target >>= 1;
if (target == 0) { if (target == 0) {
@ -1516,12 +1523,17 @@ int32_t viewtoright(const Arg *arg) {
return 0; return 0;
} }
uint32_t target = selmon->tagset[selmon->seltags]; uint32_t target = selmon->tagset[selmon->seltags];
target <<= 1; target <<= 1;
if (target & 1 << LENGTH(tags)) {
// 9 wraps around to 1
target |= 1;
}
if (!selmon || (target) == selmon->tagset[selmon->seltags]) if (!selmon || (target) == selmon->tagset[selmon->seltags])
return 0; return 0;
if (!(target & TAGMASK)) { if (!(target & TAGMASK)) {
return 0; target = 1;
} }
view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true); view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true);