Lisp_Object selection_name, selection_value;
{
struct frame *sf = SELECTED_FRAME ();
- Window selecting_window = FRAME_X_WINDOW (sf);
- Display *display = FRAME_X_DISPLAY (sf);
+ Window selecting_window;
+ Display *display;
Time time = last_event_timestamp;
Atom selection_atom;
- struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf);
+ struct x_display_info *dpyinfo;
int count;
+ if (! FRAME_X_P (sf))
+ return;
+
+ selecting_window = FRAME_X_WINDOW (sf);
+ display = FRAME_X_DISPLAY (sf);
+ dpyinfo = FRAME_X_DISPLAY_INFO (sf);
+
CHECK_SYMBOL (selection_name);
selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
FOR_EACH_FRAME (list, frame)
{
- if (FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
+ if (FRAME_X_P (XFRAME (frame))
+ && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
return frame;
}
to see if this Emacs job now owns the selection
through that display. */
for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next)
- if (t_dpyinfo->kboard == dpyinfo->kboard)
+ if (t_dpyinfo->frame_display->kboard == dpyinfo->frame_display->kboard)
{
Window owner_window
= XGetSelectionOwner (t_dpyinfo->display, selection);
Lisp_Object selection_symbol, target_type, time_stamp;
{
struct frame *sf = SELECTED_FRAME ();
- Window requestor_window = FRAME_X_WINDOW (sf);
- Display *display = FRAME_X_DISPLAY (sf);
- struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf);
+ Window requestor_window;
+ Display *display;
+ struct x_display_info *dpyinfo;
Time requestor_time = last_event_timestamp;
- Atom target_property = dpyinfo->Xatom_EMACS_TMP;
- Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol);
+ Atom target_property;
+ Atom selection_atom;
Atom type_atom;
int secs, usecs;
int count;
Lisp_Object frame;
+ if (! FRAME_X_P (sf))
+ return Qnil;
+
+ requestor_window = FRAME_X_WINDOW (sf);
+ display = FRAME_X_DISPLAY (sf);
+ dpyinfo = FRAME_X_DISPLAY_INFO (sf);
+ target_property = dpyinfo->Xatom_EMACS_TMP;
+ selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol);
+
if (CONSP (target_type))
type_atom = symbol_to_x_atom (dpyinfo, display, XCAR (target_type));
else
When converting an object to C, it may be of the form (SYMBOL . <data>)
where SYMBOL is what we should claim that the type is. Format and
- representation are as above. */
+ representation are as above.
+
+ Important: When format is 32, data should contain an array of int,
+ not an array of long as the X library returns. This makes a difference
+ when sizeof(long) != sizeof(int). */
else if (type == XA_ATOM)
{
int i;
- if (size == sizeof (Atom))
- return x_atom_to_symbol (display, *((Atom *) data));
+ /* On a 64 bit machine sizeof(Atom) == sizeof(long) == 8.
+ But the callers of these function has made sure the data for
+ format == 32 is an array of int. Thus, use int instead
+ of Atom. */
+ int *idata = (int *) data;
+
+ if (size == sizeof (int))
+ return x_atom_to_symbol (display, (Atom) idata[0]);
else
{
- Lisp_Object v = Fmake_vector (make_number (size / sizeof (Atom)),
+ Lisp_Object v = Fmake_vector (make_number (size / sizeof (int)),
make_number (0));
- for (i = 0; i < size / sizeof (Atom); i++)
+ for (i = 0; i < size / sizeof (int); i++)
Faset (v, make_number (i),
- x_atom_to_symbol (display, ((Atom *) data) [i]));
+ x_atom_to_symbol (display, (Atom) idata[i]));
return v;
}
}
}
else if (STRINGP (obj))
{
- xassert (! STRING_MULTIBYTE (obj));
+ if (SCHARS (obj) < SBYTES (obj))
+ /* OBJ is a multibyte string containing a non-ASCII char. */
+ Fsignal (Qerror, /* Qselection_error */
+ Fcons (build_string
+ ("Non-ASCII string must be encoded in advance"),
+ Fcons (obj, Qnil)));
if (NILP (type))
type = QSTRING;
*format_ret = 8;
/* Use sizeof(long) even if it is more than 32 bits. See comment
in x_get_window_property and x_fill_property_data. */
-
+
if (*format_ret == 32) data_size = sizeof(long);
*data_ret = (unsigned char *) xmalloc (*size_ret * data_size);
for (i = 0; i < *size_ret; i++)
}
else
Fsignal (Qerror, /* Qselection_error */
- Fcons (build_string ("unrecognised selection data"),
+ Fcons (build_string ("unrecognized selection data"),
Fcons (obj, Qnil)));
*type_ret = symbol_to_x_atom (dpyinfo, display, type);
{
check_x ();
CHECK_SYMBOL (selection_name);
- if (NILP (selection_value)) error ("selection-value may not be nil");
+ if (NILP (selection_value)) error ("SELECTION-VALUE may not be nil");
x_own_selection (selection_name, selection_value);
return selection_value;
}
{
Time timestamp;
Atom selection_atom;
- struct selection_input_event event;
+ union {
+ struct selection_input_event sie;
+ struct input_event ie;
+ } event;
Display *display;
struct x_display_info *dpyinfo;
struct frame *sf = SELECTED_FRAME ();
check_x ();
+ if (! FRAME_X_P (sf))
+ return Qnil;
+
display = FRAME_X_DISPLAY (sf);
dpyinfo = FRAME_X_DISPLAY_INFO (sf);
CHECK_SYMBOL (selection);
the selection owner to None. The NCD server does, the MIT Sun4 server
doesn't. So we synthesize one; this means we might get two, but
that's ok, because the second one won't have any effect. */
- SELECTION_EVENT_DISPLAY (&event) = display;
- SELECTION_EVENT_SELECTION (&event) = selection_atom;
- SELECTION_EVENT_TIME (&event) = timestamp;
- x_handle_selection_clear ((struct input_event *) &event);
+ SELECTION_EVENT_DISPLAY (&event.sie) = display;
+ SELECTION_EVENT_SELECTION (&event.sie) = selection_atom;
+ SELECTION_EVENT_TIME (&event.sie) = timestamp;
+ x_handle_selection_clear (&event.ie);
return Qt;
}
struct frame *sf = SELECTED_FRAME ();
check_x ();
+
+ if (! FRAME_X_P (sf))
+ return Qnil;
+
display = FRAME_X_DISPLAY (sf);
dpyinfo = FRAME_X_DISPLAY_INFO (sf);
window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
struct frame *sf = SELECTED_FRAME ();
check_x ();
+
+ if (! FRAME_X_P (sf))
+ return Qnil;
+
display = FRAME_X_DISPLAY (sf);
window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
Atom props[8];
Display *display;
struct frame *sf = SELECTED_FRAME ();
-
+
check_x ();
+
+ if (! FRAME_X_P (sf))
+ return Qnil;
+
display = FRAME_X_DISPLAY (sf);
window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
CHECK_NUMBER (n);
be stored in RET.
SIZE is the number of elements in DATA.
+ Important: When format is 32, data should contain an array of int,
+ not an array of long as the X library returns. This makes a difference
+ when sizeof(long) != sizeof(int).
+
Also see comment for selection_data_to_lisp_data above. */
Lisp_Object
when sending to the root window. */
event.xclient.window = to_root ? FRAME_OUTER_WINDOW (f) : wdest;
-
+
memset (event.xclient.data.b, 0, sizeof (event.xclient.data.b));
x_fill_property_data (dpyinfo->display, values, event.xclient.data.b,
event.xclient.format);