diff options
| author | Jan Djärv | 2013-12-19 11:25:48 +0100 |
|---|---|---|
| committer | Jan Djärv | 2013-12-19 11:25:48 +0100 |
| commit | 1269a680862a9bc6cd65e3d26ef05f68c7521632 (patch) | |
| tree | 1160cb3afcd5b77d2240c276029289ce38feffc1 | |
| parent | 680e6b8c5a28489733df544edb074fd29d0522a0 (diff) | |
| download | emacs-1269a680862a9bc6cd65e3d26ef05f68c7521632.tar.gz emacs-1269a680862a9bc6cd65e3d26ef05f68c7521632.zip | |
Make NS port use the normal dnd functions.
* lisp/term/ns-win.el: Require dnd.
(global-map): Remove drag items.
(ns-insert-text, ns-set-foreground-at-mouse)
(ns-set-background-at-mouse): Remove
(ns-drag-n-drop, ns-drag-n-drop-other-frame)
(ns-drag-n-drop-as-text, ns-drag-n-drop-as-text-other-frame): New
functions.
* src/nsterm.h (KEY_NS_DRAG_FILE, KEY_NS_DRAG_COLOR, KEY_NS_DRAG_TEXT):
Remove.
* src/nsterm.m (Qfile, Qurl): New.
(EV_MODIFIERS2): New macro.
(EV_MODIFIERS): Use EV_MODIFIERS2.
(ns_term_init): Remove font and color from DND, does not work on
newer OSX, and other ports don't have them.
(performDragOperation:): Handle modifiers used during drag.
Use DRAG_N_DROP_EVENT instead of NS specific events.
Remove global Lisp variables used to communicate with ns-win.el.
Remove font and color handling.
(syms_of_nsterm): Defsym Qfile and Qurl.
Fixes: debbugs:8051
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 91 | ||||
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/nsterm.h | 3 | ||||
| -rw-r--r-- | src/nsterm.m | 127 |
5 files changed, 124 insertions, 123 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 249f629b5f4..336a7caa8ed 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-12-19 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * term/ns-win.el: Require dnd. | ||
| 4 | (global-map): Remove drag items. | ||
| 5 | (ns-insert-text, ns-set-foreground-at-mouse) | ||
| 6 | (ns-set-background-at-mouse): Remove | ||
| 7 | (ns-drag-n-drop, ns-drag-n-drop-other-frame) | ||
| 8 | (ns-drag-n-drop-as-text, ns-drag-n-drop-as-text-other-frame): New | ||
| 9 | functions. | ||
| 10 | |||
| 1 | 2013-12-19 Glenn Morris <rgm@gnu.org> | 11 | 2013-12-19 Glenn Morris <rgm@gnu.org> |
| 2 | 12 | ||
| 3 | * emacs-lisp/ert.el (ert-select-tests): | 13 | * emacs-lisp/ert.el (ert-select-tests): |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 03244aaeb8a..f780fbfc2fe 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | (require 'faces) | 50 | (require 'faces) |
| 51 | (require 'menu-bar) | 51 | (require 'menu-bar) |
| 52 | (require 'fontset) | 52 | (require 'fontset) |
| 53 | (require 'dnd) | ||
| 53 | 54 | ||
| 54 | (defgroup ns nil | 55 | (defgroup ns nil |
| 55 | "GNUstep/Mac OS X specific features." | 56 | "GNUstep/Mac OS X specific features." |
| @@ -160,10 +161,6 @@ The properties returned may include `top', `left', `height', and `width'." | |||
| 160 | (define-key global-map [ns-power-off] 'save-buffers-kill-emacs) | 161 | (define-key global-map [ns-power-off] 'save-buffers-kill-emacs) |
| 161 | (define-key global-map [ns-open-file] 'ns-find-file) | 162 | (define-key global-map [ns-open-file] 'ns-find-file) |
| 162 | (define-key global-map [ns-open-temp-file] [ns-open-file]) | 163 | (define-key global-map [ns-open-temp-file] [ns-open-file]) |
| 163 | (define-key global-map [ns-drag-file] 'ns-find-file) | ||
| 164 | (define-key global-map [ns-drag-color] 'ns-set-foreground-at-mouse) | ||
| 165 | (define-key global-map [S-ns-drag-color] 'ns-set-background-at-mouse) | ||
| 166 | (define-key global-map [ns-drag-text] 'ns-insert-text) | ||
| 167 | (define-key global-map [ns-change-font] 'ns-respond-to-change-font) | 164 | (define-key global-map [ns-change-font] 'ns-respond-to-change-font) |
| 168 | (define-key global-map [ns-open-file-line] 'ns-open-file-select-line) | 165 | (define-key global-map [ns-open-file-line] 'ns-open-file-select-line) |
| 169 | (define-key global-map [ns-spi-service-call] 'ns-spi-service-call) | 166 | (define-key global-map [ns-spi-service-call] 'ns-spi-service-call) |
| @@ -365,14 +362,6 @@ See `ns-insert-working-text'." | |||
| 365 | 362 | ||
| 366 | ;;;; Inter-app communications support. | 363 | ;;;; Inter-app communications support. |
| 367 | 364 | ||
| 368 | (defvar ns-input-text) ; nsterm.m | ||
| 369 | |||
| 370 | (defun ns-insert-text () | ||
| 371 | "Insert contents of `ns-input-text' at point." | ||
| 372 | (interactive) | ||
| 373 | (insert ns-input-text) | ||
| 374 | (setq ns-input-text nil)) | ||
| 375 | |||
| 376 | (defun ns-insert-file () | 365 | (defun ns-insert-file () |
| 377 | "Insert contents of file `ns-input-file' like insert-file but with less | 366 | "Insert contents of file `ns-input-file' like insert-file but with less |
| 378 | prompting. If file is a directory perform a `find-file' on it." | 367 | prompting. If file is a directory perform a `find-file' on it." |
| @@ -518,6 +507,50 @@ unless the current buffer is a scratch buffer." | |||
| 518 | (ns-hide-emacs 'activate) | 507 | (ns-hide-emacs 'activate) |
| 519 | (find-file f))))) | 508 | (find-file f))))) |
| 520 | 509 | ||
| 510 | |||
| 511 | (defun ns-drag-n-drop (event &optional new-frame force-text) | ||
| 512 | "Edit the files listed in the drag-n-drop EVENT. | ||
| 513 | Switch to a buffer editing the last file dropped." | ||
| 514 | (interactive "e") | ||
| 515 | (let* ((window (posn-window (event-start event))) | ||
| 516 | (arg (car (cdr (cdr event)))) | ||
| 517 | (type (car arg)) | ||
| 518 | (data (car (cdr arg))) | ||
| 519 | (url-or-string (cond ((eq type 'file) | ||
| 520 | (concat "file:" data)) | ||
| 521 | (t data)))) | ||
| 522 | (set-frame-selected-window nil window) | ||
| 523 | (when new-frame | ||
| 524 | (select-frame (make-frame))) | ||
| 525 | (raise-frame) | ||
| 526 | (setq window (selected-window)) | ||
| 527 | (if force-text | ||
| 528 | (dnd-insert-text window 'private data) | ||
| 529 | (dnd-handle-one-url window 'private url-or-string)))) | ||
| 530 | |||
| 531 | |||
| 532 | (defun ns-drag-n-drop-other-frame (event) | ||
| 533 | "Edit the files listed in the drag-n-drop EVENT, in other frames. | ||
| 534 | May create new frames, or reuse existing ones. The frame editing | ||
| 535 | the last file dropped is selected." | ||
| 536 | (interactive "e") | ||
| 537 | (ns-drag-n-drop event t)) | ||
| 538 | |||
| 539 | (defun ns-drag-n-drop-as-text (event) | ||
| 540 | "Drop the data in EVENT as text." | ||
| 541 | (interactive "e") | ||
| 542 | (ns-drag-n-drop event nil t)) | ||
| 543 | |||
| 544 | (defun ns-drag-n-drop-as-text-other-frame (event) | ||
| 545 | "Drop the data in EVENT as text in a new frame." | ||
| 546 | (interactive "e") | ||
| 547 | (ns-drag-n-drop event t t)) | ||
| 548 | |||
| 549 | (global-set-key [drag-n-drop] 'ns-drag-n-drop) | ||
| 550 | (global-set-key [C-drag-n-drop] 'ns-drag-n-drop-other-frame) | ||
| 551 | (global-set-key [M-drag-n-drop] 'ns-drag-n-drop-as-text) | ||
| 552 | (global-set-key [C-M-drag-n-drop] 'ns-drag-n-drop-as-text-other-frame) | ||
| 553 | |||
| 521 | ;;;; Frame-related functions. | 554 | ;;;; Frame-related functions. |
| 522 | 555 | ||
| 523 | ;; nsterm.m | 556 | ;; nsterm.m |
| @@ -830,40 +863,6 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 830 | (t | 863 | (t |
| 831 | nil)))) | 864 | nil)))) |
| 832 | 865 | ||
| 833 | (defvar ns-input-color) ; nsterm.m | ||
| 834 | |||
| 835 | (defun ns-set-foreground-at-mouse () | ||
| 836 | "Set the foreground color at the mouse location to `ns-input-color'." | ||
| 837 | (interactive) | ||
| 838 | (let* ((pos (mouse-position)) | ||
| 839 | (frame (car pos)) | ||
| 840 | (face (ns-face-at-pos pos))) | ||
| 841 | (cond | ||
| 842 | ((eq face 'cursor) | ||
| 843 | (modify-frame-parameters frame (list (cons 'cursor-color | ||
| 844 | ns-input-color)))) | ||
| 845 | ((not face) | ||
| 846 | (modify-frame-parameters frame (list (cons 'foreground-color | ||
| 847 | ns-input-color)))) | ||
| 848 | (t | ||
| 849 | (set-face-foreground face ns-input-color frame))))) | ||
| 850 | |||
| 851 | (defun ns-set-background-at-mouse () | ||
| 852 | "Set the background color at the mouse location to `ns-input-color'." | ||
| 853 | (interactive) | ||
| 854 | (let* ((pos (mouse-position)) | ||
| 855 | (frame (car pos)) | ||
| 856 | (face (ns-face-at-pos pos))) | ||
| 857 | (cond | ||
| 858 | ((eq face 'cursor) | ||
| 859 | (modify-frame-parameters frame (list (cons 'cursor-color | ||
| 860 | ns-input-color)))) | ||
| 861 | ((not face) | ||
| 862 | (modify-frame-parameters frame (list (cons 'background-color | ||
| 863 | ns-input-color)))) | ||
| 864 | (t | ||
| 865 | (set-face-background face ns-input-color frame))))) | ||
| 866 | |||
| 867 | ;; Set some options to be as Nextstep-like as possible. | 866 | ;; Set some options to be as Nextstep-like as possible. |
| 868 | (setq frame-title-format t | 867 | (setq frame-title-format t |
| 869 | icon-title-format t) | 868 | icon-title-format t) |
diff --git a/src/ChangeLog b/src/ChangeLog index e7f30f25800..283777cbcdf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2013-12-19 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsterm.h (KEY_NS_DRAG_FILE, KEY_NS_DRAG_COLOR, KEY_NS_DRAG_TEXT): | ||
| 4 | Remove. | ||
| 5 | |||
| 6 | * nsterm.m (Qfile, Qurl): New. | ||
| 7 | (EV_MODIFIERS2): New macro. | ||
| 8 | (EV_MODIFIERS): Use EV_MODIFIERS2. | ||
| 9 | (ns_term_init): Remove font and color from DND, does not work on | ||
| 10 | newer OSX, and other ports don't have them. | ||
| 11 | (performDragOperation:): Handle modifiers used during drag. | ||
| 12 | Use DRAG_N_DROP_EVENT instead of NS specific events (Bug#8051). | ||
| 13 | Remove global Lisp variables used to communicate with ns-win.el. | ||
| 14 | Remove font and color handling. | ||
| 15 | (syms_of_nsterm): Defsym Qfile and Qurl. | ||
| 16 | |||
| 1 | 2013-12-19 Anders Lindgren <andlind@gmail.com> | 17 | 2013-12-19 Anders Lindgren <andlind@gmail.com> |
| 2 | 18 | ||
| 3 | * nsterm.m (NSTRACE_SIZE, NSTRACE_RECT): New macros. | 19 | * nsterm.m (NSTRACE_SIZE, NSTRACE_RECT): New macros. |
diff --git a/src/nsterm.h b/src/nsterm.h index faf8271bcc7..b86122417e5 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -458,9 +458,6 @@ extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu; | |||
| 458 | #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1) | 458 | #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1) |
| 459 | #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2) | 459 | #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2) |
| 460 | #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3) | 460 | #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3) |
| 461 | #define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4) | ||
| 462 | #define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5) | ||
| 463 | #define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6) | ||
| 464 | #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7) | 461 | #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7) |
| 465 | #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8) | 462 | #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8) |
| 466 | #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9) | 463 | #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9) |
diff --git a/src/nsterm.m b/src/nsterm.m index d7c2f38135a..8047bca1f60 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -80,7 +80,7 @@ int term_trace_num = 0; | |||
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | /* Detailed tracing. "S" means "size" and "LL" stands for "lower left". */ | 82 | /* Detailed tracing. "S" means "size" and "LL" stands for "lower left". */ |
| 83 | #if 1 | 83 | #if 0 |
| 84 | int term_trace_num = 0; | 84 | int term_trace_num = 0; |
| 85 | #define NSTRACE_SIZE(str,size) fprintf (stderr, \ | 85 | #define NSTRACE_SIZE(str,size) fprintf (stderr, \ |
| 86 | "%s:%d: [%d] " str \ | 86 | "%s:%d: [%d] " str \ |
| @@ -196,6 +196,7 @@ extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; | |||
| 196 | 196 | ||
| 197 | static Lisp_Object QUTF8_STRING; | 197 | static Lisp_Object QUTF8_STRING; |
| 198 | static Lisp_Object Qcocoa, Qgnustep; | 198 | static Lisp_Object Qcocoa, Qgnustep; |
| 199 | static Lisp_Object Qfile, Qurl; | ||
| 199 | 200 | ||
| 200 | /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold, | 201 | /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold, |
| 201 | the maximum font size to NOT antialias. On GNUstep there is currently | 202 | the maximum font size to NOT antialias. On GNUstep there is currently |
| @@ -278,31 +279,32 @@ static CGPoint menu_mouse_point; | |||
| 278 | #define NSRightCommandKeyMask (0x000010 | NSCommandKeyMask) | 279 | #define NSRightCommandKeyMask (0x000010 | NSCommandKeyMask) |
| 279 | #define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask) | 280 | #define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask) |
| 280 | #define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask) | 281 | #define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask) |
| 281 | #define EV_MODIFIERS(e) \ | 282 | #define EV_MODIFIERS2(flags) \ |
| 282 | ((([e modifierFlags] & NSHelpKeyMask) ? \ | 283 | (((flags & NSHelpKeyMask) ? \ |
| 283 | hyper_modifier : 0) \ | 284 | hyper_modifier : 0) \ |
| 284 | | (!EQ (ns_right_alternate_modifier, Qleft) && \ | 285 | | (!EQ (ns_right_alternate_modifier, Qleft) && \ |
| 285 | (([e modifierFlags] & NSRightAlternateKeyMask) \ | 286 | ((flags & NSRightAlternateKeyMask) \ |
| 286 | == NSRightAlternateKeyMask) ? \ | 287 | == NSRightAlternateKeyMask) ? \ |
| 287 | parse_solitary_modifier (ns_right_alternate_modifier) : 0) \ | 288 | parse_solitary_modifier (ns_right_alternate_modifier) : 0) \ |
| 288 | | (([e modifierFlags] & NSAlternateKeyMask) ? \ | 289 | | ((flags & NSAlternateKeyMask) ? \ |
| 289 | parse_solitary_modifier (ns_alternate_modifier) : 0) \ | 290 | parse_solitary_modifier (ns_alternate_modifier) : 0) \ |
| 290 | | (([e modifierFlags] & NSShiftKeyMask) ? \ | 291 | | ((flags & NSShiftKeyMask) ? \ |
| 291 | shift_modifier : 0) \ | 292 | shift_modifier : 0) \ |
| 292 | | (!EQ (ns_right_control_modifier, Qleft) && \ | 293 | | (!EQ (ns_right_control_modifier, Qleft) && \ |
| 293 | (([e modifierFlags] & NSRightControlKeyMask) \ | 294 | ((flags & NSRightControlKeyMask) \ |
| 294 | == NSRightControlKeyMask) ? \ | 295 | == NSRightControlKeyMask) ? \ |
| 295 | parse_solitary_modifier (ns_right_control_modifier) : 0) \ | 296 | parse_solitary_modifier (ns_right_control_modifier) : 0) \ |
| 296 | | (([e modifierFlags] & NSControlKeyMask) ? \ | 297 | | ((flags & NSControlKeyMask) ? \ |
| 297 | parse_solitary_modifier (ns_control_modifier) : 0) \ | 298 | parse_solitary_modifier (ns_control_modifier) : 0) \ |
| 298 | | (([e modifierFlags] & NS_FUNCTION_KEY_MASK) ? \ | 299 | | ((flags & NS_FUNCTION_KEY_MASK) ? \ |
| 299 | parse_solitary_modifier (ns_function_modifier) : 0) \ | 300 | parse_solitary_modifier (ns_function_modifier) : 0) \ |
| 300 | | (!EQ (ns_right_command_modifier, Qleft) && \ | 301 | | (!EQ (ns_right_command_modifier, Qleft) && \ |
| 301 | (([e modifierFlags] & NSRightCommandKeyMask) \ | 302 | ((flags & NSRightCommandKeyMask) \ |
| 302 | == NSRightCommandKeyMask) ? \ | 303 | == NSRightCommandKeyMask) ? \ |
| 303 | parse_solitary_modifier (ns_right_command_modifier) : 0) \ | 304 | parse_solitary_modifier (ns_right_command_modifier) : 0) \ |
| 304 | | (([e modifierFlags] & NSCommandKeyMask) ? \ | 305 | | ((flags & NSCommandKeyMask) ? \ |
| 305 | parse_solitary_modifier (ns_command_modifier):0)) | 306 | parse_solitary_modifier (ns_command_modifier):0)) |
| 307 | #define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags]) | ||
| 306 | 308 | ||
| 307 | #define EV_UDMODIFIERS(e) \ | 309 | #define EV_UDMODIFIERS(e) \ |
| 308 | ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \ | 310 | ((([e type] == NSLeftMouseDown) ? down_modifier : 0) \ |
| @@ -4377,9 +4379,7 @@ ns_term_init (Lisp_Object display_name) | |||
| 4377 | NSStringPboardType, | 4379 | NSStringPboardType, |
| 4378 | NSTabularTextPboardType, | 4380 | NSTabularTextPboardType, |
| 4379 | NSFilenamesPboardType, | 4381 | NSFilenamesPboardType, |
| 4380 | NSURLPboardType, | 4382 | NSURLPboardType, nil] retain]; |
| 4381 | NSColorPboardType, | ||
| 4382 | NSFontPboardType, nil] retain]; | ||
| 4383 | 4383 | ||
| 4384 | /* If fullscreen is in init/default-frame-alist, focus isn't set | 4384 | /* If fullscreen is in init/default-frame-alist, focus isn't set |
| 4385 | right for fullscreen windows, so set this. */ | 4385 | right for fullscreen windows, so set this. */ |
| @@ -6647,6 +6647,8 @@ if (cols > 0 && rows > 0) | |||
| 6647 | NSString *type; | 6647 | NSString *type; |
| 6648 | NSEvent *theEvent = [[self window] currentEvent]; | 6648 | NSEvent *theEvent = [[self window] currentEvent]; |
| 6649 | NSPoint position; | 6649 | NSPoint position; |
| 6650 | NSDragOperation op = [sender draggingSourceOperationMask]; | ||
| 6651 | int modifiers = 0; | ||
| 6650 | 6652 | ||
| 6651 | NSTRACE (performDragOperation); | 6653 | NSTRACE (performDragOperation); |
| 6652 | 6654 | ||
| @@ -6658,6 +6660,20 @@ if (cols > 0 && rows > 0) | |||
| 6658 | 6660 | ||
| 6659 | pb = [sender draggingPasteboard]; | 6661 | pb = [sender draggingPasteboard]; |
| 6660 | type = [pb availableTypeFromArray: ns_drag_types]; | 6662 | type = [pb availableTypeFromArray: ns_drag_types]; |
| 6663 | |||
| 6664 | if (! (op & (NSDragOperationMove|NSDragOperationDelete)) && | ||
| 6665 | // URL drags contain all operations (0xf), don't allow all to be set. | ||
| 6666 | (op & 0xf) != 0xf) | ||
| 6667 | { | ||
| 6668 | if (op & NSDragOperationLink) | ||
| 6669 | modifiers |= NSControlKeyMask; | ||
| 6670 | if (op & NSDragOperationCopy) | ||
| 6671 | modifiers |= NSAlternateKeyMask; | ||
| 6672 | if (op & NSDragOperationGeneric) | ||
| 6673 | modifiers |= NSCommandKeyMask; | ||
| 6674 | } | ||
| 6675 | |||
| 6676 | modifiers = EV_MODIFIERS2 (modifiers); | ||
| 6661 | if (type == 0) | 6677 | if (type == 0) |
| 6662 | { | 6678 | { |
| 6663 | return NO; | 6679 | return NO; |
| @@ -6674,34 +6690,37 @@ if (cols > 0 && rows > 0) | |||
| 6674 | fenum = [files objectEnumerator]; | 6690 | fenum = [files objectEnumerator]; |
| 6675 | while ( (file = [fenum nextObject]) ) | 6691 | while ( (file = [fenum nextObject]) ) |
| 6676 | { | 6692 | { |
| 6677 | emacs_event->kind = NS_NONKEY_EVENT; | 6693 | emacs_event->kind = DRAG_N_DROP_EVENT; |
| 6678 | emacs_event->code = KEY_NS_DRAG_FILE; | ||
| 6679 | XSETINT (emacs_event->x, x); | 6694 | XSETINT (emacs_event->x, x); |
| 6680 | XSETINT (emacs_event->y, y); | 6695 | XSETINT (emacs_event->y, y); |
| 6681 | ns_input_file = append2 (ns_input_file, | 6696 | ns_input_file = append2 (ns_input_file, |
| 6682 | build_string ([file UTF8String])); | 6697 | build_string ([file UTF8String])); |
| 6683 | emacs_event->modifiers = EV_MODIFIERS (theEvent); | 6698 | emacs_event->modifiers = modifiers; |
| 6699 | emacs_event->arg = list2 (Qfile, build_string ([file UTF8String])); | ||
| 6684 | EV_TRAILER (theEvent); | 6700 | EV_TRAILER (theEvent); |
| 6685 | } | 6701 | } |
| 6686 | return YES; | 6702 | return YES; |
| 6687 | } | 6703 | } |
| 6688 | else if ([type isEqualToString: NSURLPboardType]) | 6704 | else if ([type isEqualToString: NSURLPboardType]) |
| 6689 | { | 6705 | { |
| 6690 | NSString *file; | 6706 | NSURL *url = [NSURL URLFromPasteboard: pb]; |
| 6691 | NSURL *fileURL; | 6707 | if (url == nil) return NO; |
| 6692 | |||
| 6693 | if (!(fileURL = [NSURL URLFromPasteboard: pb]) || | ||
| 6694 | [fileURL isFileURL] == NO) | ||
| 6695 | return NO; | ||
| 6696 | 6708 | ||
| 6697 | file = [fileURL path]; | 6709 | emacs_event->kind = DRAG_N_DROP_EVENT; |
| 6698 | emacs_event->kind = NS_NONKEY_EVENT; | ||
| 6699 | emacs_event->code = KEY_NS_DRAG_FILE; | ||
| 6700 | XSETINT (emacs_event->x, x); | 6710 | XSETINT (emacs_event->x, x); |
| 6701 | XSETINT (emacs_event->y, y); | 6711 | XSETINT (emacs_event->y, y); |
| 6702 | ns_input_file = append2 (ns_input_file, build_string ([file UTF8String])); | 6712 | emacs_event->modifiers = modifiers; |
| 6703 | emacs_event->modifiers = EV_MODIFIERS (theEvent); | 6713 | emacs_event->arg = list2 (Qurl, |
| 6714 | build_string ([[url absoluteString] | ||
| 6715 | UTF8String])); | ||
| 6704 | EV_TRAILER (theEvent); | 6716 | EV_TRAILER (theEvent); |
| 6717 | |||
| 6718 | if ([url isFileURL] != NO) | ||
| 6719 | { | ||
| 6720 | NSString *file = [url path]; | ||
| 6721 | ns_input_file = append2 (ns_input_file, | ||
| 6722 | build_string ([file UTF8String])); | ||
| 6723 | } | ||
| 6705 | return YES; | 6724 | return YES; |
| 6706 | } | 6725 | } |
| 6707 | else if ([type isEqualToString: NSStringPboardType] | 6726 | else if ([type isEqualToString: NSStringPboardType] |
| @@ -6712,46 +6731,11 @@ if (cols > 0 && rows > 0) | |||
| 6712 | if (! (data = [pb stringForType: type])) | 6731 | if (! (data = [pb stringForType: type])) |
| 6713 | return NO; | 6732 | return NO; |
| 6714 | 6733 | ||
| 6715 | emacs_event->kind = NS_NONKEY_EVENT; | 6734 | emacs_event->kind = DRAG_N_DROP_EVENT; |
| 6716 | emacs_event->code = KEY_NS_DRAG_TEXT; | ||
| 6717 | XSETINT (emacs_event->x, x); | ||
| 6718 | XSETINT (emacs_event->y, y); | ||
| 6719 | ns_input_text = build_string ([data UTF8String]); | ||
| 6720 | emacs_event->modifiers = EV_MODIFIERS (theEvent); | ||
| 6721 | EV_TRAILER (theEvent); | ||
| 6722 | return YES; | ||
| 6723 | } | ||
| 6724 | else if ([type isEqualToString: NSColorPboardType]) | ||
| 6725 | { | ||
| 6726 | NSColor *c = [NSColor colorFromPasteboard: pb]; | ||
| 6727 | emacs_event->kind = NS_NONKEY_EVENT; | ||
| 6728 | emacs_event->code = KEY_NS_DRAG_COLOR; | ||
| 6729 | XSETINT (emacs_event->x, x); | ||
| 6730 | XSETINT (emacs_event->y, y); | ||
| 6731 | ns_input_color = ns_color_to_lisp (c); | ||
| 6732 | emacs_event->modifiers = EV_MODIFIERS (theEvent); | ||
| 6733 | EV_TRAILER (theEvent); | ||
| 6734 | return YES; | ||
| 6735 | } | ||
| 6736 | else if ([type isEqualToString: NSFontPboardType]) | ||
| 6737 | { | ||
| 6738 | /* impl based on GNUstep NSTextView.m */ | ||
| 6739 | NSData *data = [pb dataForType: NSFontPboardType]; | ||
| 6740 | NSDictionary *dict = [NSUnarchiver unarchiveObjectWithData: data]; | ||
| 6741 | NSFont *font = [dict objectForKey: NSFontAttributeName]; | ||
| 6742 | char fontSize[10]; | ||
| 6743 | |||
| 6744 | if (font == nil) | ||
| 6745 | return NO; | ||
| 6746 | |||
| 6747 | emacs_event->kind = NS_NONKEY_EVENT; | ||
| 6748 | emacs_event->code = KEY_NS_CHANGE_FONT; | ||
| 6749 | XSETINT (emacs_event->x, x); | 6735 | XSETINT (emacs_event->x, x); |
| 6750 | XSETINT (emacs_event->y, y); | 6736 | XSETINT (emacs_event->y, y); |
| 6751 | ns_input_font = build_string ([[font fontName] UTF8String]); | 6737 | emacs_event->modifiers = modifiers; |
| 6752 | snprintf (fontSize, 10, "%f", [font pointSize]); | 6738 | emacs_event->arg = list2 (Qnil, build_string ([data UTF8String])); |
| 6753 | ns_input_fontsize = build_string (fontSize); | ||
| 6754 | emacs_event->modifiers = EV_MODIFIERS (theEvent); | ||
| 6755 | EV_TRAILER (theEvent); | 6739 | EV_TRAILER (theEvent); |
| 6756 | return YES; | 6740 | return YES; |
| 6757 | } | 6741 | } |
| @@ -7514,6 +7498,9 @@ syms_of_nsterm (void) | |||
| 7514 | DEFSYM (Qcontrol, "control"); | 7498 | DEFSYM (Qcontrol, "control"); |
| 7515 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); | 7499 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); |
| 7516 | 7500 | ||
| 7501 | DEFSYM (Qfile, "file"); | ||
| 7502 | DEFSYM (Qurl, "url"); | ||
| 7503 | |||
| 7517 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); | 7504 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); |
| 7518 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); | 7505 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); |
| 7519 | Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); | 7506 | Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); |
| @@ -7524,10 +7511,6 @@ syms_of_nsterm (void) | |||
| 7524 | "The file specified in the last NS event."); | 7511 | "The file specified in the last NS event."); |
| 7525 | ns_input_file =Qnil; | 7512 | ns_input_file =Qnil; |
| 7526 | 7513 | ||
| 7527 | DEFVAR_LISP ("ns-input-text", ns_input_text, | ||
| 7528 | "The data received in the last NS text drag event."); | ||
| 7529 | ns_input_text =Qnil; | ||
| 7530 | |||
| 7531 | DEFVAR_LISP ("ns-working-text", ns_working_text, | 7514 | DEFVAR_LISP ("ns-working-text", ns_working_text, |
| 7532 | "String for visualizing working composition sequence."); | 7515 | "String for visualizing working composition sequence."); |
| 7533 | ns_working_text =Qnil; | 7516 | ns_working_text =Qnil; |
| @@ -7544,10 +7527,6 @@ syms_of_nsterm (void) | |||
| 7544 | "The line specified in the last NS event."); | 7527 | "The line specified in the last NS event."); |
| 7545 | ns_input_line =Qnil; | 7528 | ns_input_line =Qnil; |
| 7546 | 7529 | ||
| 7547 | DEFVAR_LISP ("ns-input-color", ns_input_color, | ||
| 7548 | "The color specified in the last NS event."); | ||
| 7549 | ns_input_color =Qnil; | ||
| 7550 | |||
| 7551 | DEFVAR_LISP ("ns-input-spi-name", ns_input_spi_name, | 7530 | DEFVAR_LISP ("ns-input-spi-name", ns_input_spi_name, |
| 7552 | "The service name specified in the last NS event."); | 7531 | "The service name specified in the last NS event."); |
| 7553 | ns_input_spi_name =Qnil; | 7532 | ns_input_spi_name =Qnil; |