Merge pull request #18 from guidocella/zoom

Add zoom
This commit is contained in:
Devin J. Pohly 2020-07-24 17:07:52 -04:00 committed by GitHub
commit 66dce64145
Failed to generate hash of commit
2 changed files with 31 additions and 0 deletions

View file

@ -59,6 +59,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} }, { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },

30
dwl.c
View file

@ -211,6 +211,7 @@ static void unmapnotify(struct wl_listener *listener, void *data);
static void view(const Arg *arg); static void view(const Arg *arg);
static Client *xytoclient(double x, double y); static Client *xytoclient(double x, double y);
static Monitor *xytomon(double x, double y); static Monitor *xytomon(double x, double y);
static void zoom(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@ -1636,6 +1637,35 @@ xytomon(double x, double y)
return o ? o->data : NULL; return o ? o->data : NULL;
} }
void
zoom(const Arg *arg)
{
unsigned int n = 0;
Client *c, *sel = selclient();
if (!sel || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
return;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, selmon) && !c->isfloating) {
if (++n == 1 && c == sel)
sel = NULL;
else if (n == 2) {
if (!sel)
sel = c;
break;
}
}
if (n == 1)
return;
wl_list_remove(&sel->link);
wl_list_insert(&clients, &sel->link);
focusclient(sel, NULL, 1);
arrange(selmon);
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {