Adding universcroll patch ref. #21

This commit is contained in:
bakkeby 2021-05-08 17:49:04 +02:00
parent a1303a8811
commit a5435903d4
11 changed files with 36 additions and 12 deletions

View File

@ -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

View File

@ -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~"} },

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

5
patch/universcroll.c Normal file
View File

@ -0,0 +1,5 @@
int
tisaltscr(void)
{
return IS_SET(MODE_ALTSCREEN);
}

1
patch/universcroll.h Normal file
View File

@ -0,0 +1 @@
int tisaltscr(void);

View File

@ -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/
*/

3
st.h
View File

@ -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 {

3
x.c
View File

@ -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));