diff options
Diffstat (limited to 'src/xselect.c')
| -rw-r--r-- | src/xselect.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/src/xselect.c b/src/xselect.c index 8741cb89967..0f852a7c382 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -2107,6 +2107,7 @@ frame's display, or the first available X display. */) | |||
| 2107 | return (owner ? Qt : Qnil); | 2107 | return (owner ? Qt : Qnil); |
| 2108 | } | 2108 | } |
| 2109 | 2109 | ||
| 2110 | |||
| 2110 | /* Send the clipboard manager a SAVE_TARGETS request with a | 2111 | /* Send the clipboard manager a SAVE_TARGETS request with a |
| 2111 | UTF8_STRING property, as described by | 2112 | UTF8_STRING property, as described by |
| 2112 | http://www.freedesktop.org/wiki/ClipboardManager */ | 2113 | http://www.freedesktop.org/wiki/ClipboardManager */ |
| @@ -2126,54 +2127,53 @@ x_clipboard_manager_save (struct x_display_info *dpyinfo, | |||
| 2126 | Qnil, frame); | 2127 | Qnil, frame); |
| 2127 | } | 2128 | } |
| 2128 | 2129 | ||
| 2129 | DEFUN ("x-clipboard-manager-save", Fx_clipboard_manager_save, | 2130 | /* Called from delete_frame: save any clipboard owned by FRAME to the |
| 2130 | Sx_clipboard_manager_save, 0, 1, 0, | 2131 | clipboard manager. Do nothing if FRAME does not own the clipboard, |
| 2131 | doc: /* Save the clipboard contents to the clipboard manager. | 2132 | or if no clipboard manager is present. */ |
| 2132 | This function is intended to run from `delete-frame-functions' and | 2133 | |
| 2133 | `kill-emacs-hook', to transfer clipboard data owned by Emacs to a | 2134 | void |
| 2134 | clipboard manager prior to deleting a frame or killing Emacs. | 2135 | x_clipboard_manager_save_frame (Lisp_Object frame) |
| 2135 | |||
| 2136 | FRAME specifies a frame owning a clipboard; do nothing if FRAME does | ||
| 2137 | not own the clipboard, or if no clipboard manager is present. If | ||
| 2138 | FRAME is nil, save all clipboard contents owned by Emacs. */) | ||
| 2139 | (Lisp_Object frame) | ||
| 2140 | { | 2136 | { |
| 2141 | if (FRAMEP (frame)) | 2137 | struct frame *f; |
| 2138 | |||
| 2139 | if (FRAMEP (frame) | ||
| 2140 | && (f = XFRAME (frame), FRAME_X_P (f)) | ||
| 2141 | && FRAME_LIVE_P (f)) | ||
| 2142 | { | 2142 | { |
| 2143 | struct frame *f = XFRAME (frame); | 2143 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 2144 | if (FRAME_LIVE_P (f) && FRAME_X_P (f)) | 2144 | Lisp_Object local_selection |
| 2145 | { | 2145 | = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); |
| 2146 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 2146 | |
| 2147 | Lisp_Object local_selection | 2147 | if (!NILP (local_selection) |
| 2148 | = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); | 2148 | && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection))))) |
| 2149 | 2149 | && XGetSelectionOwner (dpyinfo->display, | |
| 2150 | if (!NILP (local_selection) | 2150 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) |
| 2151 | && EQ (frame, XCAR (XCDR (XCDR (XCDR (local_selection))))) | 2151 | x_clipboard_manager_save (dpyinfo, frame); |
| 2152 | && XGetSelectionOwner (dpyinfo->display, | ||
| 2153 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) | ||
| 2154 | x_clipboard_manager_save (dpyinfo, frame); | ||
| 2155 | } | ||
| 2156 | } | 2152 | } |
| 2157 | else if (NILP (frame)) | 2153 | } |
| 2154 | |||
| 2155 | /* Called from Fkill_emacs: save any clipboard owned by FRAME to the | ||
| 2156 | clipboard manager. Do nothing if FRAME does not own the clipboard, | ||
| 2157 | or if no clipboard manager is present. */ | ||
| 2158 | |||
| 2159 | void | ||
| 2160 | x_clipboard_manager_save_all (void) | ||
| 2161 | { | ||
| 2162 | /* Loop through all X displays, saving owned clipboards. */ | ||
| 2163 | struct x_display_info *dpyinfo; | ||
| 2164 | Lisp_Object local_selection, local_frame; | ||
| 2165 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | ||
| 2158 | { | 2166 | { |
| 2159 | /* Loop through all X displays, saving owned clipboards. */ | 2167 | local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); |
| 2160 | struct x_display_info *dpyinfo; | 2168 | if (NILP (local_selection) |
| 2161 | Lisp_Object local_selection, local_frame; | 2169 | || !XGetSelectionOwner (dpyinfo->display, |
| 2162 | for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) | 2170 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) |
| 2163 | { | 2171 | continue; |
| 2164 | local_selection = LOCAL_SELECTION (QCLIPBOARD, dpyinfo); | ||
| 2165 | if (NILP (local_selection) | ||
| 2166 | || !XGetSelectionOwner (dpyinfo->display, | ||
| 2167 | dpyinfo->Xatom_CLIPBOARD_MANAGER)) | ||
| 2168 | continue; | ||
| 2169 | |||
| 2170 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); | ||
| 2171 | if (FRAME_LIVE_P (XFRAME (local_frame))) | ||
| 2172 | x_clipboard_manager_save (dpyinfo, local_frame); | ||
| 2173 | } | ||
| 2174 | } | ||
| 2175 | 2172 | ||
| 2176 | return Qnil; | 2173 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); |
| 2174 | if (FRAME_LIVE_P (XFRAME (local_frame))) | ||
| 2175 | x_clipboard_manager_save (dpyinfo, local_frame); | ||
| 2176 | } | ||
| 2177 | } | 2177 | } |
| 2178 | 2178 | ||
| 2179 | 2179 | ||
| @@ -2586,7 +2586,6 @@ syms_of_xselect (void) | |||
| 2586 | defsubr (&Sx_disown_selection_internal); | 2586 | defsubr (&Sx_disown_selection_internal); |
| 2587 | defsubr (&Sx_selection_owner_p); | 2587 | defsubr (&Sx_selection_owner_p); |
| 2588 | defsubr (&Sx_selection_exists_p); | 2588 | defsubr (&Sx_selection_exists_p); |
| 2589 | defsubr (&Sx_clipboard_manager_save); | ||
| 2590 | 2589 | ||
| 2591 | defsubr (&Sx_get_atom_name); | 2590 | defsubr (&Sx_get_atom_name); |
| 2592 | defsubr (&Sx_send_client_message); | 2591 | defsubr (&Sx_send_client_message); |