commit a5435903d4eceea128fdb159489339d42600c191
parent a1303a881129f8e06604e57ff514d1316a92c95d
Author: bakkeby <bakkeby@gmail.com>
Date: Sat, 8 May 2021 17:49:04 +0200
Adding universcroll patch ref. #21
Diffstat:
11 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -15,7 +15,7 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
-2021-05-08 - Added blinking cursor, delkey, undercurl, desktopentry, netwmicon and osc_10_11_12_2 patches
+2021-05-08 - Added blinking cursor, delkey, undercurl,universcroll, desktopentry, netwmicon and osc_10_11_12_2 patches
2021-05-07 - Added xresources reload patch
@@ -190,6 +190,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [undercurl](https://st.suckless.org/patches/undercurl/)
- adds support for special underlines, e.g. curly / wavy underlines
+ - [universcroll](https://st.suckless.org/patches/universcroll/)
+ - allows mouse scroll without modifier keys for regardless of alt screen using the external
+ scroll program
+
- [vertcenter](https://st.suckless.org/patches/vertcenter/)
- vertically center lines in the space available if you have set a larger chscale in config.h
diff --git a/config.def.h b/config.def.h
@@ -286,7 +286,11 @@ static uint forcemousemod = ShiftMask;
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
+ #if UNIVERSCROLL_PATCH
+ /* mask button function argument release alt */
+ #else
/* mask button function argument release */
+ #endif // UNIVERSCROLL_PATCH
#if CLIPBOARD_PATCH
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
#else
@@ -295,6 +299,9 @@ static MouseShortcut mshortcuts[] = {
#if SCROLLBACK_MOUSE_PATCH
{ ShiftMask, Button4, kscrollup, {.i = 1} },
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
+ #elif UNIVERSCROLL_PATCH
+ { XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, -1 },
+ { XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, -1 },
#else
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
diff --git a/patch/scrollback.c b/patch/scrollback.c
@@ -29,10 +29,3 @@ kscrollup(const Arg* a)
tfulldirt();
}
}
-
-#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
-int tisaltscr(void)
-{
- return IS_SET(MODE_ALTSCREEN);
-}
-#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
-\ No newline at end of file
diff --git a/patch/scrollback.h b/patch/scrollback.h
@@ -15,7 +15,3 @@ typedef struct {
extern MouseKey mkeys[];
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
-
-#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
-int tisaltscr(void);
-#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
-\ No newline at end of file
diff --git a/patch/st_include.c b/patch/st_include.c
@@ -20,6 +20,9 @@
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
#include "scrollback.c"
#endif
+#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
+#include "universcroll.c"
+#endif
#if SIXEL_PATCH
#include "sixel_st.c"
#endif
\ No newline at end of file
diff --git a/patch/st_include.h b/patch/st_include.h
@@ -20,6 +20,9 @@
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
#include "scrollback.h"
#endif
+#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
+#include "universcroll.h"
+#endif
#if SIXEL_PATCH
#include "sixel_st.h"
#endif
\ No newline at end of file
diff --git a/patch/universcroll.c b/patch/universcroll.c
@@ -0,0 +1,5 @@
+int
+tisaltscr(void)
+{
+ return IS_SET(MODE_ALTSCREEN);
+}
+\ No newline at end of file
diff --git a/patch/universcroll.h b/patch/universcroll.h
@@ -0,0 +1 @@
+int tisaltscr(void);
+\ No newline at end of file
diff --git a/patches.def.h b/patches.def.h
@@ -292,6 +292,12 @@
*/
#define UNDERCURL_PATCH 0
+/* Allows mouse scroll without modifier keys for regardless of alt screen using the external
+ * scroll program.
+ * https://st.suckless.org/patches/universcroll/
+ */
+#define UNIVERSCROLL_PATCH 0
+
/* Vertically center lines in the space available if you have set a larger chscale in config.h
* https://st.suckless.org/patches/vertcenter/
*/
diff --git a/st.h b/st.h
@@ -243,6 +243,9 @@ typedef struct {
void (*func)(const Arg *);
const Arg arg;
uint release;
+ #if UNIVERSCROLL_PATCH
+ int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
+ #endif // UNIVERSCROLL_PATCH
} MouseShortcut;
typedef struct {
diff --git a/x.c b/x.c
@@ -334,6 +334,9 @@ mouseaction(XEvent *e, uint release)
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
if (ms->release == release &&
ms->button == e->xbutton.button &&
+ #if UNIVERSCROLL_PATCH
+ (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
+ #endif // UNIVERSCROLL_PATCH
(match(ms->mod, state) || /* exact or forced */
match(ms->mod, state & ~forcemousemod))) {
ms->func(&(ms->arg));