Mercurial > hg > xemacs-beta
changeset 2620:5e906dd5c3e9
[xemacs-hg @ 2005-02-28 20:21:43 by aidan]
(Revised) General X11 selection cleanup. Content negotiation for incoming
data, UTF8_STRING support, the ability to paste images (purely cosmetic at
this point), TIMESTAMP as one of the selection types offered,
author | aidan |
---|---|
date | Mon, 28 Feb 2005 20:21:50 +0000 |
parents | 935833be8506 |
children | a5158a1f89a4 |
files | lisp/ChangeLog lisp/x-select.el src/ChangeLog src/select-gtk.c src/select-x.c src/select.c src/select.h |
diffstat | 7 files changed, 159 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Mon Feb 28 17:02:10 2005 +0000 +++ b/lisp/ChangeLog Mon Feb 28 20:21:50 2005 +0000 @@ -1,3 +1,75 @@ +2005-02-28 Aidan Kehoe <kehoea@parhasard.net> + + * select.el (selected-text-type): Removed. + * select.el (selection-preferred-types): New. + * select.el ('selected-text-type): New. + Rename selected-text-type to selection-preferred-types, now that + it's full of image types as fallbacks. Define an alias to the old + name. + * select.el (kill-primary-selection): deleted -> delete + + * select.el (get-selection-no-error): + * select.el (get-selection): + * select.el (get-selection-foreign): + Reference selection-preferred-types instead of giving details of + which types these functions default to wanting. + + * select.el (select-make-extent-for-selection): Comment that we + need to hook something similar into the rectangle functions. + + * select.el (select-convert-in): + If we don't have a handler for an X11 selection, pass the value + itself as a string. Fixes X11 atoms. + + * select.el (select-convert-to-timestamp): New. + Uses get-xemacs-selection-timestamp. + + * select.el (select-convert-to-utf-8-text): New. + * select.el (select-convert-from-text): Removed. + The change in select-convert-in makes this irrelevant. + + * select.el (select-convert-from-length): Removed. + We have a more generic integer conversion routine here. + + * select.el (select-convert-from-filename): Removed. + The generic string conversion handles this. + + * select.el (select-convert-from-ip-address): New. + Whee. + + * select.el (select-convert-from-utf-8-text): New. + * select.el (select-convert-from-utf-16-le-text): New. + The various Mozilla-specific types need the utf-16 conversion; + utf-8 conversion is _in_ this season, didn't you know? + + * select.el (select-convert-from-image-data): New. + Generic convert-an-image-to-a-space-with-end-glyph function. Used + by the next six functions. + + * select.el (select-convert-from-image/gif): New. + * select.el (select-convert-from-image/jpeg): New. + * select.el (select-convert-from-image/png): New. + * select.el (select-convert-from-image/tiff): New. + * select.el (select-convert-from-image/xpm): New. + * select.el (select-convert-from-image/xbm): New. + Check if we have support for a given image format; if so, pass + back a space with the corresponding selection's image attached as + glyph data. + + * select.el (select-convert-from-cf-unicodetext): + * select.el (select-convert-to-cf-text): + * select.el (select-convert-to-cf-unicodetext): + Check that the corresponding Windows coding systems are available + before trying to convert. + + * select.el (selection-converter-out-alist): + * select.el (selection-converter-in-alist): + Update both lists to reflect the other changes in the file. + + * x-select.el (x-selected-text-type): + Update the define-obsolete-variable-alias now selected-text-type + is called something else. + 2005-02-25 Adrian Aichner <adrian@xemacs.org> * diagnose.el: Fix typo.
--- a/lisp/x-select.el Mon Feb 28 17:02:10 2005 +0000 +++ b/lisp/x-select.el Mon Feb 28 20:21:50 2005 +0000 @@ -43,7 +43,7 @@ (define-obsolete-function-alias 'x-selection-owner-p 'selection-owner-p) (define-obsolete-variable-alias 'x-selection-converter-alist 'selection-converter-alist) (define-obsolete-variable-alias 'x-lost-selection-hooks 'lost-selection-hooks) -(define-obsolete-variable-alias 'x-selected-text-type 'selected-text-type) +(define-obsolete-variable-alias 'x-selected-text-type 'selection-preferred-types) (define-obsolete-function-alias 'x-valid-simple-selection-p 'valid-simple-selection-p) (define-obsolete-function-alias 'x-own-selection 'own-selection) (define-obsolete-function-alias 'x-disown-selection 'disown-selection)
--- a/src/ChangeLog Mon Feb 28 17:02:10 2005 +0000 +++ b/src/ChangeLog Mon Feb 28 20:21:50 2005 +0000 @@ -1,3 +1,28 @@ +2005-02-28 Aidan Kehoe <kehoea@parhasard.net> + + * select-gtk.c (emacs_gtk_selection_handle): + * select-gtk.c (emacs_gtk_selection_clear_event_handle): + Use get_selection_raw_timestamp instead of Fget_selection_timestamp. + * select-gtk.c (gtk_own_selection): + Cross reference to some debate in select-x.c + * select-x.c: + * select-x.c (x_handle_selection_request): + Discuss Time vs. time_t--I think Time is _always_ thirty-two-bit + and time_t is variable in size. + * select-x.c (x_handle_selection_clear): + Replace call to Fget_selection_timestamp with call to + get_selection_raw_time, check that pasted data pointer is non-zero + before trying to free it. + * select.c: + * select.c (Fown_selection_internal): + Informative comment! Shouldn't actually be needed outside of the X + world. + * select.c (get_selection_raw_time): New function. + * select.c (Fget_selection_timestamp): Rework to use + get_selection_raw_time. + * select.h: + Make get_selection_raw_time available. + 2005-02-26 Aidan Kehoe <kehoea@parhasard.net> * select-x.c (x_reply_selection_request): Use XtRegisterDrawable
--- a/src/select-gtk.c Mon Feb 28 17:02:10 2005 +0000 +++ b/src/select-gtk.c Mon Feb 28 20:21:50 2005 +0000 @@ -158,7 +158,7 @@ target_symbol = fetch_multiple_target (selection_data); #endif - temp_obj = Fget_selection_timestamp (selection_symbol); + temp_obj = get_selection_raw_time(selection_symbol); if (NILP (temp_obj)) { @@ -255,7 +255,7 @@ selection_symbol = atom_to_symbol (d, selection); - local_selection_time_lisp = Fget_selection_timestamp (selection_symbol); + local_selection_time_lisp = get_selection_raw_time (selection_symbol); /* We don't own the selection, so that's fine. */ if (NILP (local_selection_time_lisp)) @@ -428,13 +428,14 @@ selection_atom, thyme); - /* We do NOT use time_to_lisp() here any more, like we used to. + /* [[ We do NOT use time_to_lisp() here any more, like we used to. That assumed equivalence of time_t and Time, which is not necessarily the case (e.g. under OSF on the Alphas, where Time is a 64-bit quantity and time_t is a 32-bit quantity). - Opaque pointers are the clean way to go here. - */ + Opaque pointers are the clean way to go here. ]] + + See my comment on the same issue in select-x.c -- Aidan. */ return make_opaque (&thyme, sizeof (thyme)); }
--- a/src/select-x.c Mon Feb 28 17:02:10 2005 +0000 +++ b/src/select-x.c Mon Feb 28 20:21:50 2005 +0000 @@ -237,13 +237,21 @@ XSetSelectionOwner (display, selection_atom, selecting_window, thyme); - /* We do NOT use time_to_lisp() here any more, like we used to. + /* [[ We do NOT use time_to_lisp() here any more, like we used to. That assumed equivalence of time_t and Time, which is not necessarily the case (e.g. under OSF on the Alphas, where - Time is a 64-bit quantity and time_t is a 32-bit quantity). + Time is a 64-bit quantity and time_t is a 32-bit quantity).]] + + This is wrong--on Digital Unix, time_t is a sixty-four-bit quantity, + and Time is, as the X protocol dictates, a thirty-two-bit quantity. - Opaque pointers are the clean way to go here. - */ + [[ Opaque pointers are the clean way to go here. ]] + + Again, I disagree--the Lisp selection infrastructure needs to be + able to manipulate the selection timestamps if it is, as we want + it to, to be able to do most of the work. Though I have moved the + conversion to lisp to get-xemacs-selection-timestamp. -- Aidan. */ + selection_time = make_opaque (&thyme, sizeof (thyme)); #ifdef MOTIF_CLIPBOARDS @@ -617,7 +625,7 @@ target_symbol = fetch_multiple_target (event); #endif - temp_obj = Fget_selection_timestamp (selection_symbol); + temp_obj = get_selection_raw_time (selection_symbol); if (NILP (temp_obj)) { @@ -665,7 +673,12 @@ successful_p = Qt; /* Tell x_selection_request_lisp_error() it's cool. */ event->type = 0; - xfree (data, Rawbyte *); + /* Data need not have been allocated; cf. select-convert-to-delete in + lisp/select.el . */ + if ((Rawbyte *)0 != data) + { + xfree (data, Rawbyte *); + } } unbind_to (count); @@ -705,7 +718,7 @@ selection_symbol = x_atom_to_symbol (d, selection); - local_selection_time_lisp = Fget_selection_timestamp (selection_symbol); + local_selection_time_lisp = get_selection_raw_time (selection_symbol); /* We don't own the selection, so that's fine. */ if (NILP (local_selection_time_lisp))
--- a/src/select.c Mon Feb 28 17:02:10 2005 +0000 +++ b/src/select.c Mon Feb 28 20:21:50 2005 +0000 @@ -289,6 +289,14 @@ /* have to do device specific stuff last so that methods can access the selection_alist */ + + /* If you are re-implementing this for another redisplay type, either make + certain that the selection time will fit within thirty-two bits, or + redesign get-xemacs-selection-timestamp to return, say, a bignum, and + convert the device-specific timestamp to a bignum before storing it in + this list. The current practice is to blindly assume that the timestamp + is thirty-two bits, which will work for extant architectures. */ + if (HAS_DEVMETH_P (XDEVICE (device), own_selection)) selection_time = DEVMETH (XDEVICE (device), own_selection, (selection_name, selection_value, @@ -492,18 +500,36 @@ : Qnil; } +Lisp_Object +get_selection_raw_time(Lisp_Object selection) +{ + Lisp_Object local_value = assq_no_quit (selection, Vselection_alist); + + if (!NILP (local_value)) + { + return XCAR (XCDR (XCDR (local_value))); + } + return Qnil; +} + /* Get the timestamp of the given selection */ -DEFUN ("get-selection-timestamp", Fget_selection_timestamp, 1, 1, 0, /* -Return the timestamp associated with the specified SELECTION, if it exists. -Note that the timestamp is a device-specific object, and may not actually be -visible from Lisp. +DEFUN ("get-xemacs-selection-timestamp", Fget_selection_timestamp, 1, 1, 0, /* +Return timestamp for SELECTION, if belongs to XEmacs and exists. + +The timestamp is a cons of two integers, the first being the higher-order +sixteen bits of the device-specific thirty-two-bit quantity, the second +being the lower-order sixteen bits of same. Expect to see this API change +when and if redisplay on a window system with timestamps wider than 32bits +happens. */ (selection)) { - Lisp_Object local_value = assq_no_quit (selection, Vselection_alist); + Lisp_Object val = get_selection_raw_time(selection); - if (!NILP (local_value)) - return XCAR (XCDR (XCDR (local_value))); + if (!NILP (val)) + { + return word_to_lisp(* (UINT_32_BIT *) XOPAQUE_DATA (val)); + } return Qnil; }
--- a/src/select.h Mon Feb 28 17:02:10 2005 +0000 +++ b/src/select.h Mon Feb 28 20:21:50 2005 +0000 @@ -57,12 +57,13 @@ void select_notify_buffer_kill (Lisp_Object buffer); +Lisp_Object get_selection_raw_time(Lisp_Object selection); + /* Lisp functions we export for other files' use */ EXFUN (Fregister_selection_data_type, 2); EXFUN (Fselection_data_type_name, 2); EXFUN (Favailable_selection_types, 2); EXFUN (Fselection_owner_p, 1); EXFUN (Fselection_exists_p, 3); -EXFUN (Fget_selection_timestamp, 1); #endif /* INCLUDED_select_h_ */