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. * Beware that overloading Button1 will disable the selection.
*/ */
static MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* button mask string */ /* mask button function argument */
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
{ Button4, XK_NO_MOD, "\031" }, { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
{ Button5, XK_NO_MOD, "\005" },
#else
{ Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" },
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
}; };
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH #if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH

1
st.h
View File

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

24
x.c
View File

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