surf

Mahdi's build of surf
git clone git://mahdi.pw/surf.git
Log | Files | Refs | README | LICENSE

surf-clipboard-20200112-a6a8878.diff (1924B)


      1 From a6a8878bb6a203b589d559025b94a78214f22878 Mon Sep 17 00:00:00 2001
      2 From: Olivier Moreau <[email protected]>
      3 Date: Sun, 12 Jan 2020 11:23:11 +0000
      4 Subject: [PATCH] Added choice between PRIMARY and CLIPBOARD Gtk selections, as
      5  a config option
      6 
      7 ---
      8  config.def.h |  1 +
      9  surf.c       | 11 +++++++++--
     10  2 files changed, 10 insertions(+), 2 deletions(-)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 34265f6..03bbe2b 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -48,6 +48,7 @@ static Parameter defconfig[ParameterLast] = {
     17  	[Style]               =       { { .i = 1 },     },
     18  	[WebGL]               =       { { .i = 0 },     },
     19  	[ZoomLevel]           =       { { .f = 1.0 },   },
     20 +	[ClipboardNotPrimary] =				{ { .i = 1 },			},
     21  };
     22  
     23  static UriParameters uriparams[] = {
     24 diff --git a/surf.c b/surf.c
     25 index 2b54e3c..b8a9b2f 100644
     26 --- a/surf.c
     27 +++ b/surf.c
     28 @@ -82,6 +82,7 @@ typedef enum {
     29  	Style,
     30  	WebGL,
     31  	ZoomLevel,
     32 +	ClipboardNotPrimary,
     33  	ParameterLast
     34  } ParamName;
     35  
     36 @@ -291,6 +292,7 @@ static ParamName loadcommitted[] = {
     37  	SpellLanguages,
     38  	Style,
     39  	ZoomLevel,
     40 +	ClipboardNotPrimary,
     41  	ParameterLast
     42  };
     43  
     44 @@ -1816,13 +1818,18 @@ showcert(Client *c, const Arg *a)
     45  void
     46  clipboard(Client *c, const Arg *a)
     47  {
     48 +	/* User defined choice of selection, see config.h */
     49 +	GdkAtom	selection = GDK_SELECTION_PRIMARY;
     50 +	if (curconfig[ClipboardNotPrimary].val.i > 0)
     51 +		selection = GDK_SELECTION_CLIPBOARD;
     52 +
     53  	if (a->i) { /* load clipboard uri */
     54  		gtk_clipboard_request_text(gtk_clipboard_get(
     55 -		                           GDK_SELECTION_PRIMARY),
     56 +                                          selection),
     57  		                           pasteuri, c);
     58  	} else { /* copy uri */
     59  		gtk_clipboard_set_text(gtk_clipboard_get(
     60 -		                       GDK_SELECTION_PRIMARY), c->targeturi
     61 +		                       selection), c->targeturi
     62  		                       ? c->targeturi : geturi(c), -1);
     63  	}
     64  }
     65 -- 
     66 2.24.1
     67