dwm-keycodes-6.1.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-keycodes-6.1.diff (6731B)
       ---
            1 diff --git a/config.def.h b/config.def.h
            2 index 7054c06..f59d1eb 100644
            3 --- a/config.def.h
            4 +++ b/config.def.h
            5 @@ -58,40 +58,40 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont,
            6  static const char *termcmd[]  = { "st", NULL };
            7  
            8  static Key keys[] = {
            9 -        /* modifier                     key        function        argument */
           10 -        { MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
           11 -        { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
           12 -        { MODKEY,                       XK_b,      togglebar,      {0} },
           13 -        { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
           14 -        { MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
           15 -        { MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
           16 -        { MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
           17 -        { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
           18 -        { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
           19 -        { MODKEY,                       XK_Return, zoom,           {0} },
           20 -        { MODKEY,                       XK_Tab,    view,           {0} },
           21 -        { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
           22 -        { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
           23 -        { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
           24 -        { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
           25 -        { MODKEY,                       XK_space,  setlayout,      {0} },
           26 -        { MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
           27 -        { MODKEY,                       XK_0,      view,           {.ui = ~0 } },
           28 -        { MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
           29 -        { MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
           30 -        { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
           31 -        { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
           32 -        { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
           33 -        TAGKEYS(                        XK_1,                      0)
           34 -        TAGKEYS(                        XK_2,                      1)
           35 -        TAGKEYS(                        XK_3,                      2)
           36 -        TAGKEYS(                        XK_4,                      3)
           37 -        TAGKEYS(                        XK_5,                      4)
           38 -        TAGKEYS(                        XK_6,                      5)
           39 -        TAGKEYS(                        XK_7,                      6)
           40 -        TAGKEYS(                        XK_8,                      7)
           41 -        TAGKEYS(                        XK_9,                      8)
           42 -        { MODKEY|ShiftMask,             XK_q,      quit,           {0} },
           43 +        /* modifier             key    function        argument */
           44 +        { MODKEY,               33,    spawn,          {.v = dmenucmd } }, // p
           45 +        { MODKEY|ShiftMask,     36,    spawn,          {.v = termcmd } }, // Return
           46 +        { MODKEY,               56,    togglebar,      {0} },             // b
           47 +        { MODKEY,               44,    focusstack,     {.i = +1 } },      // j
           48 +        { MODKEY,               45,    focusstack,     {.i = -1 } },      // k
           49 +        { MODKEY,               31,    incnmaster,     {.i = +1 } },      // i
           50 +        { MODKEY,               40,    incnmaster,     {.i = -1 } },      // d
           51 +        { MODKEY,               43,    setmfact,       {.f = -0.05} },    // h
           52 +        { MODKEY,               46,    setmfact,       {.f = +0.05} },    // l
           53 +        { MODKEY,               36,    zoom,           {0} },             // Return
           54 +        { MODKEY,               23,    view,           {0} },             // Tab
           55 +        { MODKEY|ShiftMask,     54,    killclient,     {0} },             // c
           56 +        { MODKEY,               28,    setlayout,      {.v = &layouts[0]} }, // t
           57 +        { MODKEY,               41,    setlayout,      {.v = &layouts[1]} }, // f
           58 +        { MODKEY,               58,    setlayout,      {.v = &layouts[2]} }, // m
           59 +        { MODKEY,               65,    setlayout,      {0} },             // space
           60 +        { MODKEY|ShiftMask,     65,    togglefloating, {0} },             // space
           61 +        { MODKEY,               19,    view,           {.ui = ~0 } },     // 0
           62 +        { MODKEY|ShiftMask,     19,    tag,            {.ui = ~0 } },     // 0
           63 +        { MODKEY,               59,    focusmon,       {.i = -1 } },      // comma
           64 +        { MODKEY,               60,    focusmon,       {.i = +1 } },      // period
           65 +        { MODKEY|ShiftMask,     59,    tagmon,         {.i = -1 } },      // comma
           66 +        { MODKEY|ShiftMask,     60,    tagmon,         {.i = +1 } },      // period
           67 +        TAGKEYS(                10,                    0)                 // 1
           68 +        TAGKEYS(                11,                    1)                 // 2
           69 +        TAGKEYS(                12,                    2)                 // 3
           70 +        TAGKEYS(                13,                    3)                 // 4
           71 +        TAGKEYS(                14,                    4)                 // 5
           72 +        TAGKEYS(                15,                    5)                 // 6
           73 +        TAGKEYS(                16,                    6)                 // 7
           74 +        TAGKEYS(                17,                    7)                 // 8
           75 +        TAGKEYS(                18,                    8)                 // 9
           76 +        { MODKEY|ShiftMask,     24,    quit,           {0} },             // q
           77  };
           78  
           79  /* button definitions */
           80 diff --git a/dwm.c b/dwm.c
           81 index 0362114..60dd817 100644
           82 --- a/dwm.c
           83 +++ b/dwm.c
           84 @@ -31,7 +31,6 @@
           85  #include <sys/types.h>
           86  #include <sys/wait.h>
           87  #include <X11/cursorfont.h>
           88 -#include <X11/keysym.h>
           89  #include <X11/Xatom.h>
           90  #include <X11/Xlib.h>
           91  #include <X11/Xproto.h>
           92 @@ -101,7 +100,7 @@ struct Client {
           93  
           94  typedef struct {
           95          unsigned int mod;
           96 -        KeySym keysym;
           97 +        KeyCode keycode;
           98          void (*func)(const Arg *);
           99          const Arg arg;
          100  } Key;
          101 @@ -967,14 +966,12 @@ grabkeys(void)
          102          {
          103                  unsigned int i, j;
          104                  unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
          105 -                KeyCode code;
          106  
          107                  XUngrabKey(dpy, AnyKey, AnyModifier, root);
          108                  for (i = 0; i < LENGTH(keys); i++)
          109 -                        if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
          110 -                                for (j = 0; j < LENGTH(modifiers); j++)
          111 -                                        XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
          112 -                                                 True, GrabModeAsync, GrabModeAsync);
          113 +                        for (j = 0; j < LENGTH(modifiers); j++)
          114 +                                XGrabKey(dpy, keys[i].keycode, keys[i].mod | modifiers[j], root,
          115 +                                         True, GrabModeAsync, GrabModeAsync);
          116          }
          117  }
          118  
          119 @@ -1001,13 +998,11 @@ void
          120  keypress(XEvent *e)
          121  {
          122          unsigned int i;
          123 -        KeySym keysym;
          124          XKeyEvent *ev;
          125  
          126          ev = &e->xkey;
          127 -        keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
          128          for (i = 0; i < LENGTH(keys); i++)
          129 -                if (keysym == keys[i].keysym
          130 +                if (ev->keycode == keys[i].keycode
          131                  && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
          132                  && keys[i].func)
          133                          keys[i].func(&(keys[i].arg));