mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
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.
|
||||
*/
|
||||
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, Button5, ttysend, {.s = "\005"} },
|
||||
};
|
||||
|
40
x.c
40
x.c
@ -37,6 +37,7 @@ typedef struct {
|
||||
uint button;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
uint release;
|
||||
} MouseShortcut;
|
||||
|
||||
typedef struct {
|
||||
@ -200,6 +201,7 @@ static void selnotify(XEvent *);
|
||||
static void selclear_(XEvent *);
|
||||
static void selrequest(XEvent *);
|
||||
static void setsel(char *, Time);
|
||||
static int mouseaction(XEvent *, uint);
|
||||
static void mousesel(XEvent *, int);
|
||||
static void mousereport(XEvent *);
|
||||
static char *kmap(KeySym, uint);
|
||||
@ -386,6 +388,24 @@ evrow(XEvent *e)
|
||||
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
|
||||
mousesel(XEvent *e, int done)
|
||||
{
|
||||
@ -470,7 +490,6 @@ void
|
||||
bpress(XEvent *e)
|
||||
{
|
||||
struct timespec now;
|
||||
MouseShortcut *ms;
|
||||
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
MouseKey *mk;
|
||||
#endif // SCROLLBACK_MOUSE_PATCH / SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
@ -484,13 +503,8 @@ bpress(XEvent *e)
|
||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
if (tisaltscr())
|
||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
||||
if (e->xbutton.button == ms->button &&
|
||||
match(ms->mod, e->xbutton.state & ~forcemousemod)) {
|
||||
ms->func(&(ms->arg));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mouseaction(e, 0))
|
||||
return;
|
||||
|
||||
#if SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
|
||||
@ -725,13 +739,9 @@ brelease(XEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->xbutton.button == Button2)
|
||||
#if CLIPBOARD_PATCH
|
||||
clippaste(NULL);
|
||||
#else
|
||||
selpaste(NULL);
|
||||
#endif // CLIPBOARD_PATCH
|
||||
else if (e->xbutton.button == Button1)
|
||||
if (mouseaction(e, 1))
|
||||
return;
|
||||
if (e->xbutton.button == Button1)
|
||||
mousesel(e, 1);
|
||||
#if RIGHTCLICKTOPLUMB_PATCH
|
||||
else if (e->xbutton.button == Button3)
|
||||
|
Loading…
Reference in New Issue
Block a user