/* X Selection processing for Emacs.
- Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000 Free Software Foundation.
This file is part of GNU Emacs.
#include "charset.h"
#include "coding.h"
#include "process.h"
+#include "composite.h"
#define CUT_BUFFER_SUPPORT
It is set to zero when the request is fully processed. */
static struct input_event *x_selection_current_request;
+/* Display info in x_selection_request. */
+
+static struct x_display_info *selection_request_dpyinfo;
+
/* Used as an unwind-protect clause so that, if a selection-converter signals
an error, we tell the requester that we were unable to do what they wanted
before we throw to top-level or go into the debugger or whatever. */
x_selection_request_lisp_error (ignore)
Lisp_Object ignore;
{
- if (x_selection_current_request != 0)
+ if (x_selection_current_request != 0
+ && selection_request_dpyinfo->display)
x_decline_selection_request (x_selection_current_request);
return Qnil;
}
PropModeReplace, data, 0);
}
+ /* The window we're communicating with may have been deleted
+ in the meantime (that's a real situation from a bug report).
+ In this case, there may be events in the event queue still
+ refering to the deleted window, and we'll get a BadWindow error
+ in XTread_socket when processing the events. I don't have
+ an idea how to fix that. gerd, 2001-01-98. */
XFlush (display);
x_uncatch_errors (display, count);
UNBLOCK_INPUT;
goto DONE;
}
- count = specpdl_ptr - specpdl;
x_selection_current_request = event;
+ count = BINDING_STACK_SIZE ();
+ selection_request_dpyinfo = dpyinfo;
record_unwind_protect (x_selection_request_lisp_error, Qnil);
target_symbol = x_atom_to_symbol (dpyinfo, SELECTION_EVENT_DISPLAY (event),
for (; CONSP (rest); rest = Fcdr (rest))
call1 (Fcar (rest), selection_symbol);
prepare_menu_bars ();
- redisplay_preserve_echo_area ();
+ redisplay_preserve_echo_area (20);
}
}
}
#if 0 /* This can crash when deleting a frame
from x_connection_closed. Anyway, it seems unnecessary;
something else should cause a redisplay. */
- redisplay_preserve_echo_area ();
+ redisplay_preserve_echo_area (21);
#endif
}
for (; CONSP (hooks); hooks = Fcdr (hooks))
call1 (Fcar (hooks), selection_symbol);
#if 0 /* See above */
- redisplay_preserve_echo_area ();
+ redisplay_preserve_echo_area (22);
#endif
}
XCDR (rest) = Fcdr (XCDR (rest));
Vnext_selection_coding_system = Vselection_coding_system;
setup_coding_system
(Fcheck_coding_system(Vnext_selection_coding_system), &coding);
+ coding.src_multibyte = 0;
+ coding.dst_multibyte = 1;
Vnext_selection_coding_system = Qnil;
coding.mode |= CODING_MODE_LAST_BLOCK;
bufsize = decoding_buffer_size (&coding, size);
buf = (unsigned char *) xmalloc (bufsize);
decode_coding (&coding, data, buf, size, bufsize);
- size = (coding.fake_multibyte
- ? multibyte_chars_in_text (buf, coding.produced)
- : coding.produced_char);
- str = make_string_from_bytes ((char *) buf, size, coding.produced);
+ str = make_string_from_bytes ((char *) buf,
+ coding.produced_char, coding.produced);
xfree (buf);
Vlast_coding_system_used = coding.symbol;
}
+ compose_chars_in_text (0, XSTRING (str)->size, str);
return str;
}
/* Convert a single atom to a Lisp_Symbol. Convert a set of atoms to
{
/* Since we are now handling multilingual text, we must consider
sending back compound text. */
- int charsets[MAX_CHARSET + 1];
- int num;
+ int stringp;
- *format_ret = 8;
- *size_ret = STRING_BYTES (XSTRING (obj));
- *data_ret = XSTRING (obj)->data;
- bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));
- num = ((*size_ret <= 1 /* Check the possibility of short cut. */
- || !STRING_MULTIBYTE (obj)
- || *size_ret == XSTRING (obj)->size)
- ? 0
- : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil, 0, 1));
-
- if (!num || (num == 1 && charsets[CHARSET_ASCII]))
- {
- /* No multibyte character in OBJ. We need not encode it. */
- *nofree_ret = 1;
- if (NILP (type)) type = QSTRING;
- Vlast_coding_system_used = Qraw_text;
- }
- else
- {
- /* We must encode contents of OBJ to compound text format.
- The format is compatible with what the target `STRING'
- expects if OBJ contains only ASCII and Latin-1
- characters. */
- int bufsize;
- unsigned char *buf;
- struct coding_system coding;
+ if (NILP (Vnext_selection_coding_system))
+ Vnext_selection_coding_system = Vselection_coding_system;
- if (NILP (Vnext_selection_coding_system))
- Vnext_selection_coding_system = Vselection_coding_system;
- setup_coding_system
- (Fcheck_coding_system (Vnext_selection_coding_system), &coding);
- Vnext_selection_coding_system = Qnil;
- coding.mode |= CODING_MODE_LAST_BLOCK;
- bufsize = encoding_buffer_size (&coding, *size_ret);
- buf = (unsigned char *) xmalloc (bufsize);
- encode_coding (&coding, *data_ret, buf, *size_ret, bufsize);
- *size_ret = coding.produced;
- *data_ret = buf;
- if (charsets[charset_latin_iso8859_1]
- && (num == 1 || (num == 2 && charsets[CHARSET_ASCII])))
- {
- /* Ok, we can return it as `STRING'. */
- if (NILP (type)) type = QSTRING;
- }
- else
- {
- /* We must return it as `COMPOUND_TEXT'. */
- if (NILP (type)) type = QCOMPOUND_TEXT;
- }
- Vlast_coding_system_used = coding.symbol;
- }
+ *format_ret = 8;
+ *data_ret = x_encode_text (obj, Vnext_selection_coding_system,
+ (int *) size_ret, &stringp);
+ *nofree_ret = (*data_ret == XSTRING (obj)->data);
+ if (NILP (type))
+ type = (stringp ? QSTRING : QCOMPOUND_TEXT);
+ Vlast_coding_system_used = (*nofree_ret
+ ? Qraw_text
+ : Vnext_selection_coding_system);
+ Vnext_selection_coding_system = Qnil;
}
else if (SYMBOLP (obj))
{