summaryrefslogtreecommitdiff
path: root/patches/st-scrollback-mouse-20161020-6e79e83.diff
blob: 05b8b458be607330a81b04053478f9f2450053dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
diff --git a/config.def.h b/config.def.h
index eae969e..34ebb44 100644
--- a/config.def.h
+++ b/config.def.h
@@ -152,8 +152,14 @@ static unsigned int defaultunderline = 7;
  */
 static MouseShortcut mshortcuts[] = {
 	/* button               mask            string */
-	{ Button4,              XK_ANY_MOD,     "\031" },
-	{ Button5,              XK_ANY_MOD,     "\005" },
+	{ Button4,              XK_NO_MOD,      "\031" },
+	{ Button5,              XK_NO_MOD,      "\005" },
+};
+
+static MouseKey mkeys[] = {
+	/* button               mask            function        argument */
+	{ Button4,              ShiftMask,      kscrollup,      {.i =  1} },
+	{ Button5,              ShiftMask,      kscrolldown,    {.i =  1} },
 };
 
 /* Internal keyboard shortcuts. */
diff --git a/st.c b/st.c
index 233d301..c71b6e7 100644
--- a/st.c
+++ b/st.c
@@ -299,6 +299,13 @@ typedef union {
 	const void *v;
 } Arg;
 
+typedef struct {
+	uint b;
+	uint mask;
+	void (*func)(const Arg *);
+	const Arg arg;
+} MouseKey;
+
 typedef struct {
 	uint mod;
 	KeySym keysym;
@@ -953,6 +960,7 @@ bpress(XEvent *e)
 {
 	struct timespec now;
 	MouseShortcut *ms;
+	MouseKey *mk;
 
 	if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
 		mousereport(e);
@@ -967,6 +975,14 @@ bpress(XEvent *e)
 		}
 	}
 
+	for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
+		if (e->xbutton.button == mk->b
+				&& match(mk->mask, e->xbutton.state)) {
+			mk->func(&mk->arg);
+			return;
+		}
+	}
+
 	if (e->xbutton.button == Button1) {
 		clock_gettime(CLOCK_MONOTONIC, &now);