From a5435903d4eceea128fdb159489339d42600c191 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 8 May 2021 17:49:04 +0200 Subject: [PATCH] Adding universcroll patch ref. #21 --- README.md | 6 +++++- config.def.h | 7 +++++++ patch/scrollback.c | 7 ------- patch/scrollback.h | 4 ---- patch/st_include.c | 3 +++ patch/st_include.h | 3 +++ patch/universcroll.c | 5 +++++ patch/universcroll.h | 1 + patches.def.h | 6 ++++++ st.h | 3 +++ x.c | 3 +++ 11 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 patch/universcroll.c create mode 100644 patch/universcroll.h diff --git a/README.md b/README.md index 6607130..75e5115 100644 --- 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 index 0834aef..84a639d 100644 --- 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 index 4eb4fd0..71a1854 100644 --- 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 index 5d39d03..08940f0 100644 --- 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 index 6f51d14..b33e975 100644 --- 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 index 9c9aadd..3dc496d 100644 --- 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 new file mode 100644 index 0000000..dfa3a61 --- /dev/null +++ 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 new file mode 100644 index 0000000..b34d653 --- /dev/null +++ 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 index de585b7..7336e96 100644 --- 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 index b2128bf..c4d99c9 100644 --- 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 index 385f0de..c8fffe0 100644 --- 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));