surf-middleclickplumb-20200815-d068a38.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
surf-middleclickplumb-20200815-d068a38.diff (2111B)
---
1 From f675414e350d9c4face743a1bfc4af8a2cd445cd Mon Sep 17 00:00:00 2001
2 From: 0x1bi <ben@0x1bi.net>
3 Date: Sat, 15 Aug 2020 12:05:11 -0400
4 Subject: [PATCH] fix for middle click to plumb
5
6 ---
7 config.def.h | 2 +-
8 surf.c | 16 ++++++++++++++++
9 2 files changed, 17 insertions(+), 1 deletion(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 34265f6..01d040a 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -186,7 +186,7 @@ static Key keys[] = {
16 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
17 static Button buttons[] = {
18 /* target event mask button function argument stop event */
19 - { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
20 + { OnAny, 0, 2, clickplumb, { .i = 0 }, 1 },
21 { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
22 { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
23 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
24 diff --git a/surf.c b/surf.c
25 index 2b54e3c..46e6934 100644
26 --- a/surf.c
27 +++ b/surf.c
28 @@ -236,6 +236,7 @@ static void find(Client *c, const Arg *a);
29 static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
30 static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h);
31 static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h);
32 +static void clickplumb(Client *c, const Arg *a, WebKitHitTestResult *h);
33
34 static char winid[64];
35 static char togglestats[12];
36 @@ -1971,6 +1972,21 @@ clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h)
37 spawn(c, &arg);
38 }
39
40 +void
41 +clickplumb(Client *c, const Arg *a, WebKitHitTestResult *h)
42 +{
43 + Arg arg;
44 +
45 + char *s;
46 + WebKitHitTestResultContext e = webkit_hit_test_result_get_context(h);
47 + if (OnSel & e)
48 + s = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
49 + else if ((OnLink|OnMedia|OnImg) & e)
50 + s = webkit_hit_test_result_get_link_uri(h);
51 + arg = (Arg)PLUMB(s);
52 + spawn(c, &arg);
53 +}
54 +
55 int
56 main(int argc, char *argv[])
57 {
58 --
59 2.26.2
60