diff options
| author | Alan Third | 2019-01-05 16:11:37 +0000 |
|---|---|---|
| committer | Alan Third | 2019-01-10 19:24:19 +0000 |
| commit | c342b26371480316024e1e5d63cd8b3f035dda69 (patch) | |
| tree | ec999f6d48e5737528f48f9c0224de5db8a13d10 /src | |
| parent | 7ae0a24c87c2bbefe78717d5e89cf3fe14f4af4c (diff) | |
| download | emacs-c342b26371480316024e1e5d63cd8b3f035dda69.tar.gz emacs-c342b26371480316024e1e5d63cd8b3f035dda69.zip | |
Fix drag and drop behaviour on NS (bug#30929)
* doc/emacs/macos.texi (Mac / GNUstep Events): Describe the new drag
and drop behaviour.
* lisp/term/ns-win.el (ns-drag-n-drop): Handle the new event format.
(ns-drag-n-drop-other-frame):
(ns-drag-n-drop-as-text):
(ns-drag-n-drop-as-text-other-frame): Remove functions and key
bindings.
* src/nsterm.m ([EmacsView performDragOperation:]): Send Emacs event
in new format without setting any modifiers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 016c0447609..2bce4a89aea 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -8230,7 +8230,9 @@ not_in_argv (NSString *arg) | |||
| 8230 | NSEvent *theEvent = [[self window] currentEvent]; | 8230 | NSEvent *theEvent = [[self window] currentEvent]; |
| 8231 | NSPoint position; | 8231 | NSPoint position; |
| 8232 | NSDragOperation op = [sender draggingSourceOperationMask]; | 8232 | NSDragOperation op = [sender draggingSourceOperationMask]; |
| 8233 | int modifiers = 0; | 8233 | Lisp_Object operations = Qnil; |
| 8234 | Lisp_Object strings = Qnil; | ||
| 8235 | Lisp_Object type_sym; | ||
| 8234 | 8236 | ||
| 8235 | NSTRACE ("[EmacsView performDragOperation:]"); | 8237 | NSTRACE ("[EmacsView performDragOperation:]"); |
| 8236 | 8238 | ||
| @@ -8243,19 +8245,17 @@ not_in_argv (NSString *arg) | |||
| 8243 | pb = [sender draggingPasteboard]; | 8245 | pb = [sender draggingPasteboard]; |
| 8244 | type = [pb availableTypeFromArray: ns_drag_types]; | 8246 | type = [pb availableTypeFromArray: ns_drag_types]; |
| 8245 | 8247 | ||
| 8246 | if (! (op & (NSDragOperationMove|NSDragOperationDelete)) && | 8248 | /* We used to convert these drag operations to keyboard modifiers, |
| 8247 | // URL drags contain all operations (0xf), don't allow all to be set. | 8249 | but because they can be set by the sending program as well as the |
| 8248 | (op & 0xf) != 0xf) | 8250 | keyboard modifiers it was difficult to work out a sensible key |
| 8249 | { | 8251 | mapping for drag and drop. */ |
| 8250 | if (op & NSDragOperationLink) | 8252 | if (op & NSDragOperationLink) |
| 8251 | modifiers |= NSEventModifierFlagControl; | 8253 | operations = Fcons (Qns_drag_operation_link, operations); |
| 8252 | if (op & NSDragOperationCopy) | 8254 | if (op & NSDragOperationCopy) |
| 8253 | modifiers |= NSEventModifierFlagOption; | 8255 | operations = Fcons (Qns_drag_operation_copy, operations); |
| 8254 | if (op & NSDragOperationGeneric) | 8256 | if (op & NSDragOperationGeneric || NILP (operations)) |
| 8255 | modifiers |= NSEventModifierFlagCommand; | 8257 | operations = Fcons (Qns_drag_operation_generic, operations); |
| 8256 | } | ||
| 8257 | 8258 | ||
| 8258 | modifiers = EV_MODIFIERS2 (modifiers); | ||
| 8259 | if (type == 0) | 8259 | if (type == 0) |
| 8260 | { | 8260 | { |
| 8261 | return NO; | 8261 | return NO; |
| @@ -8269,39 +8269,20 @@ not_in_argv (NSString *arg) | |||
| 8269 | if (!(files = [pb propertyListForType: type])) | 8269 | if (!(files = [pb propertyListForType: type])) |
| 8270 | return NO; | 8270 | return NO; |
| 8271 | 8271 | ||
| 8272 | type_sym = Qfile; | ||
| 8273 | |||
| 8272 | fenum = [files objectEnumerator]; | 8274 | fenum = [files objectEnumerator]; |
| 8273 | while ( (file = [fenum nextObject]) ) | 8275 | while ( (file = [fenum nextObject]) ) |
| 8274 | { | 8276 | strings = Fcons (build_string ([file UTF8String]), strings); |
| 8275 | emacs_event->kind = DRAG_N_DROP_EVENT; | ||
| 8276 | XSETINT (emacs_event->x, x); | ||
| 8277 | XSETINT (emacs_event->y, y); | ||
| 8278 | emacs_event->modifiers = modifiers; | ||
| 8279 | emacs_event->arg = list2 (Qfile, build_string ([file UTF8String])); | ||
| 8280 | EV_TRAILER (theEvent); | ||
| 8281 | } | ||
| 8282 | return YES; | ||
| 8283 | } | 8277 | } |
| 8284 | else if ([type isEqualToString: NSURLPboardType]) | 8278 | else if ([type isEqualToString: NSURLPboardType]) |
| 8285 | { | 8279 | { |
| 8286 | NSURL *url = [NSURL URLFromPasteboard: pb]; | 8280 | NSURL *url = [NSURL URLFromPasteboard: pb]; |
| 8287 | if (url == nil) return NO; | 8281 | if (url == nil) return NO; |
| 8288 | 8282 | ||
| 8289 | emacs_event->kind = DRAG_N_DROP_EVENT; | 8283 | type_sym = Qurl; |
| 8290 | XSETINT (emacs_event->x, x); | ||
| 8291 | XSETINT (emacs_event->y, y); | ||
| 8292 | emacs_event->modifiers = modifiers; | ||
| 8293 | emacs_event->arg = list2 (Qurl, | ||
| 8294 | build_string ([[url absoluteString] | ||
| 8295 | UTF8String])); | ||
| 8296 | EV_TRAILER (theEvent); | ||
| 8297 | 8284 | ||
| 8298 | if ([url isFileURL] != NO) | 8285 | strings = Fcons (build_string ([[url absoluteString] UTF8String]), Qnil); |
| 8299 | { | ||
| 8300 | NSString *file = [url path]; | ||
| 8301 | ns_input_file = append2 (ns_input_file, | ||
| 8302 | build_string ([file UTF8String])); | ||
| 8303 | } | ||
| 8304 | return YES; | ||
| 8305 | } | 8286 | } |
| 8306 | else if ([type isEqualToString: NSStringPboardType] | 8287 | else if ([type isEqualToString: NSStringPboardType] |
| 8307 | || [type isEqualToString: NSTabularTextPboardType]) | 8288 | || [type isEqualToString: NSTabularTextPboardType]) |
| @@ -8311,19 +8292,27 @@ not_in_argv (NSString *arg) | |||
| 8311 | if (! (data = [pb stringForType: type])) | 8292 | if (! (data = [pb stringForType: type])) |
| 8312 | return NO; | 8293 | return NO; |
| 8313 | 8294 | ||
| 8314 | emacs_event->kind = DRAG_N_DROP_EVENT; | 8295 | type_sym = Qnil; |
| 8315 | XSETINT (emacs_event->x, x); | 8296 | |
| 8316 | XSETINT (emacs_event->y, y); | 8297 | strings = Fcons (build_string ([data UTF8String]), Qnil); |
| 8317 | emacs_event->modifiers = modifiers; | ||
| 8318 | emacs_event->arg = list2 (Qnil, build_string ([data UTF8String])); | ||
| 8319 | EV_TRAILER (theEvent); | ||
| 8320 | return YES; | ||
| 8321 | } | 8298 | } |
| 8322 | else | 8299 | else |
| 8323 | { | 8300 | { |
| 8324 | fprintf (stderr, "Invalid data type in dragging pasteboard"); | 8301 | fprintf (stderr, "Invalid data type in dragging pasteboard"); |
| 8325 | return NO; | 8302 | return NO; |
| 8326 | } | 8303 | } |
| 8304 | |||
| 8305 | emacs_event->kind = DRAG_N_DROP_EVENT; | ||
| 8306 | XSETINT (emacs_event->x, x); | ||
| 8307 | XSETINT (emacs_event->y, y); | ||
| 8308 | emacs_event->modifiers = 0; | ||
| 8309 | |||
| 8310 | emacs_event->arg = Fcons (type_sym, | ||
| 8311 | Fcons (operations, | ||
| 8312 | strings)); | ||
| 8313 | EV_TRAILER (theEvent); | ||
| 8314 | |||
| 8315 | return YES; | ||
| 8327 | } | 8316 | } |
| 8328 | 8317 | ||
| 8329 | 8318 | ||
| @@ -9358,6 +9347,10 @@ syms_of_nsterm (void) | |||
| 9358 | DEFSYM (Qfile, "file"); | 9347 | DEFSYM (Qfile, "file"); |
| 9359 | DEFSYM (Qurl, "url"); | 9348 | DEFSYM (Qurl, "url"); |
| 9360 | 9349 | ||
| 9350 | DEFSYM (Qns_drag_operation_copy, "ns-drag-operation-copy"); | ||
| 9351 | DEFSYM (Qns_drag_operation_link, "ns-drag-operation-link"); | ||
| 9352 | DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic"); | ||
| 9353 | |||
| 9361 | Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); | 9354 | Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); |
| 9362 | Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); | 9355 | Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); |
| 9363 | Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); | 9356 | Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier)); |