sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

surf-middleclickplumb-20200814-5544643.diff (1989B)


      1 From 5544643861b3c7a6eec31ea413242bf224557e14 Mon Sep 17 00:00:00 2001
      2 From: 0x1bi <ben@0x1bi.net>
      3 Date: Fri, 14 Aug 2020 21:35:22 -0400
      4 Subject: [PATCH] added middle click plumb functionality
      5 
      6 ---
      7  config.def.h |  2 +-
      8  surf.c       | 12 ++++++++++++
      9  2 files changed, 13 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..04b7688 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,17 @@ 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 = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
     46 +
     47 +	arg = (Arg)PLUMB(s ? s : webkit_hit_test_result_get_link_uri(h));
     48 +	spawn(c, &arg);
     49 +}
     50 +
     51  int
     52  main(int argc, char *argv[])
     53  {
     54 -- 
     55 2.26.2
     56