mouse shortcuts: don't hardcode selpaste (ff828c)
This commit is contained in:
parent
ed7837a816
commit
0cdfd86e5e
|
@ -274,7 +274,12 @@ static uint forcemousemod = ShiftMask;
|
||||||
* Beware that overloading Button1 will disable the selection.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
*/
|
*/
|
||||||
static MouseShortcut mshortcuts[] = {
|
static MouseShortcut mshortcuts[] = {
|
||||||
/* mask button function argument */
|
/* mask button function argument release */
|
||||||
|
#if CLIPBOARD_PATCH
|
||||||
|
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
|
||||||
|
#else
|
||||||
|
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||||
|
#endif // CLIPBOARD_PATCH
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||||
};
|
};
|
||||||
|
|
38
x.c
38
x.c
|
@ -37,6 +37,7 @@ typedef struct {
|
||||||
uint button;
|
uint button;
|
||||||
void (*func)(const Arg *);
|
void (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
|
uint release;
|
||||||
} MouseShortcut;
|
} MouseShortcut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -200,6 +201,7 @@ static void selnotify(XEvent *);
|
||||||
static void selclear_(XEvent *);
|
static void selclear_(XEvent *);
|
||||||
static void selrequest(XEvent *);
|
static void selrequest(XEvent *);
|
||||||
static void setsel(char *, Time);
|
static void setsel(char *, Time);
|
||||||
|
static int mouseaction(XEvent *, uint);
|
||||||
static void mousesel(XEvent *, int);
|
static void mousesel(XEvent *, int);
|
||||||
static void mousereport(XEvent *);
|
static void mousereport(XEvent *);
|
||||||
static char *kmap(KeySym, uint);
|
static char *kmap(KeySym, uint);
|
||||||
|
@ -386,6 +388,24 @@ evrow(XEvent *e)
|
||||||
return y / win.ch;
|
return y / win.ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 & ~forcemousemod)) {
|
||||||
|
ms->func(&(ms->arg));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mousesel(XEvent *e, int done)
|
mousesel(XEvent *e, int done)
|
||||||
{
|
{
|
||||||
|
@ -470,7 +490,6 @@ void
|
||||||
bpress(XEvent *e)
|
bpress(XEvent *e)
|
||||||
{
|
{
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
MouseShortcut *ms;
|
|
||||||
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
MouseKey *mk;
|
MouseKey *mk;
|
||||||
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
|
@ -484,13 +503,8 @@ bpress(XEvent *e)
|
||||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
if (tisaltscr())
|
if (tisaltscr())
|
||||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
if (mouseaction(e, 0))
|
||||||
if (e->xbutton.button == ms->button &&
|
|
||||||
match(ms->mod, e->xbutton.state & ~forcemousemod)) {
|
|
||||||
ms->func(&(ms->arg));
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
|
for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
|
||||||
|
@ -725,13 +739,9 @@ brelease(XEvent *e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->xbutton.button == Button2)
|
if (mouseaction(e, 1))
|
||||||
#if CLIPBOARD_PATCH
|
return;
|
||||||
clippaste(NULL);
|
if (e->xbutton.button == Button1)
|
||||||
#else
|
|
||||||
selpaste(NULL);
|
|
||||||
#endif // CLIPBOARD_PATCH
|
|
||||||
else if (e->xbutton.button == Button1)
|
|
||||||
mousesel(e, 1);
|
mousesel(e, 1);
|
||||||
#if RIGHTCLICKTOPLUMB_PATCH
|
#if RIGHTCLICKTOPLUMB_PATCH
|
||||||
else if (e->xbutton.button == Button3)
|
else if (e->xbutton.button == Button3)
|
||||||
|
|
Loading…
Reference in New Issue