Previously mouse shortcuts supported only ttywrite.
This required adding an "Arg" function ttysend - which does what the
original mouse shortcuts did.
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
- /* button mask string */
- { Button4, XK_ANY_MOD, "\031" },
- { Button5, XK_ANY_MOD, "\005" },
+ /* mask button function argument */
+ { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
+ { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
/* Internal keyboard shortcuts. */
uint ui;
float f;
const void *v;
+ const char *s;
} Arg;
void die(const char *, ...);
} Shortcut;
typedef struct {
- uint b;
- uint mask;
- char *s;
+ uint mod;
+ uint button;
+ void (*func)(const Arg *);
+ const Arg arg;
} MouseShortcut;
typedef struct {
static void zoom(const Arg *);
static void zoomabs(const Arg *);
static void zoomreset(const Arg *);
+static void ttysend(const Arg *);
/* config.h for applying patches and the configuration. */
#include "config.h"
}
}
+void
+ttysend(const Arg *arg)
+{
+ ttywrite(arg->s, strlen(arg->s), 1);
+}
+
int
evcol(XEvent *e)
{
}
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;
}
}