Add viewtoleft and viewtoright

This commit is contained in:
Alex Selimov 2025-06-27 22:24:45 -04:00
parent 7e42ab3f4f
commit e9f05098d8
3 changed files with 55 additions and 31 deletions

22
dwm.c
View file

@ -291,6 +291,8 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static void viewtoleft(const Arg *arg);
static void viewtoright(const Arg *arg);
static void warp(const Client *c);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
@ -2333,6 +2335,26 @@ void view(const Arg *arg) {
arrange(selmon);
}
void viewtoleft(const Arg *arg) {
if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] > 1) {
selmon->seltags ^= 1; /* toggle sel tagset */
selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
focus(NULL);
arrange(selmon);
}
}
void viewtoright(const Arg *arg) {
if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
selmon->seltags ^= 1; /* toggle sel tagset */
selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
focus(NULL);
arrange(selmon);
}
}
void warp(const Client *c) {
int x, y;