emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xselect.c


From: Sam Steingold
Subject: [Emacs-diffs] Changes to emacs/src/xselect.c
Date: Fri, 07 Jun 2002 18:05:08 -0400

Index: emacs/src/xselect.c
diff -c emacs/src/xselect.c:1.118 emacs/src/xselect.c:1.119
*** emacs/src/xselect.c:1.118   Fri Jun  7 09:43:29 2002
--- emacs/src/xselect.c Fri Jun  7 18:05:07 2002
***************
*** 116,122 ****
  /* If this is a smaller number than the max-request-size of the display,
     emacs will use INCR selection transfer when the selection is larger
     than this.  The max-request-size is usually around 64k, so if you want
!    emacs to use incremental selection transfers when the selection is 
     smaller than that, set this.  I added this mostly for debugging the
     incremental transfer stuff, but it might improve server performance.  */
  #define MAX_SELECTION_QUANTUM 0xFFFFFF
--- 116,122 ----
  /* If this is a smaller number than the max-request-size of the display,
     emacs will use INCR selection transfer when the selection is larger
     than this.  The max-request-size is usually around 64k, so if you want
!    emacs to use incremental selection transfers when the selection is
     smaller than that, set this.  I added this mostly for debugging the
     incremental transfer stuff, but it might improve server performance.  */
  #define MAX_SELECTION_QUANTUM 0xFFFFFF
***************
*** 147,153 ****
  
  /* This is an alist whose CARs are selection-types (whose names are the same
     as the names of X Atoms) and whose CDRs are the names of Lisp functions to
!    call to convert the given Emacs selection value to a string representing 
     the given selection type.  This is for Lisp-level extension of the emacs
     selection handling.  */
  static Lisp_Object Vselection_converter_alist;
--- 147,153 ----
  
  /* This is an alist whose CARs are selection-types (whose names are the same
     as the names of X Atoms) and whose CDRs are the names of Lisp functions to
!    call to convert the given Emacs selection value to a string representing
     the given selection type.  This is for Lisp-level extension of the emacs
     selection handling.  */
  static Lisp_Object Vselection_converter_alist;
***************
*** 162,168 ****
  static Lisp_Object selection_data_to_lisp_data ();
  static Lisp_Object x_get_window_property_as_lisp_data ();
  
! /* This converts a Lisp symbol to a server Atom, avoiding a server 
     roundtrip whenever possible.  */
  
  static Atom
--- 162,168 ----
  static Lisp_Object selection_data_to_lisp_data ();
  static Lisp_Object x_get_window_property_as_lisp_data ();
  
! /* This converts a Lisp symbol to a server Atom, avoiding a server
     roundtrip whenever possible.  */
  
  static Atom
***************
*** 219,228 ****
    struct x_display_info *dpyinfo;
    char *str;
    Lisp_Object val;
!   
    if (! atom)
      return Qnil;
!   
    switch (atom)
      {
      case XA_PRIMARY:
--- 219,228 ----
    struct x_display_info *dpyinfo;
    char *str;
    Lisp_Object val;
! 
    if (! atom)
      return Qnil;
! 
    switch (atom)
      {
      case XA_PRIMARY:
***************
*** 291,297 ****
  }
  
  /* Do protocol to assert ourself as a selection owner.
!    Update the Vselection_alist so that we can reply to later requests for 
     our selection.  */
  
  static void
--- 291,297 ----
  }
  
  /* Do protocol to assert ourself as a selection owner.
!    Update the Vselection_alist so that we can reply to later requests for
     our selection.  */
  
  static void
***************
*** 436,442 ****
        && SYMBOLP (XCAR (value)))
      type = XCAR (value),
      check = XCDR (value);
!   
    if (STRINGP (check)
        || VECTORP (check)
        || SYMBOLP (check)
--- 436,442 ----
        && SYMBOLP (XCAR (value)))
      type = XCAR (value),
      check = XCDR (value);
! 
    if (STRINGP (check)
        || VECTORP (check)
        || SYMBOLP (check)
***************
*** 470,476 ****
  {
    XSelectionEvent reply;
    int count;
!   
    reply.type = SelectionNotify;
    reply.display = SELECTION_EVENT_DISPLAY (event);
    reply.requestor = SELECTION_EVENT_REQUESTOR (event);
--- 470,476 ----
  {
    XSelectionEvent reply;
    int count;
! 
    reply.type = SelectionNotify;
    reply.display = SELECTION_EVENT_DISPLAY (event);
    reply.requestor = SELECTION_EVENT_REQUESTOR (event);
***************
*** 644,650 ****
  
        if (x_window_to_frame (dpyinfo, window)) /* #### debug */
        error ("Attempt to transfer an INCR to ourself!");
!       
        TRACE2 ("Start sending %d bytes incrementally (%s)",
              bytes_remaining,  XGetAtomName (display, reply.property));
        wait_object = expect_property_change (display, window, reply.property,
--- 644,650 ----
  
        if (x_window_to_frame (dpyinfo, window)) /* #### debug */
        error ("Attempt to transfer an INCR to ourself!");
! 
        TRACE2 ("Start sending %d bytes incrementally (%s)",
              bytes_remaining,  XGetAtomName (display, reply.property));
        wait_object = expect_property_change (display, window, reply.property,
***************
*** 656,662 ****
                       32, PropModeReplace,
                       (unsigned char *) &bytes_remaining, 1);
        XSelectInput (display, window, PropertyChangeMask);
!       
        /* Tell 'em the INCR data is there...  */
        TRACE0 ("Send SelectionNotify event");
        XSendEvent (display, window, False, 0L, (XEvent *) &reply);
--- 656,662 ----
                       32, PropModeReplace,
                       (unsigned char *) &bytes_remaining, 1);
        XSelectInput (display, window, PropertyChangeMask);
! 
        /* Tell 'em the INCR data is there...  */
        TRACE0 ("Send SelectionNotify event");
        XSendEvent (display, window, False, 0L, (XEvent *) &reply);
***************
*** 690,696 ****
          TRACE1 ("Sending increment of %d bytes", i);
          TRACE1 ("Set %s to increment data",
                  XGetAtomName (display, reply.property));
!         
          /* Append the next chunk of data to the property.  */
          XChangeProperty (display, window, reply.property, type, format,
                           PropModeAppend, data, i / format_bytes);
--- 690,696 ----
          TRACE1 ("Sending increment of %d bytes", i);
          TRACE1 ("Set %s to increment data",
                  XGetAtomName (display, reply.property));
! 
          /* Append the next chunk of data to the property.  */
          XChangeProperty (display, window, reply.property, type, format,
                           PropModeAppend, data, i / format_bytes);
***************
*** 709,715 ****
                  XGetAtomName (display, reply.property));
          wait_for_property_change (wait_object);
        }
!       
        /* Now write a zero-length chunk to the property to tell the
         requester that we're done.  */
        BLOCK_INPUT;
--- 709,715 ----
                  XGetAtomName (display, reply.property));
          wait_for_property_change (wait_object);
        }
! 
        /* Now write a zero-length chunk to the property to tell the
         requester that we're done.  */
        BLOCK_INPUT;
***************
*** 797,808 ****
    if (EQ (target_symbol, QMULTIPLE))
      target_symbol = fetch_multiple_target (event);
  #endif
!   
    /* Convert lisp objects back into binary data */
!   
    converted_selection
      = x_get_local_selection (selection_symbol, target_symbol);
!   
    if (! NILP (converted_selection))
      {
        unsigned char *data;
--- 797,808 ----
    if (EQ (target_symbol, QMULTIPLE))
      target_symbol = fetch_multiple_target (event);
  #endif
! 
    /* Convert lisp objects back into binary data */
! 
    converted_selection
      = x_get_local_selection (selection_symbol, target_symbol);
! 
    if (! NILP (converted_selection))
      {
        unsigned char *data;
***************
*** 814,820 ****
        lisp_data_to_selection_data (SELECTION_EVENT_DISPLAY (event),
                                   converted_selection,
                                   &data, &type, &size, &format, &nofree);
!       
        x_reply_selection_request (event, format, data, size, type);
        successful_p = Qt;
  
--- 814,820 ----
        lisp_data_to_selection_data (SELECTION_EVENT_DISPLAY (event),
                                   converted_selection,
                                   &data, &type, &size, &format, &nofree);
! 
        x_reply_selection_request (event, format, data, size, type);
        successful_p = Qt;
  
***************
*** 853,859 ****
    Display *display = SELECTION_EVENT_DISPLAY (event);
    Atom selection = SELECTION_EVENT_SELECTION (event);
    Time changed_owner_time = SELECTION_EVENT_TIME (event);
!   
    Lisp_Object selection_symbol, local_selection_data;
    Time local_selection_time;
    struct x_display_info *dpyinfo = x_display_info_for_display (display);
--- 853,859 ----
    Display *display = SELECTION_EVENT_DISPLAY (event);
    Atom selection = SELECTION_EVENT_SELECTION (event);
    Time changed_owner_time = SELECTION_EVENT_TIME (event);
! 
    Lisp_Object selection_symbol, local_selection_data;
    Time local_selection_time;
    struct x_display_info *dpyinfo = x_display_info_for_display (display);
***************
*** 1139,1145 ****
          xfree (rest);
          return;
        }
!       
        prev = rest;
        rest = rest->next;
      }
--- 1139,1145 ----
          xfree (rest);
          return;
        }
! 
        prev = rest;
        rest = rest->next;
      }
***************
*** 1174,1180 ****
    int size;
    if (CONSP (obj))
      return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
!     
    CHECK_VECTOR (obj);
    vec = Fmake_vector (size = XVECTOR (obj)->size, Qnil);
    for (i = 0; i < size; i++)
--- 1174,1180 ----
    int size;
    if (CONSP (obj))
      return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
! 
    CHECK_VECTOR (obj);
    vec = Fmake_vector (size = XVECTOR (obj)->size, Qnil);
    for (i = 0; i < size; i++)
***************
*** 1227,1235 ****
      type_atom = symbol_to_x_atom (dpyinfo, display, target_type);
  
    BLOCK_INPUT;
!   
    count = x_catch_errors (display);
!   
    TRACE2 ("Get selection %s, type %s",
          XGetAtomName (display, type_atom),
          XGetAtomName (display, target_property));
--- 1227,1235 ----
      type_atom = symbol_to_x_atom (dpyinfo, display, target_type);
  
    BLOCK_INPUT;
! 
    count = x_catch_errors (display);
! 
    TRACE2 ("Get selection %s, type %s",
          XGetAtomName (display, type_atom),
          XGetAtomName (display, target_property));
***************
*** 1305,1316 ****
    unsigned char *tmp_data = 0;
    int result;
    int buffer_size = SELECTION_QUANTUM (display);
!   
    if (buffer_size > MAX_SELECTION_QUANTUM)
      buffer_size = MAX_SELECTION_QUANTUM;
!   
    BLOCK_INPUT;
!   
    /* First probe the thing to find out how big it is.  */
    result = XGetWindowProperty (display, window, property,
                               0L, 0L, False, AnyPropertyType,
--- 1305,1316 ----
    unsigned char *tmp_data = 0;
    int result;
    int buffer_size = SELECTION_QUANTUM (display);
! 
    if (buffer_size > MAX_SELECTION_QUANTUM)
      buffer_size = MAX_SELECTION_QUANTUM;
! 
    BLOCK_INPUT;
! 
    /* First probe the thing to find out how big it is.  */
    result = XGetWindowProperty (display, window, property,
                               0L, 0L, False, AnyPropertyType,
***************
*** 1324,1333 ****
        *bytes_ret = 0;
        return;
      }
!   
    /* This was allocated by Xlib, so use XFree.  */
    XFree ((char *) tmp_data);
!   
    if (*actual_type_ret == None || *actual_format_ret == 0)
      {
        UNBLOCK_INPUT;
--- 1324,1333 ----
        *bytes_ret = 0;
        return;
      }
! 
    /* This was allocated by Xlib, so use XFree.  */
    XFree ((char *) tmp_data);
! 
    if (*actual_type_ret == None || *actual_format_ret == 0)
      {
        UNBLOCK_INPUT;
***************
*** 1336,1342 ****
  
    total_size = bytes_remaining + 1;
    *data_ret = (unsigned char *) xmalloc (total_size);
!   
    /* Now read, until we've gotten it all.  */
    while (bytes_remaining)
      {
--- 1336,1342 ----
  
    total_size = bytes_remaining + 1;
    *data_ret = (unsigned char *) xmalloc (total_size);
! 
    /* Now read, until we've gotten it all.  */
    while (bytes_remaining)
      {
***************
*** 1363,1369 ****
        *actual_size_ret *= *actual_format_ret / 8;
        bcopy (tmp_data, (*data_ret) + offset, *actual_size_ret);
        offset += *actual_size_ret;
!       
        /* This was allocated by Xlib, so use XFree.  */
        XFree ((char *) tmp_data);
      }
--- 1363,1369 ----
        *actual_size_ret *= *actual_format_ret / 8;
        bcopy (tmp_data, (*data_ret) + offset, *actual_size_ret);
        offset += *actual_size_ret;
! 
        /* This was allocated by Xlib, so use XFree.  */
        XFree ((char *) tmp_data);
      }
***************
*** 1424,1430 ****
  
        TRACE0 ("  Wait for property change");
        wait_for_property_change (wait_object);
!       
        /* expect it again immediately, because x_get_window_property may
         .. no it won't, I don't get it.
         .. Ok, I get it now, the Xt code that implements INCR is broken. */
--- 1424,1430 ----
  
        TRACE0 ("  Wait for property change");
        wait_for_property_change (wait_object);
! 
        /* expect it again immediately, because x_get_window_property may
         .. no it won't, I don't get it.
         .. Ok, I get it now, the Xt code that implements INCR is broken. */
***************
*** 1462,1471 ****
          *size_bytes_ret = offset + tmp_size_bytes;
          *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret);
        }
!       
        bcopy (tmp_data, (*data_ret) + offset, tmp_size_bytes);
        offset += tmp_size_bytes;
!       
        /* Use xfree, not XFree, because x_get_window_property
         calls xmalloc itself.  */
        xfree (tmp_data);
--- 1462,1471 ----
          *size_bytes_ret = offset + tmp_size_bytes;
          *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret);
        }
! 
        bcopy (tmp_data, (*data_ret) + offset, tmp_size_bytes);
        offset += tmp_size_bytes;
! 
        /* Use xfree, not XFree, because x_get_window_property
         calls xmalloc itself.  */
        xfree (tmp_data);
***************
*** 1519,1525 ****
                                                 selection_atom),
                               Qnil)));
      }
!   
    if (actual_type == dpyinfo->Xatom_INCR)
      {
        /* That wasn't really the data, just the beginning.  */
--- 1519,1525 ----
                                                 selection_atom),
                               Qnil)));
      }
! 
    if (actual_type == dpyinfo->Xatom_INCR)
      {
        /* That wasn't really the data, just the beginning.  */
***************
*** 1546,1552 ****
       manner.  */
    val = selection_data_to_lisp_data (display, data, bytes,
                                     actual_type, actual_format);
!   
    /* Use xfree, not XFree, because x_get_window_property
       calls xmalloc itself.  */
    xfree ((char *) data);
--- 1546,1552 ----
       manner.  */
    val = selection_data_to_lisp_data (display, data, bytes,
                                     actual_type, actual_format);
! 
    /* Use xfree, not XFree, because x_get_window_property
       calls xmalloc itself.  */
    xfree ((char *) data);
***************
*** 1776,1782 ****
          unibyte_string = string_make_unibyte (obj);
          *data_ret = XSTRING (unibyte_string)->data;
          *nofree_ret = 1;
!         *size_ret = STRING_BYTES (*data_ret);
        }
        else
        {
--- 1776,1782 ----
          unibyte_string = string_make_unibyte (obj);
          *data_ret = XSTRING (unibyte_string)->data;
          *nofree_ret = 1;
!         *size_ret = SBYTES (unibyte_string);
        }
        else
        {
***************
*** 1864,1873 ****
                Lisp_Object pair = XVECTOR (obj)->contents [i];
                if (XVECTOR (pair)->size != 2)
                  Fsignal (Qerror,
!                          Fcons (build_string 
         ("elements of the vector must be vectors of exactly two elements"),
                                  Fcons (pair, Qnil)));
!               
                (*(Atom **) data_ret) [i * 2]
                  = symbol_to_x_atom (dpyinfo, display,
                                      XVECTOR (pair)->contents [0]);
--- 1864,1873 ----
                Lisp_Object pair = XVECTOR (obj)->contents [i];
                if (XVECTOR (pair)->size != 2)
                  Fsignal (Qerror,
!                          Fcons (build_string
         ("elements of the vector must be vectors of exactly two elements"),
                                  Fcons (pair, Qnil)));
! 
                (*(Atom **) data_ret) [i * 2]
                  = symbol_to_x_atom (dpyinfo, display,
                                      XVECTOR (pair)->contents [0]);
***************
*** 1880,1886 ****
                       Fcons (build_string
                   ("all elements of the vector must be of the same type"),
                              Fcons (obj, Qnil)));
!         
        }
  #endif
        else
--- 1880,1886 ----
                       Fcons (build_string
                   ("all elements of the vector must be of the same type"),
                              Fcons (obj, Qnil)));
! 
        }
  #endif
        else
***************
*** 2124,2130 ****
    CHECK_SYMBOL (selection);
    if (EQ (selection, Qnil)) selection = QPRIMARY;
    if (EQ (selection, Qt)) selection = QSECONDARY;
!   
    if (NILP (Fassq (selection, Vselection_alist)))
      return Qnil;
    return Qt;
--- 2124,2130 ----
    CHECK_SYMBOL (selection);
    if (EQ (selection, Qnil)) selection = QPRIMARY;
    if (EQ (selection, Qt)) selection = QSECONDARY;
! 
    if (NILP (Fassq (selection, Vselection_alist)))
      return Qnil;
    return Qt;
***************
*** 2231,2237 ****
                         &type, &format, &size, 0);
    if (!data || !format)
      return Qnil;
!   
    if (format != 8 || type != XA_STRING)
      Fsignal (Qerror,
             Fcons (build_string ("cut buffer doesn't contain 8-bit data"),
--- 2231,2237 ----
                         &type, &format, &size, 0);
    if (!data || !format)
      return Qnil;
! 
    if (format != 8 || type != XA_STRING)
      Fsignal (Qerror,
             Fcons (build_string ("cut buffer doesn't contain 8-bit data"),



reply via email to

[Prev in Thread] Current Thread [Next in Thread]