Compare commits

..
14 Commits
Author SHA1 Message Date
explosion-mental a07421c195 shift-tools - shifttag, moves the current selected client to the adjacent tag - shifttagclients, moves the current selected client to the adjacent tag that has at least one client else acts as shifttag - shiftview, view adjacent tag - shiftviewclients, view the closes tag that has a client. If none acts as shiftview - shiftboth, shifttag and shiftview. Basically moves the window to the next/prev tag and follows it. - shiftswaptags, its a shift implementation on the swaptags function (see https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c79333751b02f/config.h#L48 for more details), which in short 'swaps tags' (swaps all clients with the clients on the adjacent tag). A pretty useful example of this is chosing a tag empty and sending all your clients to that tag. - swapfunction is the 'helper' function for the shiftswaptags. remember that these functions **shift**, which means you can go from tag 1 to 9 or 9 to 1. Also remember that the default argument is 1 and you can change it. 2025-10-08 23:43:48 +02:00
lupan 006706b5d0 agree: dwm-goback with dwm-warp 2025-10-08 23:09:15 +02:00
Max Schillinger 0243a59c57 add patch/function 'goback' 2025-10-08 22:57:08 +02:00
lupan c013256eef agree: dwm-autodarkmode with dwm-awesomebar 2025-10-07 00:06:55 +02:00
dimarogiv 431135ecd9 With this patch you can focus on any of the currently open windows on the current tagset with just one key combination 2025-10-07 00:02:23 +02:00
Cyril Cressent f2837055a1 Port the uselessgap patch to 6.2 2025-10-06 23:58:04 +02:00
Jonas Dujava 5bcc02f2a7 Warp patch
Warps the mouse cursor to the center of the currently focused
window or screen when the mouse cursor is
  (a) on a different screen, or
  (b) on top of a different window.

This version properly handles warping to windows that have not been
mapped yet (before it resulted in a change of the stack order).
See the discussion in (thanks goes to Bakkeby):
    https://github.com/bakkeby/patches/issues/60
2025-10-06 23:58:04 +02:00
lupan 9e3e644c21 apply dwm-xinerama-monitors-xorder-6.4.diff 2025-10-06 23:58:04 +02:00
lupan b6d063c786 agree: change dwm-autodarkmode signal to USR1 and leave restarsig signal to HUP 2025-10-06 23:58:04 +02:00
lupan 272db9d233 apply patch dwm-autodarkmode-20250224-6.5.diff 2025-10-06 22:33:03 +02:00
lupan e93f93b98c apply patch dwm-awesomebar-20230431-6.4.diff 2025-10-06 22:14:07 +02:00
lupan cc4d5e65d7 apply patch dwm-exitmenu-6.3.diff 2025-10-06 21:31:59 +02:00
Arda Atci 9b49e9ad18 preserve clients on old tags when renewing dwm
By default, when dwm is recompiled-restarted all clients will
lose it's current tag and collapse to first tag. This patch preserves
clients on old tags, however note that layout order is not preserved.
2025-10-06 21:25:59 +02:00
Christopher Drelich cfe958510f Modifies quit to handle restarts and adds SIGHUP and SIGTERM handlers.
Modified quit() to restart if it receives arg .i = 1
MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that.

Signal handlers were handled for SIGHUP and SIGTERM.
If dwm receives these signals it calls quit() with
arg .i = to 1 or 0, respectively.

To restart dwm:
MOD+CTRL+SHIFT+Q
or
kill -HUP dwmpid

To quit dwm cleanly:
MOD+SHIFT+Q
or
kill -TERM dwmpid
2025-10-06 21:23:18 +02:00
16 changed files with 127 additions and 940 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,5 @@
MIT/X Consortium License MIT/X Consortium License
© 2010-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2006-2019 Anselm R Garbe <anselm@garbe.ca> © 2006-2019 Anselm R Garbe <anselm@garbe.ca>
© 2006-2009 Jukka Salmi <jukka at salmi dot ch> © 2006-2009 Jukka Salmi <jukka at salmi dot ch>
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com> © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
@@ -12,6 +11,7 @@ MIT/X Consortium License
© 2008 Martin Hurton <martin dot hurton at gmail dot com> © 2008 Martin Hurton <martin dot hurton at gmail dot com>
© 2008 Neale Pickett <neale dot woozle dot org> © 2008 Neale Pickett <neale dot woozle dot org>
© 2009 Mate Nagy <mnagy at port70 dot net> © 2009 Mate Nagy <mnagy at port70 dot net>
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2010-2012 Connor Lane Smith <cls@lubutu.com> © 2010-2012 Connor Lane Smith <cls@lubutu.com>
© 2011 Christoph Lohmann <20h@r-36.net> © 2011 Christoph Lohmann <20h@r-36.net>
© 2015-2016 Quentin Rameau <quinq@fifth.space> © 2015-2016 Quentin Rameau <quinq@fifth.space>
+74 -100
View File
@@ -1,9 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include "gaplessgrid.c"
/* appearance */ /* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int gappx = 2; /* gaps between windows */ static const unsigned int gappx = 6; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
@@ -14,23 +13,21 @@ static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577"; static const char col_cyan[] = "#005577";
static const char col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
static const char *colorsdark[][3] = { static const char *colorsdark[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark }, [SchemeSel] = { col_gray4, col_cyan, col_cyan },
[SchemeHid] = { col_cyan, col_gray1, col_cyan }, [SchemeHid] = { col_cyan, col_gray1, col_cyan },
}; };
static const char *colorslight[][3] = { static const char *colorslight[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 }, [SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light }, [SchemeSel] = { col_cyan, col_gray4, col_cyan },
[SchemeHid] = { col_cyan, col_gray1, col_cyan }, [SchemeHid] = { col_cyan, col_gray1, col_cyan },
}; };
/* tagging */ /* tagging */
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
@@ -47,115 +44,92 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
static const int nmaster = 1; /* number of clients in master area */ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "[]=", tile }, /* first entry is default */ { "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */ { "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle }, { "[M]", monocle },
{ "HHH", gaplessgrid },
}; };
/* key definitions */ /* key definitions */
#define MODKEY Mod4Mask #define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \ #define TAGKEYS(KEY,TAG) \
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }), { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */ /* commands */
static char dmenumon[8] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */ static char dmenumon[2] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
static const char *dmenudark[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenudark[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *dmenulight[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenulight[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "alacritty", NULL }; static const char *termcmd[] = { "st", NULL };
static const char *lockcmd[] = { "slock", NULL };
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
#include "shift-tools.c" #include "shift-tools.c"
#include "exitdwm.c"
#include "movestack.c"
static Keychord *keychords[] = { #include "exitdwm.c"
/* Keys function argument */ static const Key keys[] = {
&((Keychord){1, {{MODKEY, XK_p}}, spawndmenu, {0} }), /* modifier key function argument */
&((Keychord){1, {{MODKEY, XK_u}}, shiftview, { .i = +1 } }), { MODKEY, XK_p, spawndmenu, {0} },
&((Keychord){1, {{MODKEY|ShiftMask, XK_u}}, shifttag, { .i = +1 } }), { MODKEY, XK_o, shiftviewclients, { .i = +1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_y}}, shifttag, { .i = -1 } }), { MODKEY|ShiftMask, XK_o, shiftview, { .i = +1 } },
&((Keychord){1, {{MODKEY, XK_y}}, shiftview, { .i = -1 } }), { MODKEY|ShiftMask, XK_i, shiftview, { .i = -1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }), { MODKEY, XK_i, shiftviewclients, { .i = -1 } },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }), { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
&((Keychord){1, {{MODKEY, XK_j}}, focusstackvis, {.i = +1 } }), { MODKEY, XK_b, togglebar, {0} },
&((Keychord){1, {{MODKEY, XK_k}}, focusstackvis, {.i = -1 } }), { MODKEY, XK_j, focusstackvis, {.i = +1 } },
&((Keychord){1, {{MODKEY|ControlMask, XK_j}}, focusstackhid, {.i = +1 } }), { MODKEY, XK_k, focusstackvis, {.i = -1 } },
&((Keychord){1, {{MODKEY|ControlMask, XK_k}}, focusstackhid, {.i = -1 } }), { MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } },
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }), { MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_d}}, incnmaster, {.i = -1 } }), { MODKEY, XK_i, incnmaster, {.i = +1 } },
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }), { MODKEY, XK_d, incnmaster, {.i = -1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_h}}, shiftboth, {.i = -1} }), { MODKEY, XK_h, setmfact, {.f = -0.05} },
&((Keychord){1, {{MODKEY|ControlMask, XK_h}}, shiftswaptags, {.i = -1} }), { MODKEY|ShiftMask, XK_h, shiftboth, { .i = -1 } },
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }), { MODKEY|ControlMask, XK_h, shiftswaptags, { .i = -1 } },
&((Keychord){1, {{MODKEY|ControlMask, XK_l}}, shiftswaptags, { .i = +1 } }), { MODKEY|ControlMask, XK_l, shiftswaptags, { .i = +1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_l}}, shiftboth, { .i = +1 } }), { MODKEY|ShiftMask, XK_l, shiftboth, { .i = +1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_j}}, movestack, {.i = +1 } }), { MODKEY, XK_l, setmfact, {.f = +0.05} },
&((Keychord){1, {{MODKEY|ShiftMask, XK_k}}, movestack, {.i = -1 } }), { MODKEY, XK_Return, zoom, {0} },
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }), { MODKEY, XK_Tab, view, {0} },
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }), { MODKEY, XK_g, goback, {0} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_w}}, goback, {0} }), { MODKEY|ShiftMask, XK_c, killclient, {0} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_c}}, killclient, {0} }), { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }), { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }), { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
&((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }), { MODKEY, XK_space, setlayout, {0} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_g}}, setlayout, {.v = &layouts[3]} }), { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }), { MODKEY, XK_0, view, {.ui = ~0 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }), { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
&((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }), { MODKEY, XK_comma, focusmon, {.i = -1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }), { MODKEY, XK_period, focusmon, {.i = +1 } },
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }), { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }), { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }), { MODKEY, XK_s, show, {0} },
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }), { MODKEY|ShiftMask, XK_s, showall, {0} },
&((Keychord){1, {{MODKEY, XK_s}}, show, {0} }), { MODKEY, XK_h, hide, {0} },
&((Keychord){1, {{MODKEY|ShiftMask, XK_s}}, showall, {0} }), TAGKEYS( XK_1, 0)
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask, XK_s}}, hide, {0} }), TAGKEYS( XK_2, 1)
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }), TAGKEYS( XK_3, 2)
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask|ShiftMask, XK_q}}, quit, {1} }), TAGKEYS( XK_4, 3)
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_e}}, exitdwm, {0} }), TAGKEYS( XK_5, 4)
&((Keychord){1, {{MODKEY, XK_o}}, winview, {0} }), TAGKEYS( XK_6, 5)
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_a}}, gridall, {0} }), TAGKEYS( XK_7, 6)
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_r}}, winviewmono, {0} }), TAGKEYS( XK_8, 7)
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_s}}, spawn, {.v = suspendcmd } }), TAGKEYS( XK_9, 8)
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, XK_l}}, spawn, {.v = lockcmd } }), { MODKEY|ShiftMask, XK_j, focusbynum, {.i = 0} },
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_t}}, spawn, {.v = themecmd } }), { MODKEY|ShiftMask, XK_k, focusbynum, {.i = 1} },
TAGKEYS( XK_q, 0) { MODKEY|ShiftMask, XK_l, focusbynum, {.i = 2} },
TAGKEYS( XK_w, 1) { MODKEY|ShiftMask, XK_colon, focusbynum, {.i = 3} },
TAGKEYS( XK_e, 2) { MODKEY|ShiftMask, XK_f, focusbynum, {.i = 4} },
TAGKEYS( XK_r, 3) { MODKEY|ShiftMask, XK_d, focusbynum, {.i = 5} },
TAGKEYS( XK_t, 4) { MODKEY|ShiftMask, XK_s, focusbynum, {.i = 6} },
TAGKEYS( XK_a, 5) { MODKEY|ShiftMask, XK_a, focusbynum, {.i = 7} },
TAGKEYS( XK_s, 6) { MODKEY|ShiftMask, XK_q, quit, {0} },
TAGKEYS( XK_d, 7) { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
TAGKEYS( XK_f, 8) { MODKEY|ShiftMask, XK_e, exitdwm, {0} },
TAGKEYS( XK_g, 9)
TAGKEYS( XK_z, 10)
TAGKEYS( XK_x, 11)
TAGKEYS( XK_c, 12)
TAGKEYS( XK_v, 13)
TAGKEYS( XK_b, 14)
&((Keychord){1, {{ ControlMask, XK_1}}, focusbynum, {.i = 0} }),
&((Keychord){1, {{ ControlMask, XK_2}}, focusbynum, {.i = 1} }),
&((Keychord){1, {{ ControlMask, XK_3}}, focusbynum, {.i = 2} }),
&((Keychord){1, {{ ControlMask, XK_4}}, focusbynum, {.i = 3} }),
&((Keychord){1, {{ ControlMask, XK_5}}, focusbynum, {.i = 4} }),
&((Keychord){1, {{ ControlMask, XK_6}}, focusbynum, {.i = 5} }),
&((Keychord){1, {{ ControlMask, XK_7}}, focusbynum, {.i = 6} }),
&((Keychord){1, {{ ControlMask, XK_8}}, focusbynum, {.i = 7} }),
&((Keychord){1, {{ ControlMask, XK_9}}, focusbynum, {.i = 8} }),
}; };
/* button definitions */ /* button definitions */
-178
View File
@@ -1,178 +0,0 @@
/* See LICENSE file for copyright and license details. */
#include "gaplessgrid.c"
/* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int gappx = 2; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
static const char col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
static const char *colorsdark[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark },
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
};
static const char *colorslight[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light },
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
};
/* tagging */
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" };
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "HHH", gaplessgrid },
};
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
static char dmenumon[8] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
static const char *dmenudark[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *dmenulight[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "alacritty", NULL };
static const char *lockcmd[] = { "slock", NULL };
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
#include "shift-tools.c"
#include "exitdwm.c"
#include "movestack.c"
static Keychord *keychords[] = {
/* Keys function argument */
&((Keychord){1, {{MODKEY, XK_p}}, spawndmenu, {0} }),
&((Keychord){1, {{MODKEY, XK_u}}, shiftview, { .i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_u}}, shifttag, { .i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_y}}, shifttag, { .i = -1 } }),
&((Keychord){1, {{MODKEY, XK_y}}, shiftview, { .i = -1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }),
&((Keychord){1, {{MODKEY, XK_j}}, focusstackvis, {.i = +1 } }),
&((Keychord){1, {{MODKEY, XK_k}}, focusstackvis, {.i = -1 } }),
&((Keychord){1, {{MODKEY|ControlMask, XK_j}}, focusstackhid, {.i = +1 } }),
&((Keychord){1, {{MODKEY|ControlMask, XK_k}}, focusstackhid, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_d}}, incnmaster, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_h}}, shiftboth, {.i = -1} }),
&((Keychord){1, {{MODKEY|ControlMask, XK_h}}, shiftswaptags, {.i = -1} }),
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
&((Keychord){1, {{MODKEY|ControlMask, XK_l}}, shiftswaptags, { .i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_l}}, shiftboth, { .i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_j}}, movestack, {.i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_k}}, movestack, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_w}}, goback, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }),
&((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_g}}, setlayout, {.v = &layouts[3]} }),
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
&((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
&((Keychord){1, {{MODKEY, XK_s}}, show, {0} }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_s}}, showall, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask, XK_s}}, hide, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask|ShiftMask, XK_q}}, quit, {1} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_e}}, exitdwm, {0} }),
&((Keychord){1, {{MODKEY, XK_o}}, winview, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_a}}, gridall, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_r}}, winviewmono, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_s}}, spawn, {.v = suspendcmd } }),
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, XK_l}}, spawn, {.v = lockcmd } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_t}}, spawn, {.v = themecmd } }),
TAGKEYS( XK_q, 0)
TAGKEYS( XK_w, 1)
TAGKEYS( XK_e, 2)
TAGKEYS( XK_r, 3)
TAGKEYS( XK_t, 4)
TAGKEYS( XK_a, 5)
TAGKEYS( XK_s, 6)
TAGKEYS( XK_d, 7)
TAGKEYS( XK_f, 8)
TAGKEYS( XK_g, 9)
TAGKEYS( XK_z, 10)
TAGKEYS( XK_x, 11)
TAGKEYS( XK_c, 12)
TAGKEYS( XK_v, 13)
TAGKEYS( XK_b, 14)
&((Keychord){1, {{ ControlMask, XK_1}}, focusbynum, {.i = 0} }),
&((Keychord){1, {{ ControlMask, XK_2}}, focusbynum, {.i = 1} }),
&((Keychord){1, {{ ControlMask, XK_3}}, focusbynum, {.i = 2} }),
&((Keychord){1, {{ ControlMask, XK_4}}, focusbynum, {.i = 3} }),
&((Keychord){1, {{ ControlMask, XK_5}}, focusbynum, {.i = 4} }),
&((Keychord){1, {{ ControlMask, XK_6}}, focusbynum, {.i = 5} }),
&((Keychord){1, {{ ControlMask, XK_7}}, focusbynum, {.i = 6} }),
&((Keychord){1, {{ ControlMask, XK_8}}, focusbynum, {.i = 7} }),
&((Keychord){1, {{ ControlMask, XK_9}}, focusbynum, {.i = 8} }),
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button1, togglewin, {0} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
-124
View File
@@ -1,124 +0,0 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
/* tagging */
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" };
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
};
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
static char dmenumon[8]; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "alacritty", NULL };
static Keychord *keychords[] = {
/* Keys function argument */
&((Keychord){1, {{MODKEY, XK_p}}, spawn, {.v = dmenucmd } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_e}}, spawn, {.v = termcmd } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }),
&((Keychord){1, {{MODKEY, XK_j}}, focusstack, {.i = +1 } }),
&((Keychord){1, {{MODKEY, XK_k}}, focusstack, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
&((Keychord){1, {{MODKEY, XK_u}}, incnmaster, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_m}}, setlayout, {.v = &layouts[2]} }),
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
&((Keychord){1, {{MODKEY, XK_y}}, view, {.ui = ~0 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }),
TAGKEYS( XK_q, 0)
TAGKEYS( XK_w, 1)
TAGKEYS( XK_e, 2)
TAGKEYS( XK_r, 3)
TAGKEYS( XK_t, 4)
TAGKEYS( XK_a, 5)
TAGKEYS( XK_s, 6)
TAGKEYS( XK_d, 7)
TAGKEYS( XK_f, 8)
TAGKEYS( XK_g, 9)
TAGKEYS( XK_z, 10)
TAGKEYS( XK_x, 11)
TAGKEYS( XK_c, 12)
TAGKEYS( XK_v, 13)
TAGKEYS( XK_b, 14)
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
+1 -1
View File
@@ -1,5 +1,5 @@
# dwm version # dwm version
VERSION = 6.8 VERSION = 6.6
# Customize below to fit your system # Customize below to fit your system
+3 -26
View File
@@ -178,7 +178,8 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
die("error, cannot allocate color '%s'", clrname); die("error, cannot allocate color '%s'", clrname);
} }
/* Create color schemes. */ /* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr * Clr *
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
{ {
@@ -186,7 +187,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
Clr *ret; Clr *ret;
/* need at least two colors for a scheme */ /* need at least two colors for a scheme */
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr)))) if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
return NULL; return NULL;
for (i = 0; i < clrcount; i++) for (i = 0; i < clrcount; i++)
@@ -194,30 +195,6 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
return ret; return ret;
} }
void
drw_clr_free(Drw *drw, Clr *c)
{
if (!drw || !c)
return;
/* c is typedef XftColor Clr */
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
DefaultColormap(drw->dpy, drw->screen), c);
}
void
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
{
size_t i;
if (!drw || !scm)
return;
for (i = 0; i < clrcount; i++)
drw_clr_free(drw, &scm[i]);
free(scm);
}
void void
drw_setfontset(Drw *drw, Fnt *set) drw_setfontset(Drw *drw, Fnt *set)
{ {
-2
View File
@@ -40,9 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
/* Colorscheme abstraction */ /* Colorscheme abstraction */
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
void drw_clr_free(Drw *drw, Clr *c);
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
/* Cursor abstraction */ /* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape); Cur *drw_cur_create(Drw *drw, int shape);
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-272
View File
@@ -1,272 +0,0 @@
From 9c020a20a2e1091e8b47edfea5e8795d8b451bc9 Mon Sep 17 00:00:00 2001
From: Lukasz Kasprzak <lukas@labunix.xyz>
Date: Fri, 17 Jul 2026 15:45:22 +0200
Subject: [PATCH] keychord: bind a sequence of keys, and dispatch events while
waiting
Original keychord patch by Hai Nguyen <hhai2105@gmail.com>, updated for
dwm 6.4+ grabkeys() by Aaron Zueger <contact@azureorange.xyz>. This
revision rebases onto dwm 6.8 and fixes an event-loss bug in the chord
wait loop.
The wait loop used to discard every event that was not a KeyPress:
while (running && !XNextEvent(dpy, &event) && !ran)
if(event.type == KeyPress)
break;
Two consequences, both reproduced on Xephyr:
1. Unrecoverable input freeze. grabbuttons() grabs unfocused clients
GrabModeSync/GrabModeSync, so clicking one freezes pointer AND
keyboard until the grabbing client calls XAllowEvents. dwm does that
in buttonpress() -- but if the ButtonPress is discarded here,
buttonpress() never runs. The grab stays frozen forever and the loop
can never exit, because a frozen keyboard cannot deliver the KeyPress
it is waiting for. Only killing dwm ends it; XSendEvent is discarded
by this same loop and XTEST queues behind the frozen device.
Repro: press a chord prefix, then click any unfocused client.
Observed: XGrabKeyboard -> GrabFrozen, XQueryPointer -> Button1 held.
2. Orphaned windows. A MapRequest arriving mid-chord is dropped, so a
window opening during a chord is never managed. DestroyNotify,
Expose and ConfigureRequest are lost the same way.
Dispatch through handler[] as run() does, breaking on KeyPress before
dispatch so keypress() cannot recurse. The `&& !ran` term is dropped:
ran is always 0 on entry and nothing in the body can set it.
---
config.def.h | 81 ++++++++++++++++++++++++++--------------------------
dwm.c | 79 +++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 106 insertions(+), 54 deletions(-)
diff --git a/config.def.h b/config.def.h
index 81c3fc0..7c7ec36 100644
--- a/config.def.h
+++ b/config.def.h
@@ -47,11 +47,11 @@ static const Layout layouts[] = {
/* key definitions */
#define MODKEY Mod1Mask
-#define TAGKEYS(KEY,TAG) \
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
+#define TAGKEYS(KEY,TAG) \
+ &((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
+ &((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
+ &((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
+ &((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
@@ -61,41 +61,42 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };
-static const Key keys[] = {
- /* modifier key function argument */
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
- { MODKEY, XK_b, togglebar, {0} },
- { MODKEY, XK_j, focusstack, {.i = +1 } },
- { MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY, XK_Return, zoom, {0} },
- { MODKEY, XK_Tab, view, {0} },
- { MODKEY|ShiftMask, XK_c, killclient, {0} },
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
- { MODKEY, XK_space, setlayout, {0} },
- { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
- { MODKEY, XK_0, view, {.ui = ~0 } },
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
- { MODKEY, XK_comma, focusmon, {.i = -1 } },
- { MODKEY, XK_period, focusmon, {.i = +1 } },
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
- TAGKEYS( XK_1, 0)
- TAGKEYS( XK_2, 1)
- TAGKEYS( XK_3, 2)
- TAGKEYS( XK_4, 3)
- TAGKEYS( XK_5, 4)
- TAGKEYS( XK_6, 5)
- TAGKEYS( XK_7, 6)
- TAGKEYS( XK_8, 7)
- TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_q, quit, {0} },
+static Keychord *keychords[] = {
+ /* Keys function argument */
+ &((Keychord){1, {{MODKEY, XK_p}}, spawn, {.v = dmenucmd } }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
+ &((Keychord){2, {{MODKEY, XK_e}, {MODKEY, XK_e}}, spawn, {.v = termcmd } }),
+ &((Keychord){1, {{MODKEY, XK_b}}, togglebar, {0} }),
+ &((Keychord){1, {{MODKEY, XK_j}}, focusstack, {.i = +1 } }),
+ &((Keychord){1, {{MODKEY, XK_k}}, focusstack, {.i = -1 } }),
+ &((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
+ &((Keychord){1, {{MODKEY, XK_d}}, incnmaster, {.i = -1 } }),
+ &((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
+ &((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
+ &((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
+ &((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
+ &((Keychord){1, {{MODKEY, XK_t}}, setlayout, {.v = &layouts[0]} }),
+ &((Keychord){1, {{MODKEY, XK_f}}, setlayout, {.v = &layouts[1]} }),
+ &((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }),
+ &((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
+ &((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
+ &((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
+ &((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_q}}, quit, {0} }),
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+ TAGKEYS( XK_4, 3)
+ TAGKEYS( XK_5, 4)
+ TAGKEYS( XK_6, 5)
+ TAGKEYS( XK_7, 6)
+ TAGKEYS( XK_8, 7)
+ TAGKEYS( XK_9, 8)
};
/* button definitions */
diff --git a/dwm.c b/dwm.c
index 53b393e..243b12c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -101,9 +101,14 @@ struct Client {
typedef struct {
unsigned int mod;
KeySym keysym;
+} Key;
+
+typedef struct {
+ unsigned int n;
+ const Key keys[5];
void (*func)(const Arg *);
const Arg arg;
-} Key;
+} Keychord;
typedef struct {
const char *symbol;
@@ -266,6 +271,7 @@ static Display *dpy;
static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+unsigned int currentkey = 0;
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -954,7 +960,8 @@ grabkeys(void)
{
updatenumlockmask();
{
- unsigned int i, j, k;
+ /* unsigned int i, j, k; */
+ unsigned int i, c, k;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
int start, end, skip;
KeySym *syms;
@@ -964,15 +971,18 @@ grabkeys(void)
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
if (!syms)
return;
+
for (k = start; k <= end; k++)
- for (i = 0; i < LENGTH(keys); i++)
+ for (i = 0; i < LENGTH(keychords); i++)
/* skip modifier codes, we do that ourselves */
- if (keys[i].keysym == syms[(k - start) * skip])
- for (j = 0; j < LENGTH(modifiers); j++)
+ if (keychords[i]->keys[currentkey].keysym == syms[(k - start) * skip])
+ for (c = 0; c < LENGTH(modifiers); c++)
XGrabKey(dpy, k,
- keys[i].mod | modifiers[j],
+ keychords[i]->keys[currentkey].mod | modifiers[c],
root, True,
GrabModeAsync, GrabModeAsync);
+ if(currentkey > 0)
+ XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Escape), AnyModifier, root, True, GrabModeAsync, GrabModeAsync);
XFree(syms);
}
}
@@ -999,17 +1009,58 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
void
keypress(XEvent *e)
{
- unsigned int i;
+ /* unsigned int i; */
+ XEvent event = *e;
+ unsigned int ran = 0;
KeySym keysym;
XKeyEvent *ev;
- ev = &e->xkey;
- keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
- for (i = 0; i < LENGTH(keys); i++)
- if (keysym == keys[i].keysym
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
- && keys[i].func)
- keys[i].func(&(keys[i].arg));
+ Keychord *arr1[sizeof(keychords) / sizeof(Keychord*)];
+ Keychord *arr2[sizeof(keychords) / sizeof(Keychord*)];
+ memcpy(arr1, keychords, sizeof(keychords));
+ Keychord **rpointer = arr1;
+ Keychord **wpointer = arr2;
+
+ size_t r = sizeof(keychords)/ sizeof(Keychord*);
+
+ while(1){
+ ev = &event.xkey;
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+ size_t w = 0;
+ for (int i = 0; i < r; i++){
+ if(keysym == (*(rpointer + i))->keys[currentkey].keysym
+ && CLEANMASK((*(rpointer + i))->keys[currentkey].mod) == CLEANMASK(ev->state)
+ && (*(rpointer + i))->func){
+ if((*(rpointer + i))->n == currentkey +1){
+ (*(rpointer + i))->func(&((*(rpointer + i))->arg));
+ ran = 1;
+ }else{
+ *(wpointer + w) = *(rpointer + i);
+ w++;
+ }
+ }
+ }
+ currentkey++;
+ if(w == 0 || ran == 1)
+ break;
+ grabkeys();
+ /* Events arriving mid-chord must be dispatched, not dropped:
+ * discarding a ButtonPress that activated the GrabModeSync grab
+ * from grabbuttons() freezes pointer and keyboard permanently,
+ * since only buttonpress()'s XAllowEvents can release it. */
+ while (running && !XNextEvent(dpy, &event)) {
+ if (event.type == KeyPress)
+ break;
+ if (handler[event.type])
+ handler[event.type](&event); /* call handler */
+ }
+ r = w;
+ Keychord **holder = rpointer;
+ rpointer = wpointer;
+ wpointer = holder;
+ }
+ currentkey = 0;
+ grabkeys();
}
void
--
2.47.3
-3
View File
@@ -110,9 +110,6 @@ Increase master area size.
.B Mod1\-h .B Mod1\-h
Decrease master area size. Decrease master area size.
.TP .TP
.B Mod1\-o
Select view of the window in focus. The list of tags to be displayed is matched to the window tag list.
.TP
.B Mod1\-Return .B Mod1\-Return
Zooms/cycles focused window to/from master area (tiled layouts only). Zooms/cycles focused window to/from master area (tiled layouts only).
.TP .TP
+48 -150
View File
@@ -51,6 +51,7 @@
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define HIDDEN(C) ((getstate(C->win) == IconicState)) #define HIDDEN(C) ((getstate(C->win) == IconicState))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) #define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) #define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
@@ -102,14 +103,9 @@ struct Client {
typedef struct { typedef struct {
unsigned int mod; unsigned int mod;
KeySym keysym; KeySym keysym;
} Key;
typedef struct {
unsigned int n;
const Key keys[5];
void (*func)(const Arg *); void (*func)(const Arg *);
const Arg arg; const Arg arg;
} Keychord; } Key;
typedef struct { typedef struct {
const char *symbol; const char *symbol;
@@ -255,13 +251,10 @@ static void view(const Arg *arg);
static void warp(const Client *c); static void warp(const Client *c);
static Client *wintoclient(Window w); static Client *wintoclient(Window w);
static Monitor *wintomon(Window w); static Monitor *wintomon(Window w);
static void winview(const Arg* arg);
static int xerror(Display *dpy, XErrorEvent *ee); static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg); static void zoom(const Arg *arg);
static void gridall(const Arg *arg);
static void winviewmono(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@@ -299,7 +292,6 @@ static Monitor *mons, *selmon, *prevmon;
static Window root, wmcheckwin; static Window root, wmcheckwin;
static const char **dmenucmd; static const char **dmenucmd;
static int colormodechanged; static int colormodechanged;
unsigned int currentkey = 0;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
@@ -429,8 +421,7 @@ arrange(Monitor *m)
void void
arrangemon(Monitor *m) arrangemon(Monitor *m)
{ {
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol) - 1); strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
m->ltsymbol[sizeof(m->ltsymbol) - 1] = '\0';
if (m->lt[m->sellt]->arrange) if (m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m); m->lt[m->sellt]->arrange(m);
} }
@@ -537,8 +528,8 @@ cleanup(void)
for (i = 0; i < CurLast; i++) for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]); drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colorsdark); i++) { for (i = 0; i < LENGTH(colorsdark); i++) {
drw_scm_free(drw, schemedark[i], 3); free(schemedark[i]);
drw_scm_free(drw, schemelight[i], 3); free(schemelight[i]);
} }
free(schemedark); free(schemedark);
free(schemelight); free(schemelight);
@@ -619,9 +610,6 @@ configurenotify(XEvent *e)
/* TODO: updategeom handling sucks, needs to be simplified */ /* TODO: updategeom handling sucks, needs to be simplified */
if (ev->window == root) { if (ev->window == root) {
if (ev->width <= 0 || ev->height <= 0)
return;
dirty = (sw != ev->width || sh != ev->height); dirty = (sw != ev->width || sh != ev->height);
sw = ev->width; sw = ev->width;
sh = ev->height; sh = ev->height;
@@ -705,8 +693,7 @@ createmon(void)
m->topbar = topbar; m->topbar = topbar;
m->lt[0] = &layouts[0]; m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)]; m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof(m->ltsymbol) - 1); strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
m->ltsymbol[sizeof(m->ltsymbol) - 1] = '\0';
return m; return m;
} }
@@ -986,15 +973,14 @@ focusstack(int inc, int hid)
Atom Atom
getatomprop(Client *c, Atom prop) getatomprop(Client *c, Atom prop)
{ {
int format; int di;
unsigned long nitems, dl; unsigned long dl;
unsigned char *p = NULL; unsigned char *p = NULL;
Atom da, atom = None; Atom da, atom = None;
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
&da, &format, &nitems, &dl, &p) == Success && p) { &da, &di, &dl, &dl, &p) == Success && p) {
if (nitems > 0 && format == 32) atom = *(Atom *)p;
atom = *(long *)p;
XFree(p); XFree(p);
} }
return atom; return atom;
@@ -1020,10 +1006,10 @@ getstate(Window w)
Atom real; Atom real;
if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
&real, &format, &n, &extra, &p) != Success) &real, &format, &n, &extra, (unsigned char **)&p) != Success)
return -1; return -1;
if (n != 0 && format == 32) if (n != 0)
result = *(long *)p; result = *p;
XFree(p); XFree(p);
return result; return result;
} }
@@ -1042,8 +1028,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
return 0; return 0;
if (name.encoding == XA_STRING) { if (name.encoding == XA_STRING) {
strncpy(text, (char *)name.value, size - 1); strncpy(text, (char *)name.value, size - 1);
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success) { } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
if (n > 0 && *list)
strncpy(text, *list, size - 1); strncpy(text, *list, size - 1);
XFreeStringList(list); XFreeStringList(list);
} }
@@ -1094,8 +1079,7 @@ grabkeys(void)
{ {
updatenumlockmask(); updatenumlockmask();
{ {
/* unsigned int i, j, k; */ unsigned int i, j, k;
unsigned int i, c, k;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
int start, end, skip; int start, end, skip;
KeySym *syms; KeySym *syms;
@@ -1105,18 +1089,15 @@ grabkeys(void)
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip); syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
if (!syms) if (!syms)
return; return;
for (k = start; k <= end; k++) for (k = start; k <= end; k++)
for (i = 0; i < LENGTH(keychords); i++) for (i = 0; i < LENGTH(keys); i++)
/* skip modifier codes, we do that ourselves */ /* skip modifier codes, we do that ourselves */
if (keychords[i]->keys[currentkey].keysym == syms[(k - start) * skip]) if (keys[i].keysym == syms[(k - start) * skip])
for (c = 0; c < LENGTH(modifiers); c++) for (j = 0; j < LENGTH(modifiers); j++)
XGrabKey(dpy, k, XGrabKey(dpy, k,
keychords[i]->keys[currentkey].mod | modifiers[c], keys[i].mod | modifiers[j],
root, True, root, True,
GrabModeAsync, GrabModeAsync); GrabModeAsync, GrabModeAsync);
if(currentkey > 0)
XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Escape), AnyModifier, root, True, GrabModeAsync, GrabModeAsync);
XFree(syms); XFree(syms);
} }
} }
@@ -1173,58 +1154,17 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
void void
keypress(XEvent *e) keypress(XEvent *e)
{ {
/* unsigned int i; */ unsigned int i;
XEvent event = *e;
unsigned int ran = 0;
KeySym keysym; KeySym keysym;
XKeyEvent *ev; XKeyEvent *ev;
Keychord *arr1[sizeof(keychords) / sizeof(Keychord*)]; ev = &e->xkey;
Keychord *arr2[sizeof(keychords) / sizeof(Keychord*)];
memcpy(arr1, keychords, sizeof(keychords));
Keychord **rpointer = arr1;
Keychord **wpointer = arr2;
size_t r = sizeof(keychords)/ sizeof(Keychord*);
while(1){
ev = &event.xkey;
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
size_t w = 0; for (i = 0; i < LENGTH(keys); i++)
for (int i = 0; i < r; i++){ if (keysym == keys[i].keysym
if(keysym == (*(rpointer + i))->keys[currentkey].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
&& CLEANMASK((*(rpointer + i))->keys[currentkey].mod) == CLEANMASK(ev->state) && keys[i].func)
&& (*(rpointer + i))->func){ keys[i].func(&(keys[i].arg));
if((*(rpointer + i))->n == currentkey +1){
(*(rpointer + i))->func(&((*(rpointer + i))->arg));
ran = 1;
}else{
*(wpointer + w) = *(rpointer + i);
w++;
}
}
}
currentkey++;
if(w == 0 || ran == 1)
break;
grabkeys();
/* Events arriving mid-chord must be dispatched, not dropped:
* discarding a ButtonPress that activated the GrabModeSync grab
* from grabbuttons() freezes pointer and keyboard permanently,
* since only buttonpress()'s XAllowEvents can release it. */
while (running && !XNextEvent(dpy, &event)) {
if (event.type == KeyPress)
break;
if (handler[event.type])
handler[event.type](&event); /* call handler */
}
r = w;
Keychord **holder = rpointer;
rpointer = wpointer;
wpointer = holder;
}
currentkey = 0;
grabkeys();
} }
void void
@@ -1411,7 +1351,7 @@ movemouse(const Arg *arg)
handler[ev.type](&ev); handler[ev.type](&ev);
break; break;
case MotionNotify: case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate)) if ((ev.xmotion.time - lasttime) <= (1000 / 60))
continue; continue;
lasttime = ev.xmotion.time; lasttime = ev.xmotion.time;
@@ -1605,7 +1545,7 @@ resizemouse(const Arg *arg)
handler[ev.type](&ev); handler[ev.type](&ev);
break; break;
case MotionNotify: case MotionNotify:
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate)) if ((ev.xmotion.time - lasttime) <= (1000 / 60))
continue; continue;
lasttime = ev.xmotion.time; lasttime = ev.xmotion.time;
@@ -1779,10 +1719,12 @@ sendevent(Client *c, Atom proto)
void void
setfocus(Client *c) setfocus(Client *c)
{ {
if (!c->neverfocus) if (!c->neverfocus) {
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32, XChangeProperty(dpy, root, netatom[NetActiveWindow],
PropModeReplace, (unsigned char *)&c->win, 1); XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
sendevent(c, wmatom[WMTakeFocus]); sendevent(c, wmatom[WMTakeFocus]);
} }
@@ -2027,16 +1969,8 @@ void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
struct sigaction sa; struct sigaction sa;
pid_t pid;
if (arg->v == dmenucmd) if (fork() == 0) {
snprintf(dmenumon, sizeof(dmenumon), "%d", selmon->num);
if ((pid = fork()) == -1) {
fprintf(stderr, "dwm: fork failed: %s\n", strerror(errno));
return;
}
if (pid == 0) {
if (dpy) if (dpy)
close(ConnectionNumber(dpy)); close(ConnectionNumber(dpy));
setsid(); setsid();
@@ -2396,8 +2330,7 @@ updatenumlockmask(void)
XModifierKeymap *modmap; XModifierKeymap *modmap;
numlockmask = 0; numlockmask = 0;
if (!(modmap = XGetModifierMapping(dpy))) modmap = XGetModifierMapping(dpy);
return;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
for (j = 0; j < modmap->max_keypermod; j++) for (j = 0; j < modmap->max_keypermod; j++)
if (modmap->modifiermap[i * modmap->max_keypermod + j] if (modmap->modifiermap[i * modmap->max_keypermod + j]
@@ -2416,32 +2349,32 @@ updatesizehints(Client *c)
/* size is uninitialized, ensure that size.flags aren't used */ /* size is uninitialized, ensure that size.flags aren't used */
size.flags = PSize; size.flags = PSize;
if (size.flags & PBaseSize) { if (size.flags & PBaseSize) {
c->basew = MAX(0, size.base_width); c->basew = size.base_width;
c->baseh = MAX(0, size.base_height); c->baseh = size.base_height;
} else if (size.flags & PMinSize) { } else if (size.flags & PMinSize) {
c->basew = MAX(0, size.min_width); c->basew = size.min_width;
c->baseh = MAX(0, size.min_height); c->baseh = size.min_height;
} else } else
c->basew = c->baseh = 0; c->basew = c->baseh = 0;
if (size.flags & PResizeInc) { if (size.flags & PResizeInc) {
c->incw = MAX(0, size.width_inc); c->incw = size.width_inc;
c->inch = MAX(0, size.height_inc); c->inch = size.height_inc;
} else } else
c->incw = c->inch = 0; c->incw = c->inch = 0;
if (size.flags & PMaxSize) { if (size.flags & PMaxSize) {
c->maxw = MAX(0, size.max_width); c->maxw = size.max_width;
c->maxh = MAX(0, size.max_height); c->maxh = size.max_height;
} else } else
c->maxw = c->maxh = 0; c->maxw = c->maxh = 0;
if (size.flags & PMinSize) { if (size.flags & PMinSize) {
c->minw = MAX(0, size.min_width); c->minw = size.min_width;
c->minh = MAX(0, size.min_height); c->minh = size.min_height;
} else if (size.flags & PBaseSize) { } else if (size.flags & PBaseSize) {
c->minw = MAX(0, size.base_width); c->minw = size.base_width;
c->minh = MAX(0, size.base_height); c->minh = size.base_height;
} else } else
c->minw = c->minh = 0; c->minw = c->minh = 0;
if ((size.flags & PAspect) && size.min_aspect.x > 0 && size.max_aspect.y > 0) { if (size.flags & PAspect) {
c->mina = (float)size.min_aspect.y / size.min_aspect.x; c->mina = (float)size.min_aspect.y / size.min_aspect.x;
c->maxa = (float)size.max_aspect.x / size.max_aspect.y; c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
} else } else
@@ -2563,41 +2496,6 @@ wintomon(Window w)
return selmon; return selmon;
} }
/* Selects for the view of the focused window. The list of tags */
/* to be displayed is matched to the focused window tag list. */
void
winview(const Arg* arg){
Window win, win_r, win_p, *win_c;
unsigned nc;
int unused;
Client* c;
Arg a;
if (!XGetInputFocus(dpy, &win, &unused)) return;
while(XQueryTree(dpy, win, &win_r, &win_p, &win_c, &nc)
&& win_p != win_r) win = win_p;
if (!(c = wintoclient(win))) return;
a.ui = c->tags;
view(&a);
}
/* by desgua */
void
gridall(const Arg *arg)
{
setlayout(&(Arg){.v = &layouts[3]});
view(&(Arg){.ui = ~0});
}
void
winviewmono(const Arg *arg)
{
winview(&(Arg){0});
setlayout(&(Arg){.v = &layouts[2]});
}
/* There's no way to check accesses to destroyed windows, thus those cases are /* There's no way to check accesses to destroyed windows, thus those cases are
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
* default error handler, which may call exit. */ * default error handler, which may call exit. */
BIN
View File
Binary file not shown.
-35
View File
@@ -1,35 +0,0 @@
void
gaplessgrid(Monitor *m) {
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
if(n == 0)
return;
/* grid dimensions */
for(cols = 0; cols <= n/2; cols++)
if(cols*cols >= n)
break;
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
rows = n/cols;
/* window geometries */
cw = cols ? m->ww / cols : m->ww;
cn = 0; /* current column number */
rn = 0; /* current row number */
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
if(i/rows + 1 > cols - n%cols)
rows = n/cols + 1;
ch = rows ? m->wh / rows : m->wh;
cx = m->wx + cn*cw;
cy = m->wy + rn*ch;
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
rn++;
if(rn >= rows) {
rn = 0;
cn++;
}
}
}
-48
View File
@@ -1,48 +0,0 @@
void
movestack(const Arg *arg) {
Client *c = NULL, *p = NULL, *pc = NULL, *i;
if(arg->i > 0) {
/* find the client after selmon->sel */
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
if(!c)
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
}
else {
/* find the client before selmon->sel */
for(i = selmon->clients; i != selmon->sel; i = i->next)
if(ISVISIBLE(i) && !i->isfloating)
c = i;
if(!c)
for(; i; i = i->next)
if(ISVISIBLE(i) && !i->isfloating)
c = i;
}
/* find the client before selmon->sel and c */
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
if(i->next == selmon->sel)
p = i;
if(i->next == c)
pc = i;
}
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
if(c && c != selmon->sel) {
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
selmon->sel->next = c->next==selmon->sel?c:c->next;
c->next = temp;
if(p && p != c)
p->next = c;
if(pc && pc != selmon->sel)
pc->next = selmon->sel;
if(selmon->sel == selmon->clients)
selmon->clients = c;
else if(c == selmon->clients)
selmon->clients = selmon->sel;
arrange(selmon);
}
}
BIN
View File
Binary file not shown.