2017-01-30 05:59:15 +00:00
|
|
|
diff --git a/config.def.h b/config.def.h
|
2018-04-25 20:15:11 +00:00
|
|
|
index 27d42ca..feec7e2 100644
|
2017-01-30 05:59:15 +00:00
|
|
|
--- a/config.def.h
|
|
|
|
+++ b/config.def.h
|
2018-04-25 20:15:11 +00:00
|
|
|
@@ -156,8 +156,14 @@ static unsigned int defaultattr = 11;
|
2017-01-30 05:59:15 +00:00
|
|
|
*/
|
|
|
|
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" },
|
|
|
|
+};
|
|
|
|
+
|
2018-04-25 20:15:11 +00:00
|
|
|
+MouseKey mkeys[] = {
|
2017-01-30 05:59:15 +00:00
|
|
|
+ /* button mask function argument */
|
|
|
|
+ { Button4, ShiftMask, kscrollup, {.i = 1} },
|
|
|
|
+ { Button5, ShiftMask, kscrolldown, {.i = 1} },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Internal keyboard shortcuts. */
|
2018-04-25 20:15:11 +00:00
|
|
|
diff --git a/st.h b/st.h
|
|
|
|
index 628e876..cdd25ae 100644
|
|
|
|
--- a/st.h
|
|
|
|
+++ b/st.h
|
|
|
|
@@ -81,6 +81,13 @@ typedef union {
|
2017-01-30 05:59:15 +00:00
|
|
|
const void *v;
|
|
|
|
} Arg;
|
|
|
|
|
|
|
|
+typedef struct {
|
|
|
|
+ uint b;
|
|
|
|
+ uint mask;
|
|
|
|
+ void (*func)(const Arg *);
|
|
|
|
+ const Arg arg;
|
|
|
|
+} MouseKey;
|
|
|
|
+
|
2018-04-25 20:15:11 +00:00
|
|
|
void die(const char *, ...);
|
|
|
|
void redraw(void);
|
|
|
|
void draw(void);
|
|
|
|
@@ -129,3 +136,4 @@ extern char *termname;
|
|
|
|
extern unsigned int tabspaces;
|
|
|
|
extern unsigned int defaultfg;
|
|
|
|
extern unsigned int defaultbg;
|
|
|
|
+extern MouseKey mkeys[];
|
|
|
|
diff --git a/x.c b/x.c
|
|
|
|
index d43a529..754d859 100644
|
|
|
|
--- a/x.c
|
|
|
|
+++ b/x.c
|
|
|
|
@@ -409,6 +409,7 @@ bpress(XEvent *e)
|
2017-01-30 05:59:15 +00:00
|
|
|
{
|
|
|
|
struct timespec now;
|
|
|
|
MouseShortcut *ms;
|
|
|
|
+ MouseKey *mk;
|
2018-04-25 20:15:11 +00:00
|
|
|
int snap;
|
2017-01-30 05:59:15 +00:00
|
|
|
|
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
|
2018-04-25 20:15:11 +00:00
|
|
|
@@ -424,6 +425,14 @@ bpress(XEvent *e)
|
2017-01-30 05:59:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ 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) {
|
2018-04-25 20:15:11 +00:00
|
|
|
/*
|
|
|
|
* If the user clicks below predefined timeouts specific
|