hi. i tend to live in a clipboard'y world (emacs 25, etc.). it's nice for me, but i have the problem that surf's C-y copies to the primary selection rather than the clipboard and so i always have to stand on my head to get it in the clipboard. (i don't use a mouse for pasting.)
here is a patch that makes the argument to the (oddly, presumably historically, misnamed) clipboard() routine be an integer, rather than a boolean, so one can specify sources of C-p and sinks of C-y to be the primary selection or clipboard. it seems to me to be backwards compatible, since i guess "{.b = TRUE}" == "{.i = 1}", etc. note the XXX: one odd thing i realized was that to *me* it felt funny for C-y to put the URI in the clipboard with*out* also putting it in the primary selection. so, in the case where it puts it in the clipboard, i decided to *also* put it in the primary selection. (this also means that for people used to C-y to be in the primary, it still is; but ...) if it's the greatest thing since sliced bread and someone put it in the source tree, great! cheers, Greg ---- diff --git a/surf.c b/surf.c index d75e589..64e6789 100644 --- a/surf.c +++ b/surf.c @@ -513,20 +513,42 @@ runscript(WebKitWebFrame *frame) } } +/* + * arg is copy/paste/primary/clipboard + * paste: 0 ==> URI --> primary [copy] + * paste: 1 ==> primary --> URI [paste] + * paste: 2 ==> URI --> clipboard and primary [copy] + * paste: 3 ==> clipboard --> URI [paste] + */ void clipboard(Client *c, const Arg *arg) { - gboolean paste = *(gboolean *)arg; - - if (paste) { - gtk_clipboard_request_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), + switch (arg->i) { + case 2: + /* XXX for paste == 2, it seems weird to have s.th. in + * clipboard that was never in the primary. so, we put in + * both. thus, people expecting it in primary will see it. + * not clear this is the right choice. + */ + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), + c->linkhover ? c->linkhover : geturi(c), -1); + /* fall through to set primary */ + case 0: + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), + c->linkhover ? c->linkhover : geturi(c), -1); + break; + case 1: + gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteuri, c); - } else { - gtk_clipboard_set_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), c->linkhover - ? c->linkhover : geturi(c), -1); - } + break; + case 3: + gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), + pasteuri, c); + break; + default: + g_warning("%s:%d: clipboard called with arg outside {0,1,2,3}, i.e., %d. error in config.h?", __FILE__, __LINE__, arg->i); + break; + } } char *