diff options
Diffstat (limited to 'src/xselect.c')
-rw-r--r-- | src/xselect.c | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/src/xselect.c b/src/xselect.c index 156f3bf1302..74d107e8ca4 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -140,11 +140,7 @@ static Lisp_Object Qforeign_selection; incremental transfer stuff, but it might improve server performance. */ #define MAX_SELECTION_QUANTUM 0xFFFFFF -#ifdef HAVE_X11R4 #define SELECTION_QUANTUM(dpy) ((XMaxRequestSize(dpy) << 2) - 100) -#else -#define SELECTION_QUANTUM(dpy) (((dpy)->max_request_size << 2) - 100) -#endif /* The timestamp of the last input event Emacs received from the X server. */ /* Defined in keyboard.c. */ @@ -398,12 +394,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); @@ -435,7 +438,7 @@ x_own_selection (selection_name, selection_value) if (!NILP (prev_value)) { Lisp_Object rest; /* we know it's not the CAR, so it's easy. */ - for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest)) + for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest)) if (EQ (prev_value, Fcar (XCDR (rest)))) { XSETCDR (rest, Fcdr (XCDR (rest))); @@ -671,7 +674,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; } @@ -1017,6 +1021,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; @@ -1024,7 +1029,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); @@ -1035,7 +1040,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); @@ -1062,7 +1068,7 @@ x_handle_selection_clear (event) else { Lisp_Object rest; - for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest)) + for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest)) if (EQ (local_selection_data, Fcar (XCDR (rest)))) { XSETCDR (rest, Fcdr (XCDR (rest))); @@ -1143,7 +1149,7 @@ x_clear_frame_selections (f) } /* Delete elements after the beginning of Vselection_alist. */ - for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest)) + for (rest = Vselection_alist; CONSP (rest); rest = XCDR (rest)) if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCDR (rest)))))))) { /* Let random Lisp code notice that the selection has been stolen. */ @@ -1383,17 +1389,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 @@ -2209,6 +2224,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); @@ -2370,6 +2388,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 */ @@ -2410,6 +2432,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 */ @@ -2466,8 +2492,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); @@ -2681,7 +2711,7 @@ If the value is 0 or the atom is not known, return the empty string. */) ret = make_string (name, strlen (name)); if (atom && name) XFree (name); - if (NILP (ret)) ret = make_string ("", 0); + if (NILP (ret)) ret = empty_unibyte_string; UNBLOCK_INPUT; |