mouse shortcuts: allow same functions as kb shortcuts (410651)

This commit is contained in:
bakkeby 2020-03-24 14:02:07 +01:00
parent 4aa6989993
commit 584f3928ad
3 changed files with 20 additions and 16 deletions

View File

@ -267,14 +267,9 @@ ResourcePref resources[] = {
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* button mask string */
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
{ Button4, XK_NO_MOD, "\031" },
{ Button5, XK_NO_MOD, "\005" },
#else
{ Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" },
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
/* mask button function argument */
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH

1
st.h
View File

@ -78,6 +78,7 @@ typedef union {
uint ui;
float f;
const void *v;
const char *s;
} Arg;
void die(const char *, ...);

24
x.c
View File

@ -33,9 +33,10 @@ typedef struct {
} Shortcut;
typedef struct {
uint b;
uint mask;
char *s;
uint mod;
uint button;
void (*func)(const Arg *);
const Arg arg;
} MouseShortcut;
typedef struct {
@ -57,6 +58,7 @@ static void clipcopy(const Arg *);
static void clippaste(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
static void ttysend(const Arg *);
static void zoom(const Arg *);
static void zoomabs(const Arg *);
static void zoomreset(const Arg *);
@ -308,6 +310,12 @@ clippaste(const Arg *dummy)
xw.win, CurrentTime);
}
void
numlock(const Arg *dummy)
{
win.mode ^= MODE_NUMLOCK;
}
void
selpaste(const Arg *dummy)
{
@ -316,9 +324,9 @@ selpaste(const Arg *dummy)
}
void
numlock(const Arg *dummy)
ttysend(const Arg *arg)
{
win.mode ^= MODE_NUMLOCK;
ttywrite(arg->s, strlen(arg->s), 1);
}
void
@ -477,9 +485,9 @@ bpress(XEvent *e)
if (tisaltscr())
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
if (e->xbutton.button == ms->b
&& match(ms->mask, e->xbutton.state)) {
ttywrite(ms->s, strlen(ms->s), 1);
if (e->xbutton.button == ms->button
&& match(ms->mod, e->xbutton.state)) {
ms->func(&(ms->arg));
return;
}
}