added focus master and new keybindings

This commit is contained in:
JuliusHerrmann 2020-10-19 22:27:01 +02:00
parent a3ef784a8d
commit 0d2f92ee95
6 changed files with 79 additions and 15 deletions

View File

@ -95,6 +95,7 @@ static Key keys[] = {
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ControlMask, XK_space, focusmaster, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
@ -152,7 +153,8 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_Down, moveresize, {.v = (int []){ 0, 0, 0, 25 }}},
{ MODKEY|ShiftMask, XK_Up, moveresize, {.v = (int []){ 0, 0, 0, -25 }}},
{ MODKEY|ShiftMask, XK_Right, moveresize, {.v = (int []){ 0, 0, 25, 0 }}},
{ MODKEY|ShiftMask, XK_Left, moveresize, {.v = (int []){ 0, 0, -25, 0 }}},{ MODKEY|ShiftMask, XK_q, quit, {0} },
{ MODKEY|ShiftMask, XK_Left, moveresize, {.v = (int []){ 0, 0, -25, 0 }}},
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
/* button definitions */

View File

@ -60,18 +60,18 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "[M]", monocle },
{ "[@]", spiral },
{ "[\\]", dwindle },
{ "H[]", deck },
{ "TTT", bstack },
{ "===", bstackhoriz },
{ "HHH", grid },
{ "###", nrowgrid },
{ "---", horizgrid },
//{ "[M]", monocle },
//{ "[@]", spiral },
//{ "[\\]", dwindle },
//{ "H[]", deck },
//{ "TTT", bstack },
//{ "===", bstackhoriz },
//{ "HHH", grid },
//{ "###", nrowgrid },
//{ "---", horizgrid },
{ ":::", gaplessgrid },
{ "|M|", centeredmaster },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "><>", NULL }, /*[> no layout function means floating behavior <]*/
{ NULL, NULL },
};
@ -99,12 +99,13 @@ static Key keys[] = {
//{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ShiftMask, XK_space, focusmaster, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
//{ MODKEY, XK_i, incnmaster, {.i = +1 } },
//{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_plus, incnmaster, {.i = +1 } },
{ MODKEY, XK_minus, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Tab, zoom, {0} },
@ -131,8 +132,8 @@ static Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_space, cyclelayout, {.i = +1 } },
{ MODKEY|ShiftMask, XK_f, togglefloating, {0} },
{ MODKEY, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },

BIN
dwm

Binary file not shown.

16
dwm.c
View File

@ -275,6 +275,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
static void focusmaster(const Arg *arg);
/* variables */
static Systray *systray = NULL;
static const char broken[] = "broken";
@ -2575,3 +2577,17 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
void
focusmaster(const Arg *arg)
{
Client *c;
if (selmon->nmaster < 1)
return;
c = nexttiled(selmon->clients);
if (c)
focus(c);
}

BIN
dwm.o

Binary file not shown.

45
focusmaster.diff Normal file
View File

@ -0,0 +1,45 @@
From 3e020d93df3aaec92d2daa142cd1f0d5301b3197 Mon Sep 17 00:00:00 2001
From: Mateus Auler <mateusauler@protonmail.com>
Date: Fri, 17 Jul 2020 12:36:36 -0300
Subject: [PATCH] Ability to map a key combination to switch focus to
the master window.
---
dwm.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/dwm.c b/dwm.c
index 9fd0286..be01927 100644
--- a/dwm.c
+++ b/dwm.c
@@ -235,6 +235,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void focusmaster(const Arg *arg);
+
/* variables */
static const char broken[] = "broken";
static char stext[256];
@@ -2150,3 +2152,17 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
+
+void
+focusmaster(const Arg *arg)
+{
+ Client *c;
+
+ if (selmon->nmaster < 1)
+ return;
+
+ c = nexttiled(selmon->clients);
+
+ if (c)
+ focus(c);
+}
--
2.27.0