|
|
@ -29,9 +29,11 @@ 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; |
|
|
|
|
|
|
|
uint release; |
|
|
|
} MouseShortcut; |
|
|
|
} MouseShortcut; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
@ -56,6 +58,7 @@ static void selpaste(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 *); |
|
|
|
|
|
|
|
static void ttysend(const Arg *); |
|
|
|
|
|
|
|
|
|
|
|
/* config.h for applying patches and the configuration. */ |
|
|
|
/* config.h for applying patches and the configuration. */ |
|
|
|
#include "config.h" |
|
|
|
#include "config.h" |
|
|
@ -163,6 +166,7 @@ static void kpress(XEvent *); |
|
|
|
static void cmessage(XEvent *); |
|
|
|
static void cmessage(XEvent *); |
|
|
|
static void resize(XEvent *); |
|
|
|
static void resize(XEvent *); |
|
|
|
static void focus(XEvent *); |
|
|
|
static void focus(XEvent *); |
|
|
|
|
|
|
|
static int mouseaction(XEvent *, uint); |
|
|
|
static void brelease(XEvent *); |
|
|
|
static void brelease(XEvent *); |
|
|
|
static void bpress(XEvent *); |
|
|
|
static void bpress(XEvent *); |
|
|
|
static void bmotion(XEvent *); |
|
|
|
static void bmotion(XEvent *); |
|
|
@ -312,6 +316,12 @@ zoomreset(const Arg *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
ttysend(const Arg *arg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ttywrite(arg->s, strlen(arg->s), 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
int |
|
|
|
evcol(XEvent *e) |
|
|
|
evcol(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -332,7 +342,7 @@ void |
|
|
|
mousesel(XEvent *e, int done) |
|
|
|
mousesel(XEvent *e, int done) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int type, seltype = SEL_REGULAR; |
|
|
|
int type, seltype = SEL_REGULAR; |
|
|
|
uint state = e->xbutton.state & ~(Button1Mask | forceselmod); |
|
|
|
uint state = e->xbutton.state & ~(Button1Mask | forcemousemod); |
|
|
|
|
|
|
|
|
|
|
|
for (type = 1; type < LEN(selmasks); ++type) { |
|
|
|
for (type = 1; type < LEN(selmasks); ++type) { |
|
|
|
if (match(selmasks[type], state)) { |
|
|
|
if (match(selmasks[type], state)) { |
|
|
@ -408,34 +418,37 @@ mousereport(XEvent *e) |
|
|
|
ttywrite(buf, len, 0); |
|
|
|
ttywrite(buf, len, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
|
|
|
mouseaction(XEvent *e, uint release) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MouseShortcut *ms; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { |
|
|
|
|
|
|
|
if (ms->release == release && |
|
|
|
|
|
|
|
ms->button == e->xbutton.button && |
|
|
|
|
|
|
|
(match(ms->mod, e->xbutton.state) || /* exact or forced */ |
|
|
|
|
|
|
|
match(ms->mod, e->xbutton.state & ~forcemousemod))) { |
|
|
|
|
|
|
|
ms->func(&(ms->arg)); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
bpress(XEvent *e) |
|
|
|
bpress(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct timespec now; |
|
|
|
struct timespec now; |
|
|
|
MouseShortcut *ms; |
|
|
|
|
|
|
|
MouseKey *mk; |
|
|
|
|
|
|
|
int snap; |
|
|
|
int snap; |
|
|
|
|
|
|
|
|
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { |
|
|
|
mousereport(e); |
|
|
|
mousereport(e); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { |
|
|
|
if (mouseaction(e, 0)) |
|
|
|
if (e->xbutton.button == ms->b |
|
|
|
|
|
|
|
&& match(ms->mask, e->xbutton.state)) { |
|
|
|
|
|
|
|
ttywrite(ms->s, strlen(ms->s), 1); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) { |
|
|
|
|
|
|
|
if (e->xbutton.button == mk->b |
|
|
|
|
|
|
|
&& match(mk->mask, e->xbutton.state)) { |
|
|
|
|
|
|
|
mk->func(&mk->arg); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e->xbutton.button == Button1) { |
|
|
|
if (e->xbutton.button == Button1) { |
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -652,21 +665,21 @@ xsetsel(char *str) |
|
|
|
void |
|
|
|
void |
|
|
|
brelease(XEvent *e) |
|
|
|
brelease(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { |
|
|
|
mousereport(e); |
|
|
|
mousereport(e); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e->xbutton.button == Button2) |
|
|
|
if (mouseaction(e, 1)) |
|
|
|
selpaste(NULL); |
|
|
|
return; |
|
|
|
else if (e->xbutton.button == Button1) |
|
|
|
if (e->xbutton.button == Button1) |
|
|
|
mousesel(e, 1); |
|
|
|
mousesel(e, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
bmotion(XEvent *e) |
|
|
|
bmotion(XEvent *e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
|
|
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { |
|
|
|
mousereport(e); |
|
|
|
mousereport(e); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1142,8 +1155,8 @@ xinit(int cols, int rows) |
|
|
|
|
|
|
|
|
|
|
|
win.mode = MODE_NUMLOCK; |
|
|
|
win.mode = MODE_NUMLOCK; |
|
|
|
resettitle(); |
|
|
|
resettitle(); |
|
|
|
XMapWindow(xw.dpy, xw.win); |
|
|
|
|
|
|
|
xhints(); |
|
|
|
xhints(); |
|
|
|
|
|
|
|
XMapWindow(xw.dpy, xw.win); |
|
|
|
XSync(xw.dpy, False); |
|
|
|
XSync(xw.dpy, False); |
|
|
|
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1); |
|
|
|
clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1); |
|
|
|