Jeff, this is a relatively discrete change, I can’t imagine it’ll have much
effect on you.
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1314367633 -3600
# Node ID 811ef64bb11a5ba4f8b7b899eb4d8260d3603536
# Parent f981f0cd7c99a7e8f4790145cf167165ff5d73db
Support all the types in selection-converter-out-alist on GTK.
src/ChangeLog.GTK addition:
2011-08-26 Aidan Kehoe <kehoea(a)parhasard.net>
* device-gtk.c:
* device-gtk.c (gtk_init_device):
* device-gtk.c (vars_of_device_gtk):
At startup, tell GTK that we're capable of and interested in
passing selections for all those selection types in
selection-converter-out-alist. This means that we now support
non-Latin-1 data when copying and pasting, which previously wasn't
the case on GTK.
Call va_run_hook_with_args, don't reimplement it ourselves.
Remove Qgtk_seen_characters in passing, nothing was using it.
* select-gtk.c (emacs_gtk_selection_handle):
Fix a bug in this function; because of X11, the fifth argument to
lisp_data_to_selection_data is not the number of octets at the
address DATA, rather the number of elements, each of size FORMAT
bits, in the array at that address.
* select.h:
device-gtk.c now needs to see selection-converter-out-alist.
diff -r f981f0cd7c99 -r 811ef64bb11a src/ChangeLog.GTK
--- a/src/ChangeLog.GTK Wed Jul 13 09:18:00 2011 -0400
+++ b/src/ChangeLog.GTK Fri Aug 26 15:07:13 2011 +0100
@@ -1,3 +1,23 @@
+2011-08-26 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * device-gtk.c:
+ * device-gtk.c (gtk_init_device):
+ * device-gtk.c (vars_of_device_gtk):
+ At startup, tell GTK that we're capable of and interested in
+ passing selections for all those selection types in
+ selection-converter-out-alist. This means that we now support
+ non-Latin-1 data when copying and pasting, which previously wasn't
+ the case on GTK.
+ Call va_run_hook_with_args, don't reimplement it ourselves.
+ Remove Qgtk_seen_characters in passing, nothing was using it.
+ * select-gtk.c (emacs_gtk_selection_handle):
+ Fix a bug in this function; because of X11, the fifth argument to
+ lisp_data_to_selection_data is not the number of octets at the
+ address DATA, rather the number of elements, each of size FORMAT
+ bits, in the array at that address.
+ * select.h:
+ device-gtk.c now needs to see selection-converter-out-alist.
+
2011-07-12 Jeff Sparkes <jsparkes(a)gmail.com>
* event-gtk.c (emacs_gtk_add_timeout): Use glib timeout instead of
diff -r f981f0cd7c99 -r 811ef64bb11a src/device-gtk.c
--- a/src/device-gtk.c Wed Jul 13 09:18:00 2011 -0400
+++ b/src/device-gtk.c Fri Aug 26 15:07:13 2011 +0100
@@ -36,6 +36,7 @@
#include "redisplay.h"
#include "sysdep.h"
#include "window.h"
+#include "select.h"
#include "console-gtk-impl.h"
#include "gccache-gtk.h"
@@ -59,8 +60,6 @@
Lisp_Object Vgtk_initial_argv_list; /* #### ugh! */
Lisp_Object Vgtk_initial_geometry;
-Lisp_Object Qgtk_seen_characters;
-
static void gtk_device_init_x_specific_cruft (struct device *d);
static const struct memory_description gtk_device_data_description_1 [] = {
@@ -306,12 +305,60 @@
purposes */
gtk_widget_realize (GTK_WIDGET (app_shell));
- /* Need to set up some selection handlers */
- gtk_selection_add_target (GTK_WIDGET (app_shell), GDK_SELECTION_PRIMARY,
- GDK_SELECTION_TYPE_STRING, 0);
- gtk_selection_add_target (GTK_WIDGET (app_shell),
- gdk_atom_intern("CLIPBOARD", FALSE),
- GDK_SELECTION_TYPE_STRING, 0);
+ /* Set up the selection handlers. I attempted just to register the handler
+ for TARGETS, and this works in that the requestor does see our offered
+ list of targets (GTK gets out of the way for this), but then further
+ attempts to transfer COMPOUND_TEXT and so on fail, because GTK
+ interposes itself, and ignores that we've demonstrated we know what
+ formats we can transfer by sending TARGETS.
+
+ Note that under X11 the cars of selection-converter-out-alist can
+ usefully be modified at runtime, making fewer or more selection types
+ available; this isn't the case under GTK, the set is examined once at
+ startup. */
+ {
+ guint target_count = XINT (Fsafe_length (Vselection_converter_out_alist));
+ GtkTargetEntry *targets = alloca_array (GtkTargetEntry, target_count);
+ Lisp_Object tail = Vselection_converter_out_alist;
+ DECLARE_EISTRING(ei_symname);
+ guint ii;
+
+ for (ii = 0; ii < target_count; ii++)
+ {
+ targets[ii].flags = 0;
+ /* We don't use info at the moment. */
+ targets[ii].info = ii;
+ if (CONSP (Fcar (tail)) && SYMBOLP (XCAR (XCAR (tail))))
+ {
+ eicpy_lstr (ei_symname, XSYMBOL_NAME (XCAR (XCAR (tail))));
+ /* GTK doesn't specify the encoding of their atom names. */
+ eito_external (ei_symname, Qbinary);
+ targets[ii].target = alloca_array (gchar, eiextlen (ei_symname)
+ + 1);
+ memcpy ((void *) (targets[ii].target),
+ (void *) eiextdata (ei_symname), eiextlen (ei_symname) + 1);
+ }
+ else
+ {
+ if (ii > 0xFF)
+ {
+ /* It was corrupt long before ii > 0xff, of course. */
+ gui_error ("selection-converter-out-alist is corrupt",
+ Vselection_converter_out_alist);
+ }
+ targets[ii].target = alloca_array (gchar, sizeof ("TARGETFF"));
+ sprintf (targets[ii].target, "TARGET%02X", ii);
+ }
+ tail = Fcdr (tail);
+ }
+
+ gtk_selection_add_targets (GTK_WIDGET (app_shell), GDK_SELECTION_PRIMARY,
+ targets, target_count);
+ gtk_selection_add_targets (GTK_WIDGET (app_shell), GDK_SELECTION_SECONDARY,
+ targets, target_count);
+ gtk_selection_add_targets (GTK_WIDGET (app_shell), GDK_SELECTION_CLIPBOARD,
+ targets, target_count);
+ }
g_signal_connect (G_OBJECT (app_shell), "selection_get",
GTK_SIGNAL_FUNC (emacs_gtk_selection_handle), NULL);
@@ -754,8 +801,6 @@
Vgtk_initial_geometry = Qnil;
Vgtk_initial_argv_list = Qnil;
-
- Qgtk_seen_characters = Qnil;
}
#include "sysgdkx.h"
diff -r f981f0cd7c99 -r 811ef64bb11a src/select-gtk.c
--- a/src/select-gtk.c Wed Jul 13 09:18:00 2011 -0400
+++ b/src/select-gtk.c Fri Aug 26 15:07:13 2011 +0100
@@ -198,20 +198,26 @@
make_opaque_ptr (cl));
{
- Rawbyte *data;
- Bytecount size;
- int format;
+ Rawbyte *data; /* The selection data to transfer. */
+ Elemcount len; /* The number of *elements*, each of size FORMAT bits, in
+ the array at address DATA. */
+ gint format, format_octets;
GdkAtom type;
- lisp_data_to_selection_data (d, converted_selection,
- &data, &type, &size, &format);
+ lisp_data_to_selection_data (d, converted_selection, &data, &type, &len,
+ &format);
+ format_octets = format / 8;
gtk_selection_data_set (selection_data, type, format, data,
- /* #### is this right? */
- (unsigned int) size);
+ format_octets * len);
successful_p = Qt;
/* Tell x_selection_request_lisp_error() it's cool. */
cl->successful = TRUE;
- xfree (data);
+ /* Data need not have been allocated; cf. select-convert-to-delete in
+ lisp/select.el . */
+ if (data)
+ {
+ xfree (data);
+ }
}
unbind_to (count);
@@ -224,18 +230,8 @@
UNGCPRO;
/* Let random lisp code notice that the selection has been asked for. */
- {
- Lisp_Object val = Vgtk_sent_selection_hooks;
- if (!UNBOUNDP (val) && !NILP (val))
- {
- Lisp_Object rest;
- if (CONSP (val) && !EQ (XCAR (val), Qlambda))
- for (rest = val; !NILP (rest); rest = Fcdr (rest))
- call3 (Fcar (rest), selection_symbol, target_symbol, successful_p);
- else
- call3 (val, selection_symbol, target_symbol, successful_p);
- }
- }
+ va_run_hook_with_args (Vgtk_sent_selection_hooks, 3, selection_symbol,
+ target_symbol, successful_p);
}
diff -r f981f0cd7c99 -r 811ef64bb11a src/select.h
--- a/src/select.h Wed Jul 13 09:18:00 2011 -0400
+++ b/src/select.h Fri Aug 26 15:07:13 2011 +0100
@@ -64,4 +64,6 @@
EXFUN (Fselection_owner_p, 1);
EXFUN (Fselection_exists_p, 3);
+extern Lisp_Object Vselection_converter_out_alist;
+
#endif /* INCLUDED_select_h_ */
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches