aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2007-01-22 08:27:23 +0000
committerYAMAMOTO Mitsuharu2007-01-22 08:27:23 +0000
commit1879b65c3d6a2c939ef57008bbce0adf7f367e07 (patch)
tree6fd89db06a7c96077729a61ef4dfbcd6236e1b01
parentcddbf85a957be83bc098113b8611c725f8a502ee (diff)
downloademacs-1879b65c3d6a2c939ef57008bbce0adf7f367e07.tar.gz
emacs-1879b65c3d6a2c939ef57008bbce0adf7f367e07.zip
(mac-keyboard-modifier-mask-alist): New constant.
(mac-ae-keyboard-modifiers): New function. (mac-handle-toolbar-switch-mode): Use it. (mac-dnd-handle-drag-n-drop-event): Likewise. Set action to `copy' if keyboard modifiers on drop contain option key. (mac-dnd-drop-data): Add optional argument `action'. (special-event-map): Remove binding for M-drag-n-drop.
-rw-r--r--lisp/term/mac-win.el40
1 files changed, 31 insertions, 9 deletions
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index c5817b57a08..be4c978dd28 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -1687,6 +1687,26 @@ in `selection-converter-alist', which see."
1687 (+ (* i 10) 12))))) 1687 (+ (* i 10) 12)))))
1688 result)) 1688 result))
1689 1689
1690(defconst mac-keyboard-modifier-mask-alist
1691 (mapcar
1692 (lambda (modifier-bit)
1693 (cons (car modifier-bit) (lsh 1 (cdr modifier-bit))))
1694 '((command . 8) ; cmdKeyBit
1695 (shift . 9) ; shiftKeyBit
1696 (option . 11) ; optionKeyBit
1697 (control . 12) ; controlKeyBit
1698 (function . 17))) ; kEventKeyModifierFnBit
1699 "Alist of Mac keyboard modifier symbols vs masks.")
1700
1701(defun mac-ae-keyboard-modifiers (ae)
1702 (let ((modifiers-value (mac-ae-number ae "kmod"))
1703 modifiers)
1704 (if modifiers-value
1705 (dolist (modifier-mask mac-keyboard-modifier-mask-alist)
1706 (if (/= (logand modifiers-value (cdr modifier-mask)) 0)
1707 (setq modifiers (cons (car modifier-mask) modifiers)))))
1708 modifiers))
1709
1690(defun mac-ae-open-documents (event) 1710(defun mac-ae-open-documents (event)
1691 "Open the documents specified by the Apple event EVENT." 1711 "Open the documents specified by the Apple event EVENT."
1692 (interactive "e") 1712 (interactive "e")
@@ -1762,9 +1782,8 @@ With no keyboard modifiers, it toggles the visibility of the
1762frame where the tool-bar toggle button was pressed. With some 1782frame where the tool-bar toggle button was pressed. With some
1763modifiers, it changes global tool-bar visibility setting." 1783modifiers, it changes global tool-bar visibility setting."
1764 (interactive "e") 1784 (interactive "e")
1765 (let* ((ae (mac-event-ae event)) 1785 (let ((ae (mac-event-ae event)))
1766 (modifiers (cdr (mac-ae-parameter ae "kmod")))) 1786 (if (mac-ae-keyboard-modifiers ae)
1767 (if (and modifiers (not (string= modifiers "\000\000\000\000")))
1768 ;; Globally toggle tool-bar-mode if some modifier key is pressed. 1787 ;; Globally toggle tool-bar-mode if some modifier key is pressed.
1769 (tool-bar-mode) 1788 (tool-bar-mode)
1770 (let ((frame (mac-ae-frame ae))) 1789 (let ((frame (mac-ae-frame ae)))
@@ -2221,10 +2240,10 @@ See also `mac-dnd-known-types'."
2221(defun mac-dnd-insert-TIFF (window action data) 2240(defun mac-dnd-insert-TIFF (window action data)
2222 (dnd-insert-text window action (mac-TIFF-to-string data))) 2241 (dnd-insert-text window action (mac-TIFF-to-string data)))
2223 2242
2224(defun mac-dnd-drop-data (event frame window data type) 2243(defun mac-dnd-drop-data (event frame window data type &optional action)
2244 (or action (setq action 'private))
2225 (let* ((type-info (assoc type mac-dnd-types-alist)) 2245 (let* ((type-info (assoc type mac-dnd-types-alist))
2226 (handler (cdr type-info)) 2246 (handler (cdr type-info))
2227 (action 'private)
2228 (w (posn-window (event-start event)))) 2247 (w (posn-window (event-start event))))
2229 (when handler 2248 (when handler
2230 (if (and (windowp w) (window-live-p w) 2249 (if (and (windowp w) (window-live-p w)
@@ -2245,12 +2264,16 @@ See also `mac-dnd-known-types'."
2245(defun mac-dnd-handle-drag-n-drop-event (event) 2264(defun mac-dnd-handle-drag-n-drop-event (event)
2246 "Receive drag and drop events." 2265 "Receive drag and drop events."
2247 (interactive "e") 2266 (interactive "e")
2248 (let ((window (posn-window (event-start event)))) 2267 (let ((window (posn-window (event-start event)))
2268 (ae (mac-event-ae event))
2269 action)
2249 (when (windowp window) (select-window window)) 2270 (when (windowp window) (select-window window))
2250 (dolist (item (mac-ae-list (mac-event-ae event))) 2271 (if (memq 'option (mac-ae-keyboard-modifiers ae))
2272 (setq action 'copy))
2273 (dolist (item (mac-ae-list ae))
2251 (if (not (equal (car item) "null")) 2274 (if (not (equal (car item) "null"))
2252 (mac-dnd-drop-data event (selected-frame) window 2275 (mac-dnd-drop-data event (selected-frame) window
2253 (cdr item) (car item))))) 2276 (cdr item) (car item) action))))
2254 (select-frame-set-input-focus (selected-frame))) 2277 (select-frame-set-input-focus (selected-frame)))
2255 2278
2256;;; Do the actual Windows setup here; the above code just defines 2279;;; Do the actual Windows setup here; the above code just defines
@@ -2591,7 +2614,6 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
2591;; Initiate drag and drop 2614;; Initiate drag and drop
2592 2615
2593(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event) 2616(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2594(define-key special-event-map [M-drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2595 2617
2596 2618
2597;;;; Non-toolkit Scroll bars 2619;;;; Non-toolkit Scroll bars