aboutsummarylogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
authorAvi Halachmi (:avih)2019-10-10 23:02:26 +0300
committerHiltjo Posthuma2019-10-13 21:46:31 +0200
commit3fc2e77f31762e78b0c6e8685c5d5f2c7b3e05be (patch)
tree3cf8721660b249f210e2872bc6809c061e827b78 /x.c
parent76c2fd910dd7b38653ab6db6fa9b9638a46bc339 (diff)
downloadaur-3fc2e77f31762e78b0c6e8685c5d5f2c7b3e05be.tar.gz
mouse shortcuts: allow same functions as kb shortcuts
Previously mouse shortcuts supported only ttywrite. This required adding an "Arg" function ttysend - which does what the original mouse shortcuts did.
Diffstat (limited to 'x.c')
-rw-r--r--x.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/x.c b/x.c
index 5828a3b1a42e..2a05a81435f9 100644
--- a/x.c
+++ b/x.c
@@ -29,9 +29,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 {
@@ -56,6 +57,7 @@ static void selpaste(const Arg *);
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"
@@ -312,6 +314,12 @@ zoomreset(const Arg *arg)
}
}
+void
+ttysend(const Arg *arg)
+{
+ ttywrite(arg->s, strlen(arg->s), 1);
+}
+
int
evcol(XEvent *e)
{
@@ -421,9 +429,9 @@ bpress(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;
}
}