From 4eabe48fed38b94e810768dd8523cba3cbd5bae2 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Thu, 23 Apr 2020 20:14:11 -0500 Subject: add incnmaster and setmfact commands --- config.def.h | 6 +++++- dwl.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 71d67e9..9d3dc35 100644 --- a/config.def.h +++ b/config.def.h @@ -41,9 +41,13 @@ static const char *termcmd[] = { "kitty", "-o", "linux_display_server=wayland", static const Key keys[] = { /* modifier key function argument */ - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd } }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, + { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, + { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, + { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} }, + { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} }, { MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, diff --git a/dwl.c b/dwl.c index c58a7e0..c813268 100644 --- a/dwl.c +++ b/dwl.c @@ -30,6 +30,7 @@ #include /* macros */ +#define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) #define VISIBLEON(C, M) ((C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) @@ -131,6 +132,7 @@ static void cursorframe(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); static void focus(Client *c, struct wlr_surface *surface); static void focusstack(const Arg *arg); +static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); static bool keybinding(uint32_t mods, xkb_keysym_t sym); static void keypress(struct wl_listener *listener, void *data); @@ -149,6 +151,7 @@ static void run(char *startup_cmd); static Client *selclient(void); static void setcursor(struct wl_listener *listener, void *data); static void setlayout(const Arg *arg); +static void setmfact(const Arg *arg); static void setup(void); static void spawn(const Arg *arg); static void tag(const Arg *arg); @@ -469,6 +472,12 @@ focusstack(const Arg *arg) focus(c, NULL); } +void +incnmaster(const Arg *arg) +{ + selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); +} + void inputdevice(struct wl_listener *listener, void *data) { @@ -949,6 +958,20 @@ setlayout(const Arg *arg) /* XXX change layout symbol? */ } +/* arg > 1.0 will set mfact absolutely */ +void +setmfact(const Arg *arg) +{ + float f; + + if (!arg || !selmon->lt[selmon->sellt]->arrange) + return; + f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; + if (f < 0.1 || f > 0.9) + return; + selmon->mfact = f; +} + void setup(void) { -- cgit v1.2.3