st-scrollback-mouse-20170427-5a10aca.diff (2287B)
1 diff --git a/config.def.h b/config.def.h 2 index 3e9cda5..a9c65a9 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -156,8 +156,14 @@ unsigned int defaultattr = 11; 6 */ 7 MouseShortcut mshortcuts[] = { 8 /* button mask string */ 9 - { Button4, XK_ANY_MOD, "\031" }, 10 - { Button5, XK_ANY_MOD, "\005" }, 11 + { Button4, XK_NO_MOD, "\031" }, 12 + { Button5, XK_NO_MOD, "\005" }, 13 +}; 14 + 15 +MouseKey mkeys[] = { 16 + /* button mask function argument */ 17 + { Button4, ShiftMask, kscrollup, {.i = 1} }, 18 + { Button5, ShiftMask, kscrolldown, {.i = 1} }, 19 }; 20 21 /* Internal keyboard shortcuts. */ 22 diff --git a/st.c b/st.c 23 index b74b9dc..d33eb5b 100644 24 --- a/st.c 25 +++ b/st.c 26 @@ -237,6 +237,7 @@ static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; 27 /* config.h array lengths */ 28 size_t colornamelen = LEN(colorname); 29 size_t mshortcutslen = LEN(mshortcuts); 30 +size_t mkeyslen = LEN(mkeys); 31 size_t shortcutslen = LEN(shortcuts); 32 size_t selmaskslen = LEN(selmasks); 33 34 diff --git a/st.h b/st.h 35 index 2d9b028..ca90c31 100644 36 --- a/st.h 37 +++ b/st.h 38 @@ -182,6 +182,13 @@ typedef union { 39 } Arg; 40 41 typedef struct { 42 + uint b; 43 + uint mask; 44 + void (*func)(const Arg *); 45 + const Arg arg; 46 +} MouseKey; 47 + 48 +typedef struct { 49 uint mod; 50 KeySym keysym; 51 void (*func)(const Arg *); 52 @@ -271,6 +278,8 @@ extern unsigned int mousebg; 53 extern unsigned int defaultattr; 54 extern MouseShortcut mshortcuts[]; 55 extern size_t mshortcutslen; 56 +extern MouseKey mkeys[]; 57 +extern size_t mkeyslen; 58 extern Shortcut shortcuts[]; 59 extern size_t shortcutslen; 60 extern uint forceselmod; 61 diff --git a/x.c b/x.c 62 index 495cd90..67dcfdc 100644 63 --- a/x.c 64 +++ b/x.c 65 @@ -248,6 +248,7 @@ bpress(XEvent *e) 66 { 67 struct timespec now; 68 MouseShortcut *ms; 69 + MouseKey *mk; 70 71 if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { 72 mousereport(e); 73 @@ -262,6 +263,14 @@ bpress(XEvent *e) 74 } 75 } 76 77 + for (mk = mkeys; mk < mkeys + mkeyslen; mk++) { 78 + if (e->xbutton.button == mk->b 79 + && match(mk->mask, e->xbutton.state)) { 80 + mk->func(&mk->arg); 81 + return; 82 + } 83 + } 84 + 85 if (e->xbutton.button == Button1) { 86 clock_gettime(CLOCK_MONOTONIC, &now); 87