summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-05-27 12:17:59 -0400
committerChong Yidong <cyd@stupidchicken.com>2011-05-27 12:17:59 -0400
commita9f737eef69ffe03dd045df555300ae6b41d0edf (patch)
tree515b335a2f07a324ecc71b6a9331b7e0bc712586 /lisp/select.el
parentbe520aca79dd429d55012a1916bdc97f06773fc5 (diff)
downloademacs-a9f737eef69ffe03dd045df555300ae6b41d0edf.tar.gz
Support X clipboard managers.
* lisp/select.el (xselect-convert-to-targets): Add MULTIPLE target to list. (xselect-convert-to-save-targets): New function. * src/xselect.c: Support for clipboard managers. (Vselection_alist): Move to termhooks.h as terminal-local var. (LOCAL_SELECTION): New macro. (x_atom_to_symbol): Handle x_display_info_for_display fail case. (symbol_to_x_atom): Remove gratuitous arg. (x_handle_selection_request, lisp_data_to_selection_data) (x_get_foreign_selection, Fx_register_dnd_atom): Callers changed. (x_own_selection, x_get_local_selection, x_convert_selection): New arg, specifying work frame. Use terminal-local Vselection_alist. (some_frame_on_display): Delete unused function. (Fx_own_selection_internal, Fx_get_selection_internal) (Fx_disown_selection_internal, Fx_selection_owner_p) (Fx_selection_exists_p): New optional frame arg. (frame_for_x_selection, Fx_clipboard_manager_save): New functions. (x_handle_selection_clear): Don't treat other terminals with the same keyboard specially. Use the terminal-local Vselection_alist. (x_clear_frame_selections): Use Frun_hook_with_args. * src/termhooks.h (Vselection_alist): Make it terminal-local. * src/terminal.c (create_terminal): Initialize it. * src/xterm.c (x_term_init): Intern ATOM and CLIPBOARD_MANAGER atoms. * src/xterm.h: Add support for those atoms.
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/select.el b/lisp/select.el
index 1f5191e86c1..5abbf8f795d 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -289,7 +289,9 @@ two markers or an overlay. Otherwise, it is nil."
(defun xselect-convert-to-targets (_selection _type _value)
;; return a vector of atoms, but remove duplicates first.
- (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
+ (let* ((all (cons 'TIMESTAMP
+ (cons 'MULTIPLE
+ (mapcar 'car selection-converter-alist))))
(rest all))
(while rest
(cond ((memq (car rest) (cdr rest))
@@ -365,6 +367,12 @@ This function returns the string \"emacs\"."
(defun xselect-convert-to-identity (_selection _type value) ; used internally
(vector value))
+;; Null target that tells clipboard managers we support SAVE_TARGETS
+;; (see freedesktop.org Clipboard Manager spec).
+(defun xselect-convert-to-save-targets (selection _type _value)
+ (when (eq selection 'CLIPBOARD)
+ 'NULL))
+
(setq selection-converter-alist
'((TEXT . xselect-convert-to-string)
(COMPOUND_TEXT . xselect-convert-to-string)
@@ -384,8 +392,13 @@ This function returns the string \"emacs\"."
(NAME . xselect-convert-to-name)
(ATOM . xselect-convert-to-atom)
(INTEGER . xselect-convert-to-integer)
+ (SAVE_TARGETS . xselect-convert-to-save-targets)
(_EMACS_INTERNAL . xselect-convert-to-identity)))
+(when (fboundp 'x-clipboard-manager-save)
+ (add-hook 'delete-frame-functions 'x-clipboard-manager-save)
+ (add-hook 'kill-emacs-hook 'x-clipboard-manager-save))
+
(provide 'select)
;;; select.el ends here