add setlayout function

main
Devin J. Pohly 2020-04-22 11:20:08 -05:00
parent fdbe9ee29a
commit def3572117
2 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,8 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd } }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd } },
{ MODKEY, XKB_KEY_Escape, quit, {0} }, { MODKEY, XKB_KEY_Escape, quit, {0} },
{ MODKEY, XKB_KEY_F1, focusnext, {0} }, { MODKEY, XKB_KEY_F1, focusnext, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, setlayout, {.v = &layouts[0]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_F, setlayout, {.v = &layouts[1]} },
}; };
static const Button buttons[] = { static const Button buttons[] = {

11
dwl.c
View File

@ -143,6 +143,7 @@ static void resize(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg); static void resizemouse(const Arg *arg);
static void run(char *startup_cmd); static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data); static void setcursor(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg);
static void setup(void); static void setup(void);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
@ -885,6 +886,16 @@ setcursor(struct wl_listener *listener, void *data)
} }
} }
void
setlayout(const Arg *arg)
{
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if (arg && arg->v)
selmon->lt[selmon->sellt] = (Layout *)arg->v;
/* XXX change layout symbol? */
}
void void
setup(void) setup(void)
{ {