sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

tabbed-keycode-0.6.diff (4750B)


      1 diff --git a/config.def.h b/config.def.h
      2 index ceda9f7..272074a 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -29,30 +29,30 @@ static Bool npisrelative  = False;
      6  
      7  #define MODKEY ControlMask
      8  static Key keys[] = { \
      9 -	/* modifier                     key        function        argument */
     10 -	{ MODKEY|ShiftMask,             XK_Return, focusonce,      { 0 } },
     11 -	{ MODKEY|ShiftMask,             XK_Return, spawn,          { 0 } },
     12 -	{ MODKEY,                       XK_t,      spawn,          SETPROP("_TABBED_SELECT_TAB") },
     13 -
     14 -	{ MODKEY|ShiftMask,             XK_l,      rotate,         { .i = +1 } },
     15 -	{ MODKEY|ShiftMask,             XK_h,      rotate,         { .i = -1 } },
     16 -	{ MODKEY|ShiftMask,             XK_j,      movetab,        { .i = -1 } },
     17 -	{ MODKEY|ShiftMask,             XK_k,      movetab,        { .i = +1 } },
     18 -	{ MODKEY,                       XK_Tab,    rotate,         { .i = 0 } },
     19 -
     20 -	{ MODKEY,                       XK_1,      move,           { .i = 0 } },
     21 -	{ MODKEY,                       XK_2,      move,           { .i = 1 } },
     22 -	{ MODKEY,                       XK_3,      move,           { .i = 2 } },
     23 -	{ MODKEY,                       XK_4,      move,           { .i = 3 } },
     24 -	{ MODKEY,                       XK_5,      move,           { .i = 4 } },
     25 -	{ MODKEY,                       XK_6,      move,           { .i = 5 } },
     26 -	{ MODKEY,                       XK_7,      move,           { .i = 6 } },
     27 -	{ MODKEY,                       XK_8,      move,           { .i = 7 } },
     28 -	{ MODKEY,                       XK_9,      move,           { .i = 8 } },
     29 -	{ MODKEY,                       XK_0,      move,           { .i = 9 } },
     30 -
     31 -	{ MODKEY,                       XK_q,      killclient,     { 0 } },
     32 -
     33 -	{ 0,                            XK_F11,    fullscreen,     { 0 } },
     34 +	/* modifier                  key    function        argument */
     35 +	{ MODKEY|ShiftMask,          36,    focusonce,      { 0 } },      // Return
     36 +	{ MODKEY|ShiftMask,          36,    spawn,          { 0 } },      // Return
     37 +	{ MODKEY,                    44,    spawn,          SETPROP("_TABBED_SELECT_TAB") }, // t
     38 +
     39 +	{ MODKEY|ShiftMask,          46,   rotate,         { .i = +1 } }, // l
     40 +	{ MODKEY|ShiftMask,          43,   rotate,         { .i = -1 } }, // h
     41 +	{ MODKEY|ShiftMask,          44,   movetab,        { .i = -1 } }, // j
     42 +	{ MODKEY|ShiftMask,          45,   movetab,        { .i = +1 } }, // k
     43 +	{ MODKEY,                    23,   rotate,         { .i = 0 } },  // Tab
     44 +
     45 +	{ MODKEY,                    10,   move,           { .i = 0 } },  // 1
     46 +	{ MODKEY,                    11,   move,           { .i = 1 } },  // 2
     47 +	{ MODKEY,                    12,   move,           { .i = 2 } },  // 3
     48 +	{ MODKEY,                    13,   move,           { .i = 3 } },  // 4
     49 +	{ MODKEY,                    14,   move,           { .i = 4 } },  // 5
     50 +	{ MODKEY,                    15,   move,           { .i = 5 } },  // 6
     51 +	{ MODKEY,                    16,   move,           { .i = 6 } },  // 7
     52 +	{ MODKEY,                    17,   move,           { .i = 7 } },  // 8
     53 +	{ MODKEY,                    18,   move,           { .i = 8 } },  // 9
     54 +	{ MODKEY,                    19,   move,           { .i = 9 } },  // 0
     55 +
     56 +	{ MODKEY,                    24,   killclient,     { 0 } },       // q
     57 +
     58 +	{ 0,                         95,   fullscreen,     { 0 } },       // F11
     59  };
     60  
     61 diff --git a/tabbed.c b/tabbed.c
     62 index d30206b..15d6572 100644
     63 --- a/tabbed.c
     64 +++ b/tabbed.c
     65 @@ -57,7 +57,7 @@ typedef union {
     66  
     67  typedef struct {
     68  	unsigned int mod;
     69 -	KeySym keysym;
     70 +	KeyCode keycode;
     71  	void (*func)(const Arg *);
     72  	const Arg arg;
     73  } Key;
     74 @@ -644,11 +644,9 @@ void
     75  keypress(const XEvent *e) {
     76  	const XKeyEvent *ev = &e->xkey;
     77  	unsigned int i;
     78 -	KeySym keysym;
     79  
     80 -	keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
     81  	for(i = 0; i < LENGTH(keys); i++) {
     82 -		if(keysym == keys[i].keysym
     83 +		if(ev->keycode == keys[i].keycode
     84  				&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
     85  				&& keys[i].func) {
     86  			keys[i].func(&(keys[i].arg));
     87 @@ -684,7 +682,6 @@ manage(Window w) {
     88  		int i, j, nextpos;
     89  		unsigned int modifiers[] = { 0, LockMask, numlockmask,
     90  			numlockmask|LockMask };
     91 -		KeyCode code;
     92  		Client *c;
     93  		XEvent e;
     94  
     95 @@ -695,13 +692,11 @@ manage(Window w) {
     96  		XSync(dpy, False);
     97  
     98  		for(i = 0; i < LENGTH(keys); i++) {
     99 -			if((code = XKeysymToKeycode(dpy, keys[i].keysym))) {
    100 -				for(j = 0; j < LENGTH(modifiers); j++) {
    101 -					XGrabKey(dpy, code, keys[i].mod
    102 -							| modifiers[j], w,
    103 -						 True, GrabModeAsync,
    104 -						 GrabModeAsync);
    105 -				}
    106 +			for(j = 0; j < LENGTH(modifiers); j++) {
    107 +				XGrabKey(dpy, keys[i].keycode, keys[i].mod
    108 +						| modifiers[j], w,
    109 +					 True, GrabModeAsync,
    110 +					 GrabModeAsync);
    111  			}
    112  		}
    113