Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
mouse shortcuts: allow override for all shortcuts
[st.git]
/
x.c
diff --git
a/x.c
b/x.c
index
2cd76d0
..
c967caf
100644
(file)
--- a/
x.c
+++ b/
x.c
@@
-29,9
+29,10
@@
typedef struct {
} Shortcut;
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 {
} 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 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"
/* 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)
{
int
evcol(XEvent *e)
{
@@
-332,7
+340,7
@@
void
mousesel(XEvent *e, int done)
{
int type, seltype = SEL_REGULAR;
mousesel(XEvent *e, int done)
{
int type, seltype = SEL_REGULAR;
- uint state = e->xbutton.state & ~(Button1Mask | force
sel
mod);
+ uint state = e->xbutton.state & ~(Button1Mask | force
mouse
mod);
for (type = 1; type < LEN(selmasks); ++type) {
if (match(selmasks[type], state)) {
for (type = 1; type < LEN(selmasks); ++type) {
if (match(selmasks[type], state)) {
@@
-415,15
+423,15
@@
bpress(XEvent *e)
MouseShortcut *ms;
int snap;
MouseShortcut *ms;
int snap;
- if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
sel
mod)) {
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
mouse
mod)) {
mousereport(e);
return;
}
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
mousereport(e);
return;
}
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->b
utton &&
+
match(ms->mod, e->xbutton.state & ~forcemousemod
)) {
+
ms->func(&(ms->arg)
);
return;
}
}
return;
}
}
@@
-642,7
+650,7
@@
xsetsel(char *str)
void
brelease(XEvent *e)
{
void
brelease(XEvent *e)
{
- if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
sel
mod)) {
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
mouse
mod)) {
mousereport(e);
return;
}
mousereport(e);
return;
}
@@
-656,7
+664,7
@@
brelease(XEvent *e)
void
bmotion(XEvent *e)
{
void
bmotion(XEvent *e)
{
- if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
sel
mod)) {
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & force
mouse
mod)) {
mousereport(e);
return;
}
mousereport(e);
return;
}
@@
-763,7
+771,6
@@
xsetcolorname(int x, const char *name)
if (!BETWEEN(x, 0, dc.collen))
return 1;
if (!BETWEEN(x, 0, dc.collen))
return 1;
-
if (!xloadcolor(x, name, &ncolor))
return 1;
if (!xloadcolor(x, name, &ncolor))
return 1;
@@
-1244,15
+1251,10
@@
xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
fontpattern = FcFontSetMatch(0, fcsets, 1,
fcpattern, &fcres);
fontpattern = FcFontSetMatch(0, fcsets, 1,
fcpattern, &fcres);
- /*
- * Allocate memory for the new cache entry.
- */
+ /* Allocate memory for the new cache entry. */
if (frclen >= frccap) {
frccap += 16;
if (frclen >= frccap) {
frccap += 16;
- if (!frc)
- frc = xmalloc(frccap * sizeof(Fontcache));
- else
- frc = xrealloc(frc, frccap * sizeof(Fontcache));
+ frc = xrealloc(frc, frccap * sizeof(Fontcache));
}
frc[frclen].font = XftFontOpenPattern(xw.dpy,
}
frc[frclen].font = XftFontOpenPattern(xw.dpy,
@@
-1769,7
+1771,6
@@
kpress(XEvent *ev)
ttywrite(buf, len, 1);
}
ttywrite(buf, len, 1);
}
-
void
cmessage(XEvent *e)
{
void
cmessage(XEvent *e)
{