comparison src/xselect.c @ 8101:77d5b5c8a71f

(x_own_selection, x_get_foreign_selection): Get rid of spurious X_TOOLKIT conditional. (x_own_selection): Put the frame in Vselection_alist. (x_clear_frame_selections): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 01 Jul 1994 00:46:37 +0000
parents cd81dba38a49
children 79494e6dc198
comparison
equal deleted inserted replaced
8100:eaaf6c8933b2 8101:77d5b5c8a71f
71 71
72 /* The timestamp of the last input event Emacs received from the X server. */ 72 /* The timestamp of the last input event Emacs received from the X server. */
73 unsigned long last_event_timestamp; 73 unsigned long last_event_timestamp;
74 74
75 /* This is an association list whose elements are of the form 75 /* This is an association list whose elements are of the form
76 ( selection-name selection-value selection-timestamp ) 76 ( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
77 selection-name is a lisp symbol, whose name is the name of an X Atom. 77 SELECTION-NAME is a lisp symbol, whose name is the name of an X Atom.
78 selection-value is the value that emacs owns for that selection. 78 SELECTION-VALUE is the value that emacs owns for that selection.
79 It may be any kind of Lisp object. 79 It may be any kind of Lisp object.
80 selection-timestamp is the time at which emacs began owning this selection, 80 SELECTION-TIMESTAMP is the time at which emacs began owning this selection,
81 as a cons of two 16-bit numbers (making a 32 bit time.) 81 as a cons of two 16-bit numbers (making a 32 bit time.)
82 If there is an entry in this alist, then it can be assumed that emacs owns 82 FRAME is the frame for which we made the selection.
83 If there is an entry in this alist, then it can be assumed that Emacs owns
83 that selection. 84 that selection.
84 The only (eq) parts of this list that are visible from Lisp are the 85 The only (eq) parts of this list that are visible from Lisp are the
85 selection-values. 86 selection-values.
86 */ 87 */
87 Lisp_Object Vselection_alist; 88 Lisp_Object Vselection_alist;
96 97
97 /* If the selection owner takes too long to reply to a selection request, 98 /* If the selection owner takes too long to reply to a selection request,
98 we give up on it. This is in milliseconds (0 = no timeout.) 99 we give up on it. This is in milliseconds (0 = no timeout.)
99 */ 100 */
100 int x_selection_timeout; 101 int x_selection_timeout;
101
102 102
103 /* Utility functions */ 103 /* Utility functions */
104 104
105 static void lisp_data_to_selection_data (); 105 static void lisp_data_to_selection_data ();
106 static Lisp_Object selection_data_to_lisp_data (); 106 static Lisp_Object selection_data_to_lisp_data ();
235 static void 235 static void
236 x_own_selection (selection_name, selection_value) 236 x_own_selection (selection_name, selection_value)
237 Lisp_Object selection_name, selection_value; 237 Lisp_Object selection_name, selection_value;
238 { 238 {
239 Display *display = x_current_display; 239 Display *display = x_current_display;
240 #ifdef X_TOOLKIT
241 Window selecting_window = XtWindow (selected_screen->display.x->edit_widget);
242 #else
243 Window selecting_window = FRAME_X_WINDOW (selected_frame); 240 Window selecting_window = FRAME_X_WINDOW (selected_frame);
244 #endif
245 Time time = last_event_timestamp; 241 Time time = last_event_timestamp;
246 Atom selection_atom; 242 Atom selection_atom;
247 243
248 CHECK_SYMBOL (selection_name, 0); 244 CHECK_SYMBOL (selection_name, 0);
249 selection_atom = symbol_to_x_atom (display, selection_name); 245 selection_atom = symbol_to_x_atom (display, selection_name);
262 Lisp_Object prev_value; 258 Lisp_Object prev_value;
263 259
264 selection_time = long_to_cons ((unsigned long) time); 260 selection_time = long_to_cons ((unsigned long) time);
265 selection_data = Fcons (selection_name, 261 selection_data = Fcons (selection_name,
266 Fcons (selection_value, 262 Fcons (selection_value,
267 Fcons (selection_time, Qnil))); 263 Fcons (selection_time,
264 Fcons (Fselected_frame (), Qnil))));
268 prev_value = assq_no_quit (selection_name, Vselection_alist); 265 prev_value = assq_no_quit (selection_name, Vselection_alist);
269 266
270 Vselection_alist = Fcons (selection_data, Vselection_alist); 267 Vselection_alist = Fcons (selection_data, Vselection_alist);
271 268
272 /* If we already owned the selection, remove the old selection data. 269 /* If we already owned the selection, remove the old selection data.
758 redisplay_preserve_echo_area (); 755 redisplay_preserve_echo_area ();
759 } 756 }
760 } 757 }
761 } 758 }
762 759
760 /* Clear all selections that were made from frame F.
761 We do this when about to delete a frame. */
762
763 void
764 x_clear_frame_selections (f)
765 FRAME_PTR f;
766 {
767 Lisp_Object frame;
768 Lisp_Object rest;
769
770 XSET (frame, Lisp_Frame, f);
771
772 /* Otherwise, we're really honest and truly being told to drop it.
773 Don't use Fdelq as that may QUIT;. */
774
775 while (!NILP (Vselection_alist)
776 && EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (Vselection_alist)))))))
777 {
778 /* Let random Lisp code notice that the selection has been stolen. */
779 Lisp_Object hooks, selection_symbol;
780
781 hooks = Vx_lost_selection_hooks;
782 selection_symbol = Fcar (Vselection_alist);
783
784 if (!EQ (hooks, Qunbound))
785 {
786 for (; CONSP (hooks); hooks = Fcdr (hooks))
787 call1 (Fcar (hooks), selection_symbol);
788 redisplay_preserve_echo_area ();
789 }
790
791 Vselection_alist = Fcdr (Vselection_alist);
792 }
793
794 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
795 if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCONS (rest)->cdr)))))))
796 {
797 /* Let random Lisp code notice that the selection has been stolen. */
798 Lisp_Object hooks, selection_symbol;
799
800 hooks = Vx_lost_selection_hooks;
801 selection_symbol = Fcar (XCONS (rest)->cdr);
802
803 if (!EQ (hooks, Qunbound))
804 {
805 for (; CONSP (hooks); hooks = Fcdr (hooks))
806 call1 (Fcar (hooks), selection_symbol);
807 redisplay_preserve_echo_area ();
808 }
809 XCONS (rest)->cdr = Fcdr (XCONS (rest)->cdr);
810 break;
811 }
812 }
763 813
764 /* Nonzero if any properties for DISPLAY and WINDOW 814 /* Nonzero if any properties for DISPLAY and WINDOW
765 are on the list of what we are waiting for. */ 815 are on the list of what we are waiting for. */
766 816
767 static int 817 static int
978 static Lisp_Object 1028 static Lisp_Object
979 x_get_foreign_selection (selection_symbol, target_type) 1029 x_get_foreign_selection (selection_symbol, target_type)
980 Lisp_Object selection_symbol, target_type; 1030 Lisp_Object selection_symbol, target_type;
981 { 1031 {
982 Display *display = x_current_display; 1032 Display *display = x_current_display;
983 #ifdef X_TOOLKIT
984 Window requestor_window = XtWindow (selected_screen->display.x->edit_widget);
985 #else
986 Window requestor_window = FRAME_X_WINDOW (selected_frame); 1033 Window requestor_window = FRAME_X_WINDOW (selected_frame);
987 #endif
988 Time requestor_time = last_event_timestamp; 1034 Time requestor_time = last_event_timestamp;
989 Atom target_property = Xatom_EMACS_TMP; 1035 Atom target_property = Xatom_EMACS_TMP;
990 Atom selection_atom = symbol_to_x_atom (display, selection_symbol); 1036 Atom selection_atom = symbol_to_x_atom (display, selection_symbol);
991 Atom type_atom; 1037 Atom type_atom;
992 int secs, usecs; 1038 int secs, usecs;