User: aidan   
  Date: 05/02/28 21:21:52
  Modified:    xemacs/src ChangeLog select-gtk.c select-x.c select.c
                        select.h
  Log:
  (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,
  
  Revision  Changes    Path
  1.648     +72 -0     XEmacs/xemacs/lisp/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
  retrieving revision 1.647
  retrieving revision 1.648
  diff -u -r1.647 -r1.648
  --- ChangeLog	2005/02/28 07:43:17	1.647
  +++ ChangeLog	2005/02/28 20:21:43	1.648
  @@ -1,3 +1,75 @@
  +2005-02-28  Aidan Kehoe  <kehoea(a)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(a)xemacs.org>
   
   	* diagnose.el: Fix typo.
  
  
  
  1.8       +1 -1      XEmacs/xemacs/lisp/x-select.el
  
  Index: x-select.el
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/x-select.el,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- x-select.el	2001/05/04 22:42:18	1.7
  +++ x-select.el	2005/02/28 20:21:44	1.8
  @@ -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)
  
  
  
  1.796     +25 -0     XEmacs/xemacs/src/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
  retrieving revision 1.795
  retrieving revision 1.796
  diff -u -r1.795 -r1.796
  --- ChangeLog	2005/02/28 17:02:09	1.795
  +++ ChangeLog	2005/02/28 20:21:48	1.796
  @@ -1,3 +1,28 @@
  +2005-02-28  Aidan Kehoe  <kehoea(a)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(a)parhasard.net>
   
   	* select-x.c (x_reply_selection_request): Use XtRegisterDrawable 
  
  
  
  1.17      +6 -5      XEmacs/xemacs/src/select-gtk.c
  
  Index: select-gtk.c
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/src/select-gtk.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- select-gtk.c	2004/11/04 23:06:52	1.16
  +++ select-gtk.c	2005/02/28 20:21:50	1.17
  @@ -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));
   }
   
  
  
  
  1.19      +20 -7     XEmacs/xemacs/src/select-x.c
  
  Index: select-x.c
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/src/select-x.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- select-x.c	2005/02/28 17:02:10	1.18
  +++ select-x.c	2005/02/28 20:21:50	1.19
  @@ -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).]]
   
  -     Opaque pointers are the clean way to go here.
  -  */
  +     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. ]]
  +
  +     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))
  
  
  
  1.7       +33 -7     XEmacs/xemacs/src/select.c
  
  Index: select.c
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/src/select.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- select.c	2002/06/20 21:18:45	1.6
  +++ select.c	2005/02/28 20:21:50	1.7
  @@ -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;
   }
  
  
  
  1.3       +2 -1      XEmacs/xemacs/src/select.h
  
  Index: select.h
  ===================================================================
  RCS file: /pack/xemacscvs/XEmacs/xemacs/src/select.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- select.h	2001/04/12 18:24:19	1.2
  +++ select.h	2005/02/28 20:21:50	1.3
  @@ -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_ */