Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-keybindings-6.5.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-keybindings-6.5.diff (4787B)
---
1 diff --git a/config.def.h b/config.def.h
2 index 9efa774..5ca4a0d 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -51,6 +51,8 @@ static const Layout layouts[] = {
6 { MODKEY|ControlMask, KEY, toggleview, {.ui …
7 { MODKEY|ShiftMask, KEY, tag, {.ui …
8 { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui …
9 +#define KEYEVENT(SRC_MOD,SRC_KEY,DST_MOD,DST_KEY) \
10 + { SRC_MOD, SRC_KEY, sendkeyevent, { .v = &(const KeyBinding){ D…
11
12 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
13 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL }…
14 @@ -85,6 +87,43 @@ static const Key keys[] = {
15 { MODKEY, XK_period, focusmon, {.i …
16 { MODKEY|ShiftMask, XK_comma, tagmon, {.i …
17 { MODKEY|ShiftMask, XK_period, tagmon, {.i …
18 + // Navigation(two-handed)
19 + KEYEVENT(Mod1Mask, XK_h, 0, XK_Left)
20 + KEYEVENT(Mod1Mask, XK_l, 0, XK_Right)
21 + KEYEVENT(Mod1Mask, XK_k, 0, XK_Up)
22 + KEYEVENT(Mod1Mask, XK_j, 0, XK_Down)
23 + KEYEVENT(Mod1Mask, XK_p, 0, XK_Up)
24 + KEYEVENT(Mod1Mask, XK_n, 0, XK_Down)
25 + KEYEVENT(Mod1Mask, XK_i, ControlMask, XK_Left)
26 + KEYEVENT(Mod1Mask, XK_o, ControlMask, XK_Right)
27 + KEYEVENT(Mod1Mask, XK_equal, ControlMask, XK_Home)
28 + KEYEVENT(Mod1Mask, XK_minus, ControlMask, XK_End)
29 + // Navigation(one-handed)
30 + KEYEVENT(Mod1Mask, XK_s, 0, XK_Up)
31 + KEYEVENT(Mod1Mask, XK_x, 0, XK_Down)
32 + KEYEVENT(Mod1Mask, XK_z, 0, XK_Left)
33 + KEYEVENT(Mod1Mask, XK_c, 0, XK_Right)
34 + KEYEVENT(Mod1Mask, XK_d, 0, XK_Return)
35 + KEYEVENT(Mod1Mask, XK_a, 0, XK_Home)
36 + KEYEVENT(Mod1Mask, XK_e, 0, XK_End)
37 + // Selection(two-handed)
38 + KEYEVENT(Mod1Mask|ShiftMask, XK_h, ShiftMask, XK_Left)
39 + KEYEVENT(Mod1Mask|ShiftMask, XK_l, ShiftMask, XK_Right)
40 + KEYEVENT(Mod1Mask|ShiftMask, XK_k, ShiftMask, XK_Up)
41 + KEYEVENT(Mod1Mask|ShiftMask, XK_j, ShiftMask, XK_Down)
42 + KEYEVENT(Mod1Mask|ShiftMask, XK_p, ShiftMask, XK_Up)
43 + KEYEVENT(Mod1Mask|ShiftMask, XK_n, ShiftMask, XK_Down)
44 + KEYEVENT(Mod1Mask|ShiftMask, XK_i, ControlMask|ShiftMask, XK_Le…
45 + KEYEVENT(Mod1Mask|ShiftMask, XK_o, ControlMask|ShiftMask, XK_Ri…
46 + KEYEVENT(Mod1Mask|ShiftMask, XK_equal, ControlMask|ShiftMask, X…
47 + KEYEVENT(Mod1Mask|ShiftMask, XK_minus, ControlMask|ShiftMask, X…
48 + // Selection(one-handed)
49 + KEYEVENT(Mod1Mask|ShiftMask, XK_s, ShiftMask, XK_Up)
50 + KEYEVENT(Mod1Mask|ShiftMask, XK_x, ShiftMask, XK_Down)
51 + KEYEVENT(Mod1Mask|ShiftMask, XK_z, ShiftMask, XK_Left)
52 + KEYEVENT(Mod1Mask|ShiftMask, XK_c, ShiftMask, XK_Right)
53 + KEYEVENT(Mod1Mask|ShiftMask, XK_a, ShiftMask, XK_Home)
54 + KEYEVENT(Mod1Mask|ShiftMask, XK_e, ShiftMask, XK_End)
55 TAGKEYS( XK_1, 0)
56 TAGKEYS( XK_2, 1)
57 TAGKEYS( XK_3, 2)
58 diff --git a/dwm.c b/dwm.c
59 index 67c6b2b..b7c911d 100644
60 --- a/dwm.c
61 +++ b/dwm.c
62 @@ -106,6 +106,11 @@ typedef struct {
63 const Arg arg;
64 } Key;
65
66 +typedef struct {
67 + unsigned int mod;
68 + KeySym keysym;
69 +} KeyBinding;
70 +
71 typedef struct {
72 const char *symbol;
73 void (*arrange)(Monitor *);
74 @@ -196,6 +201,7 @@ static void restack(Monitor *m);
75 static void run(void);
76 static void scan(void);
77 static int sendevent(Client *c, Atom proto);
78 +static void sendkeyevent(const Arg *arg);
79 static void sendmon(Client *c, Monitor *m);
80 static void setclientstate(Client *c, long state);
81 static void setfocus(Client *c);
82 @@ -1467,6 +1473,47 @@ sendevent(Client *c, Atom proto)
83 return exists;
84 }
85
86 +XKeyEvent
87 +createkeyevent(Display *display, Window win, Window rootWindow, int typ…
88 +{
89 + int keysym = keyBinding->keysym;
90 + unsigned int modifier = keyBinding->mod;
91 +
92 + XKeyEvent event;
93 + event.type = type;
94 + event.display = display;
95 + event.window = win;
96 + event.root = rootWindow;
97 + event.subwindow = None;
98 + event.time = CurrentTime;
99 + event.x = 1;
100 + event.y = 1;
101 + event.x_root = 1;
102 + event.y_root = 1;
103 + event.same_screen = True;
104 + event.keycode = XKeysymToKeycode(display, keysym);
105 + event.state = modifier;
106 +
107 + return event;
108 +}
109 +
110 +void sendkeyevent(const Arg *arg)
111 +{
112 + Window rootWindow = XDefaultRootWindow(dpy);
113 +
114 + Window focusedWindow;
115 + int revert;
116 + XGetInputFocus(dpy, &focusedWindow, &revert);
117 +
118 + KeyBinding *keyBinding = (KeyBinding *)arg->v;
119 +
120 + XKeyEvent event = createkeyevent(dpy, focusedWindow, rootWindow…
121 + XSendEvent(event.display, event.window, True, KeyPressMask, (XE…
122 +
123 + event = createkeyevent(dpy, focusedWindow, rootWindow, KeyRelea…
124 + XSendEvent(event.display, event.window, True, KeyReleaseMask, (…
125 +}
126 +
127 void
128 setfocus(Client *c)
129 {
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.