diff options
author | Po Lu <luangruo@yahoo.com> | 2022-06-09 16:34:18 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-06-09 16:34:18 +0800 |
commit | e7ac2ac4e07d3fd6fee4a74a9cfc5bac9310fc18 (patch) | |
tree | 2cf1ab3a6a41efbeaba620441cb3ace30bd48a3e /src/nsterm.m | |
parent | 0ba43e15d9c9ffb3df8aeb3a7e446d9a4d62ccff (diff) | |
download | emacs-e7ac2ac4e07d3fd6fee4a74a9cfc5bac9310fc18.tar.gz emacs-e7ac2ac4e07d3fd6fee4a74a9cfc5bac9310fc18.tar.bz2 emacs-e7ac2ac4e07d3fd6fee4a74a9cfc5bac9310fc18.zip |
Implement `follow-tooltip' on NS as well
* lisp/term/ns-win.el (x-begin-drag): Pass `follow-tooltip'.
* src/nsfns.m (Fx_show_tip): Record last dx and dy.
(syms_of_nsfns): New staticpros.
* src/nsmenu.m ([EmacsTooltip moveTo:]): New method.
* src/nsselect.m (Fns_begin_drag): New parameter
`follow-tooltip'.
* src/nsterm.h (@interface EmacsWindow):
(EmacsTooltip): Update prototypes.
* src/nsterm.m ([EmacsWindow draggedImage:movedTo:]): Move any
tooltip to the right location.
([EmacsWindow beginDrag:forPasteboard...]): New parameter
`followTooltip'.
Diffstat (limited to 'src/nsterm.m')
-rw-r--r-- | src/nsterm.m | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 4663ac85d84..b0eb86bfb09 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -9629,35 +9629,45 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) selected_op = operation; } -#ifdef NS_IMPL_COCOA - (void) draggedImage: (NSImage *) dragged_image movedTo: (NSPoint) screen_point { + NSPoint mouse_loc; +#ifdef NS_IMPL_COCOA NSInteger window_number; NSWindow *w; +#endif - if (dnd_mode == RETURN_FRAME_NEVER) - return; + mouse_loc = [NSEvent mouseLocation]; - window_number = [NSWindow windowNumberAtPoint: [NSEvent mouseLocation] - belowWindowWithWindowNumber: 0]; - w = [NSApp windowWithWindowNumber: window_number]; +#ifdef NS_IMPL_COCOA + if (dnd_mode != RETURN_FRAME_NEVER) + { + window_number = [NSWindow windowNumberAtPoint: mouse_loc + belowWindowWithWindowNumber: 0]; + w = [NSApp windowWithWindowNumber: window_number]; - if (!w || w != self) - dnd_mode = RETURN_FRAME_NOW; + if (!w || w != self) + dnd_mode = RETURN_FRAME_NOW; - if (dnd_mode != RETURN_FRAME_NOW - || ![[w delegate] isKindOfClass: [EmacsView class]]) - return; + if (dnd_mode != RETURN_FRAME_NOW + || ![[w delegate] isKindOfClass: [EmacsView class]]) + goto out; - dnd_return_frame = ((EmacsView *) [w delegate])->emacsframe; + dnd_return_frame = ((EmacsView *) [w delegate])->emacsframe; - /* FIXME: there must be a better way to leave the event loop. */ - [NSException raise: @"" - format: @"Must return DND frame"]; -} + /* FIXME: there must be a better way to leave the event loop. */ + [NSException raise: @"" + format: @"Must return DND frame"]; + } #endif + out: + + if (dnd_move_tooltip_with_frame) + ns_move_tooltip_to_mouse_location (mouse_loc); +} + - (BOOL) mustNotDropOn: (NSView *) receiver { return ([receiver window] == self @@ -9669,6 +9679,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) withMode: (enum ns_return_frame_mode) mode returnFrameTo: (struct frame **) frame_return prohibitSame: (BOOL) prohibit_same_frame + followTooltip: (BOOL) follow_tooltip { NSImage *image; #ifdef NS_IMPL_COCOA @@ -9681,6 +9692,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) dnd_mode = mode; dnd_return_frame = NULL; dnd_allow_same_frame = !prohibit_same_frame; + dnd_move_tooltip_with_frame = follow_tooltip; /* Now draw transparency onto the image. */ [image lockFocus]; @@ -9728,6 +9740,10 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) #endif unblock_input (); + /* The drop happened, so delete the tooltip. */ + if (follow_tooltip) + Fx_hide_tip (); + /* Assume all buttons have been released since the drag-and-drop operation is now over. */ if (!dnd_return_frame) |