about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-07-11 10:38:56 -0400
committerJosh Rickmar <jrick@devio.us>2012-07-11 10:38:56 -0400
commit1b1ab5fa1804dacc43140fc95f85452cefdb5db6 (patch)
treeb3419120bd66f4cd4f84236b1b7701ea87f4ab92
parent77296e1725d6e3e7d6006a447678908e9b0eb601 (diff)
downloadxombrero-1b1ab5fa1804dacc43140fc95f85452cefdb5db6.tar.gz
Remove xterm_workaround as this has been fixed upstream, and make y
and p work with CLIPBOARD in addition to PRIMARY.  Yanking copies to
both, and pasting tries PRIMARY first, and if empty, reads from
CLIPBOARD.  This should make y/p/P work on windows.
-rw-r--r--settings.c20
-rw-r--r--xombrero.17
-rw-r--r--xombrero.c99
-rw-r--r--xombrero.conf1
-rw-r--r--xombrero.h2
5 files changed, 21 insertions, 108 deletions
diff --git a/settings.c b/settings.c
index 340c510..aeffa91 100644
--- a/settings.c
+++ b/settings.c
@@ -93,7 +93,6 @@ int		session_autosave = XT_DS_SESSION_AUTOSAVE;
 int		guess_search = XT_DS_GUESS_SEARCH;
 gint		enable_spell_checking = XT_DS_ENABLE_SPELL_CHECKING;
 char		*spell_check_languages = NULL;	/* allocated/set at startup */
-int		xterm_workaround = XT_DS_XTERM_WORKAROUND;
 char		*url_regex = NULL;		/* allocated/set at startup */
 char		*encoding = NULL;		/* allocated/set at startup */
 int		autofocus_onload = XT_DS_AUTOFOCUS_ONLOAD;
@@ -199,7 +198,6 @@ int		set_userstyle(struct settings *, char *);
 int		set_userstyle_rt(char *);
 int		set_userstyle_global(char *);
 int		set_external_editor(char *);
-int		set_xterm_workaround(char *);
 int		set_warn_cert_changes(char *);
 int		set_allow_insecure_content(char *);
 int		set_allow_insecure_scripts(char *);
@@ -468,7 +466,6 @@ struct settings		rs[] = {
 	{ "window_maximize",		XT_S_INT, 0,		&window_maximize, NULL, NULL, NULL, NULL },
 	{ "window_width",		XT_S_INT, 0,		&window_width, NULL, NULL, NULL, NULL },
 	{ "work_dir",			XT_S_STR, 0, NULL, NULL,&s_work_dir, NULL, NULL },
-	{ "xterm_workaround",		XT_S_INT, 0,		&xterm_workaround, NULL, NULL, NULL, set_xterm_workaround },
 
 	/* special settings */
 	{ "alias",			XT_S_STR, XT_SF_RUNTIME, NULL, NULL, &s_alias, NULL, NULL },
@@ -2483,23 +2480,6 @@ set_work_dir(struct settings *s, char *val)
 	return (0);
 }
 
-int
-set_xterm_workaround(char *value)
-{
-	int			tmp;
-	const char		*errstr;
-
-	if (value == NULL || strlen(value) == 0)
-		xterm_workaround = XT_DS_XTERM_WORKAROUND;
-	else {
-		tmp = strtonum(value, 0, 1, &errstr);
-		if (errstr)
-			return (-1);
-		xterm_workaround = tmp;
-	}
-	return (0);
-}
-
 void
 walk_cookie_wl(struct settings *s,
     void (*cb)(struct settings *, char *, void *), void *cb_args)
diff --git a/xombrero.1 b/xombrero.1
index 64dddc2..d80b5e9 100644
--- a/xombrero.1
+++ b/xombrero.1
@@ -1531,13 +1531,6 @@ Set the work directory where all
 scratch files are stored.
 Default is
 .Cm ~/.xombrero .
-.It Cm xterm_workaround
-When enabled
-.Nm
-will look additionally at CUT_BUFFER0 if PRIMARY clipboard is empty.
-Additionally when the PRIMARY clipboard is cleared it will copy CUT_BUFFER0
-into the PRIMARY clipboard.
-Default is 0.
 .El
 .Sh HISTORY
 .Nm
diff --git a/xombrero.c b/xombrero.c
index b5414f8..5a1c545 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -1457,12 +1457,14 @@ int
 yank_uri(struct tab *t, struct karg *args)
 {
 	const gchar		*uri;
-	GtkClipboard		*clipboard;
+	GtkClipboard		*clipboard, *primary;
 
 	if ((uri = get_uri(t)) == NULL)
 		return (1);
 
-	clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+	primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_set_text(primary, uri, -1);
 	gtk_clipboard_set_text(clipboard, uri, -1);
 
 	return (0);
@@ -1471,35 +1473,22 @@ yank_uri(struct tab *t, struct karg *args)
 int
 paste_uri(struct tab *t, struct karg *args)
 {
-	GtkClipboard		*clipboard;
-	GdkAtom			atom = gdk_atom_intern("CUT_BUFFER0", FALSE);
-	gint			len;
-	gchar			*p = NULL, *uri;
-
-	/* try primary clipboard first */
-	clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
-	p = gtk_clipboard_wait_for_text(clipboard);
-
-	/* if it failed get whatever text is in cut_buffer0 */
-	if (p == NULL && xterm_workaround)
-		if (gdk_property_get(gdk_get_default_root_window(),
-		    atom,
-		    gdk_atom_intern("STRING", FALSE),
-		    0,
-		    1024 * 1024 /* picked out of my butt */,
-		    FALSE,
-		    NULL,
-		    NULL,
-		    &len,
-		    (guchar **)&p)) {
-			if (p == NULL)
-				goto done;
-			/* yes sir, we need to NUL the string */
-			p[len] = '\0';
-		}
+	GtkClipboard		*clipboard, *primary;
+	gchar			*c = NULL, *p = NULL, *uri;
 
-	if (p) {
-		uri = p;
+	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+	primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+	c = gtk_clipboard_wait_for_text(clipboard);
+	p = gtk_clipboard_wait_for_text(primary);
+
+	if (c || p) {
+#ifdef __MINGW32__
+		/* Windows try clipboard first */
+		uri = c ? c : p;
+#else
+		/* UNIX try primary first */
+		uri = p ? p : c;
+#endif
 		while (*uri && isspace(*uri))
 			uri++;
 		if (strlen(uri) == 0) {
@@ -1519,6 +1508,8 @@ paste_uri(struct tab *t, struct karg *args)
 	}
 
 done:
+	if (c)
+		g_free(c);
 	if (p)
 		g_free(p);
 
@@ -7927,48 +7918,6 @@ button_set_stockid(GtkWidget *button, char *stockid)
 }
 
 void
-clipb_primary_cb(GtkClipboard *primary, GdkEvent *event, gpointer notused)
-{
-	gchar			*p = NULL;
-	GdkAtom			atom = gdk_atom_intern("CUT_BUFFER0", FALSE);
-	gint			len;
-
-	if (xterm_workaround == 0)
-		return;
-
-	/*
-	 * xterm doesn't play nice with clipboards because it clears the
-	 * primary when clicked.  We rely on primary being set to properly
-	 * handle middle mouse button clicks (paste).  So when someone clears
-	 * primary copy whatever is in CUT_BUFFER0 into primary to simualte
-	 * other application behavior (as in DON'T clear primary).
-	 */
-
-	p = gtk_clipboard_wait_for_text(primary);
-	if (p == NULL) {
-		if (gdk_property_get(gdk_get_default_root_window(),
-		    atom,
-		    gdk_atom_intern("STRING", FALSE),
-		    0,
-		    1024 * 1024 /* picked out of my butt */,
-		    FALSE,
-		    NULL,
-		    NULL,
-		    &len,
-		    (guchar **)&p)) {
-			if (p == NULL)
-				return;
-			/* yes sir, we need to NUL the string */
-			p[len] = '\0';
-			gtk_clipboard_set_text(primary, p, -1);
-		}
-	}
-
-	if (p)
-		g_free(p);
-}
-
-void
 create_canvas(void)
 {
 	GtkWidget		*vbox;
@@ -8036,12 +7985,6 @@ create_canvas(void)
 	}
 	gtk_window_set_default_icon_list(l);
 
-	/* clipboard work around */
-	if (xterm_workaround)
-		g_signal_connect(
-		    G_OBJECT(gtk_clipboard_get(GDK_SELECTION_PRIMARY)),
-		    "owner-change", G_CALLBACK(clipb_primary_cb), NULL);
-
 	gtk_widget_show_all(abtn);
 	gtk_widget_show_all(main_window);
 	notebook_tab_set_visibility();
diff --git a/xombrero.conf b/xombrero.conf
index 859e146..175df7c 100644
--- a/xombrero.conf
+++ b/xombrero.conf
@@ -50,7 +50,6 @@
 # session_autosave	= 1
 # history_autosave	= 1
 # autofocus_onload	= 1
-# xterm_workaround	= 1
 # single_instance	= 1
 # enable_socket		= 1
 # enable_js_autorun	= 0
diff --git a/xombrero.h b/xombrero.h
index bcd20cb..c91443d 100644
--- a/xombrero.h
+++ b/xombrero.h
@@ -632,7 +632,6 @@ int		command_mode(struct tab *, struct karg *);
 #define XT_DS_GUESS_SEARCH	(0)
 #define XT_DS_ENABLE_SPELL_CHECKING	(0)
 #define XT_DS_SPELL_CHECK_LANGUAGES	("en_US")
-#define XT_DS_XTERM_WORKAROUND	(0)
 #define XT_DS_URL_REGEX		("^[[:blank:]]*[^[:blank:]]*([[:alnum:]-]+\\.)+[[:alnum:]-][^[:blank:]]*[[:blank:]]*$")
 #define XT_DS_ENCODING		("UTF-8")
 #define XT_DS_AUTOFOCUS_ONLOAD	(0)
@@ -803,7 +802,6 @@ extern gint	max_connections;
 extern gint	max_host_connections;
 extern gint	enable_spell_checking;
 extern char	*spell_check_languages;
-extern int	xterm_workaround;
 extern char	*url_regex;
 extern int	history_autosave;
 extern char	search_file[PATH_MAX];