X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/8cf06c7f74ccb33646dabf1553c4fdbbe030ae6a..498234263fef921c1fbb56a0830dc95d6449e024:/src/xselect.c diff --git a/src/xselect.c b/src/xselect.c index 17dc7c0e7d..d71ac42aa7 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -6,7 +6,7 @@ This file is part of GNU Emacs. GNU Emacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) +the Free Software Foundation; either version 3, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, @@ -398,12 +398,19 @@ x_own_selection (selection_name, selection_value) 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; + + 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); @@ -671,7 +678,8 @@ some_frame_on_display (dpyinfo) 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; } @@ -683,6 +691,10 @@ some_frame_on_display (dpyinfo) DATA and SIZE describe the data to send, already converted. FORMAT is the unit-size (in bits) of the data to be transmitted. */ +#ifdef TRACE_SELECTION +static int x_reply_selection_request_cnt; +#endif /* TRACE_SELECTION */ + static void x_reply_selection_request (event, format, data, size, type) struct input_event *event; @@ -721,10 +733,9 @@ x_reply_selection_request (event, format, data, size, type) #ifdef TRACE_SELECTION { - static int cnt; char *sel = XGetAtomName (display, reply.selection); char *tgt = XGetAtomName (display, reply.target); - TRACE3 ("%s, target %s (%d)", sel, tgt, ++cnt); + TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt); if (sel) XFree (sel); if (tgt) XFree (tgt); } @@ -1014,6 +1025,7 @@ x_handle_selection_clear (event) TRACE0 ("x_handle_selection_clear"); +#ifdef MULTI_KBOARD /* If the new selection owner is also Emacs, don't clear the new selection. */ BLOCK_INPUT; @@ -1021,7 +1033,7 @@ x_handle_selection_clear (event) 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->terminal->kboard == dpyinfo->terminal->kboard) { Window owner_window = XGetSelectionOwner (t_dpyinfo->display, selection); @@ -1032,7 +1044,8 @@ x_handle_selection_clear (event) } } UNBLOCK_INPUT; - +#endif + selection_symbol = x_atom_to_symbol (display, selection); local_selection_data = assq_no_quit (selection_symbol, Vselection_alist); @@ -1380,17 +1393,26 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp) 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 = SPECPDL_INDEX (); 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 @@ -1854,9 +1876,9 @@ selection_data_to_lisp_data (display, data, size, type, format) } } - /* Convert a single 16 or small 32 bit number to a Lisp_Int. - If the number is > 16 bits, convert it to a cons of integers, - 16 bits in each half. + /* Convert a single 16-bit number or a small 32-bit number to a Lisp_Int. + If the number is 32 bits and won't fit in a Lisp_Int, + convert it to a cons of integers, 16 bits in each half. */ else if (format == 32 && size == sizeof (int)) return long_to_cons (((unsigned int *) data) [0]); @@ -2206,6 +2228,9 @@ Disowning it means there is no such selection. */) 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); @@ -2367,6 +2392,10 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal, 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 */ @@ -2407,6 +2436,10 @@ DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal, 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 */ @@ -2463,8 +2496,12 @@ Positive means shift the values forward, negative means backward. */) 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);