diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfns.m | 49 | ||||
| -rw-r--r-- | src/nsmenu.m | 9 | ||||
| -rw-r--r-- | src/nsselect.m | 12 | ||||
| -rw-r--r-- | src/nsterm.h | 27 | ||||
| -rw-r--r-- | src/nsterm.m | 48 |
5 files changed, 115 insertions, 30 deletions
diff --git a/src/nsfns.m b/src/nsfns.m index 1593338dc95..d4cf4f5ffae 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -63,6 +63,9 @@ static EmacsTooltip *ns_tooltip = nil; | |||
| 63 | /* The frame of the currently visible tooltip, or nil if none. */ | 63 | /* The frame of the currently visible tooltip, or nil if none. */ |
| 64 | static Lisp_Object tip_frame; | 64 | static Lisp_Object tip_frame; |
| 65 | 65 | ||
| 66 | /* The X and Y deltas of the last call to `x-show-tip'. */ | ||
| 67 | static Lisp_Object tip_dx, tip_dy; | ||
| 68 | |||
| 66 | /* The window-system window corresponding to the frame of the | 69 | /* The window-system window corresponding to the frame of the |
| 67 | currently visible tooltip. */ | 70 | currently visible tooltip. */ |
| 68 | static NSWindow *tip_window; | 71 | static NSWindow *tip_window; |
| @@ -3243,6 +3246,9 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, | |||
| 3243 | else | 3246 | else |
| 3244 | CHECK_FIXNUM (dy); | 3247 | CHECK_FIXNUM (dy); |
| 3245 | 3248 | ||
| 3249 | tip_dx = dx; | ||
| 3250 | tip_dy = dy; | ||
| 3251 | |||
| 3246 | if (use_system_tooltips) | 3252 | if (use_system_tooltips) |
| 3247 | { | 3253 | { |
| 3248 | NSSize size; | 3254 | NSSize size; |
| @@ -3794,6 +3800,45 @@ all_nonzero_ascii (unsigned char *str, ptrdiff_t n) | |||
| 3794 | } | 3800 | } |
| 3795 | @end | 3801 | @end |
| 3796 | 3802 | ||
| 3803 | void | ||
| 3804 | ns_move_tooltip_to_mouse_location (NSPoint screen_point) | ||
| 3805 | { | ||
| 3806 | int root_x, root_y; | ||
| 3807 | NSSize size; | ||
| 3808 | NSWindow *window; | ||
| 3809 | struct frame *tip_f; | ||
| 3810 | |||
| 3811 | if (!FIXNUMP (tip_dx) || !FIXNUMP (tip_dy)) | ||
| 3812 | return; | ||
| 3813 | |||
| 3814 | if (ns_tooltip) | ||
| 3815 | size = [ns_tooltip frame].size; | ||
| 3816 | else if (!FRAMEP (tip_frame) | ||
| 3817 | || !FRAME_LIVE_P (XFRAME (tip_frame))) | ||
| 3818 | return; | ||
| 3819 | else | ||
| 3820 | { | ||
| 3821 | tip_f = XFRAME (tip_frame); | ||
| 3822 | window = [FRAME_NS_VIEW (tip_f) window]; | ||
| 3823 | size = [window frame].size; | ||
| 3824 | } | ||
| 3825 | |||
| 3826 | root_x = screen_point.x; | ||
| 3827 | root_y = screen_point.y; | ||
| 3828 | |||
| 3829 | /* We can directly use `compute_tip_xy' here, since it doesn't cons | ||
| 3830 | nearly as much as it does on X. */ | ||
| 3831 | compute_tip_xy (NULL, Qnil, tip_dx, tip_dy, (int) size.width, | ||
| 3832 | (int) size.height, &root_x, &root_y); | ||
| 3833 | |||
| 3834 | if (ns_tooltip) | ||
| 3835 | [ns_tooltip moveTo: NSMakePoint (root_x, root_y)]; | ||
| 3836 | else | ||
| 3837 | [window setFrame: NSMakeRect (root_x, root_y, | ||
| 3838 | size.width, size.height) | ||
| 3839 | display: YES]; | ||
| 3840 | } | ||
| 3841 | |||
| 3797 | /* ========================================================================== | 3842 | /* ========================================================================== |
| 3798 | 3843 | ||
| 3799 | Lisp interface declaration | 3844 | Lisp interface declaration |
| @@ -3902,6 +3947,10 @@ Default is t. */); | |||
| 3902 | staticpro (&tip_last_string); | 3947 | staticpro (&tip_last_string); |
| 3903 | tip_last_parms = Qnil; | 3948 | tip_last_parms = Qnil; |
| 3904 | staticpro (&tip_last_parms); | 3949 | staticpro (&tip_last_parms); |
| 3950 | tip_dx = Qnil; | ||
| 3951 | staticpro (&tip_dx); | ||
| 3952 | tip_dy = Qnil; | ||
| 3953 | staticpro (&tip_dy); | ||
| 3905 | 3954 | ||
| 3906 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 | 3955 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 |
| 3907 | defsubr (&Ssystem_move_file_to_trash); | 3956 | defsubr (&Ssystem_move_file_to_trash); |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 028d19f597a..d02d7bae4b5 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1497,6 +1497,15 @@ update_frame_tool_bar (struct frame *f) | |||
| 1497 | [timer retain]; | 1497 | [timer retain]; |
| 1498 | } | 1498 | } |
| 1499 | 1499 | ||
| 1500 | - (void) moveTo: (NSPoint) screen_point | ||
| 1501 | { | ||
| 1502 | [win setFrame: NSMakeRect (screen_point.x, | ||
| 1503 | screen_point.y, | ||
| 1504 | [self frame].size.width, | ||
| 1505 | [self frame].size.height) | ||
| 1506 | display: YES]; | ||
| 1507 | } | ||
| 1508 | |||
| 1500 | - (void) hide | 1509 | - (void) hide |
| 1501 | { | 1510 | { |
| 1502 | [win close]; | 1511 | [win close]; |
diff --git a/src/nsselect.m b/src/nsselect.m index 6831090aa20..c46bfeaf42a 100644 --- a/src/nsselect.m +++ b/src/nsselect.m | |||
| @@ -703,7 +703,7 @@ ns_dnd_action_from_operation (NSDragOperation operation) | |||
| 703 | } | 703 | } |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | DEFUN ("ns-begin-drag", Fns_begin_drag, Sns_begin_drag, 3, 5, 0, | 706 | DEFUN ("ns-begin-drag", Fns_begin_drag, Sns_begin_drag, 3, 6, 0, |
| 707 | doc: /* Begin a drag-and-drop operation on FRAME. | 707 | doc: /* Begin a drag-and-drop operation on FRAME. |
| 708 | 708 | ||
| 709 | FRAME must be a window system frame. PBOARD is an alist of (TYPE | 709 | FRAME must be a window system frame. PBOARD is an alist of (TYPE |
| @@ -729,9 +729,12 @@ other non-nil value means to do the same, but to wait for the mouse to | |||
| 729 | leave FRAME first. | 729 | leave FRAME first. |
| 730 | 730 | ||
| 731 | If ALLOW-SAME-FRAME is nil, dropping on FRAME will result in the drop | 731 | If ALLOW-SAME-FRAME is nil, dropping on FRAME will result in the drop |
| 732 | being ignored. */) | 732 | being ignored. |
| 733 | |||
| 734 | FOLLOW-TOOLTIP means the same thing it does in `x-begin-drag'. */) | ||
| 733 | (Lisp_Object frame, Lisp_Object pboard, Lisp_Object action, | 735 | (Lisp_Object frame, Lisp_Object pboard, Lisp_Object action, |
| 734 | Lisp_Object return_frame, Lisp_Object allow_same_frame) | 736 | Lisp_Object return_frame, Lisp_Object allow_same_frame, |
| 737 | Lisp_Object follow_tooltip) | ||
| 735 | { | 738 | { |
| 736 | struct frame *f, *return_to; | 739 | struct frame *f, *return_to; |
| 737 | NSPasteboard *pasteboard; | 740 | NSPasteboard *pasteboard; |
| @@ -761,7 +764,8 @@ being ignored. */) | |||
| 761 | forPasteboard: pasteboard | 764 | forPasteboard: pasteboard |
| 762 | withMode: mode | 765 | withMode: mode |
| 763 | returnFrameTo: &return_to | 766 | returnFrameTo: &return_to |
| 764 | prohibitSame: (BOOL) NILP (allow_same_frame)]; | 767 | prohibitSame: (BOOL) NILP (allow_same_frame) |
| 768 | followTooltip: (BOOL) !NILP (follow_tooltip)]; | ||
| 765 | 769 | ||
| 766 | if (return_to) | 770 | if (return_to) |
| 767 | { | 771 | { |
diff --git a/src/nsterm.h b/src/nsterm.h index 37bff6260a0..c4fdc7054f7 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -426,6 +426,7 @@ enum ns_return_frame_mode | |||
| 426 | struct frame *dnd_return_frame; | 426 | struct frame *dnd_return_frame; |
| 427 | enum ns_return_frame_mode dnd_mode; | 427 | enum ns_return_frame_mode dnd_mode; |
| 428 | BOOL dnd_allow_same_frame; | 428 | BOOL dnd_allow_same_frame; |
| 429 | BOOL dnd_move_tooltip_with_frame; | ||
| 429 | } | 430 | } |
| 430 | 431 | ||
| 431 | #ifdef NS_IMPL_GNUSTEP | 432 | #ifdef NS_IMPL_GNUSTEP |
| @@ -446,7 +447,8 @@ enum ns_return_frame_mode | |||
| 446 | forPasteboard: (NSPasteboard *) pasteboard | 447 | forPasteboard: (NSPasteboard *) pasteboard |
| 447 | withMode: (enum ns_return_frame_mode) mode | 448 | withMode: (enum ns_return_frame_mode) mode |
| 448 | returnFrameTo: (struct frame **) frame_return | 449 | returnFrameTo: (struct frame **) frame_return |
| 449 | prohibitSame: (BOOL) prohibit_same_frame; | 450 | prohibitSame: (BOOL) prohibit_same_frame |
| 451 | followTooltip: (BOOL) follow_tooltip; | ||
| 450 | - (BOOL) mustNotDropOn: (NSView *) receiver; | 452 | - (BOOL) mustNotDropOn: (NSView *) receiver; |
| 451 | @end | 453 | @end |
| 452 | 454 | ||
| @@ -630,19 +632,21 @@ enum ns_return_frame_mode | |||
| 630 | #else | 632 | #else |
| 631 | @interface EmacsTooltip : NSObject | 633 | @interface EmacsTooltip : NSObject |
| 632 | #endif | 634 | #endif |
| 633 | { | 635 | { |
| 634 | NSWindow *win; | 636 | NSWindow *win; |
| 635 | NSTextField *textField; | 637 | NSTextField *textField; |
| 636 | NSTimer *timer; | 638 | NSTimer *timer; |
| 637 | } | 639 | } |
| 640 | |||
| 638 | - (instancetype) init; | 641 | - (instancetype) init; |
| 639 | - (void) setText: (char *)text; | 642 | - (void) setText: (char *) text; |
| 640 | - (void) setBackgroundColor: (NSColor *)col; | 643 | - (void) setBackgroundColor: (NSColor *) col; |
| 641 | - (void) setForegroundColor: (NSColor *)col; | 644 | - (void) setForegroundColor: (NSColor *) col; |
| 642 | - (void) showAtX: (int)x Y: (int)y for: (int)seconds; | 645 | - (void) showAtX: (int) x Y: (int) y for: (int) seconds; |
| 643 | - (void) hide; | 646 | - (void) hide; |
| 644 | - (BOOL) isActive; | 647 | - (BOOL) isActive; |
| 645 | - (NSRect) frame; | 648 | - (NSRect) frame; |
| 649 | - (void) moveTo: (NSPoint) screen_point; | ||
| 646 | @end | 650 | @end |
| 647 | 651 | ||
| 648 | 652 | ||
| @@ -1140,6 +1144,9 @@ extern const char *ns_get_pending_menu_title (void); | |||
| 1140 | #endif | 1144 | #endif |
| 1141 | 1145 | ||
| 1142 | /* Implemented in nsfns, published in nsterm. */ | 1146 | /* Implemented in nsfns, published in nsterm. */ |
| 1147 | #ifdef __OBJC__ | ||
| 1148 | extern void ns_move_tooltip_to_mouse_location (NSPoint); | ||
| 1149 | #endif | ||
| 1143 | extern void ns_implicitly_set_name (struct frame *f, Lisp_Object arg, | 1150 | extern void ns_implicitly_set_name (struct frame *f, Lisp_Object arg, |
| 1144 | Lisp_Object oldval); | 1151 | Lisp_Object oldval); |
| 1145 | extern void ns_set_scroll_bar_default_width (struct frame *f); | 1152 | extern void ns_set_scroll_bar_default_width (struct frame *f); |
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) | |||
| 9629 | selected_op = operation; | 9629 | selected_op = operation; |
| 9630 | } | 9630 | } |
| 9631 | 9631 | ||
| 9632 | #ifdef NS_IMPL_COCOA | ||
| 9633 | - (void) draggedImage: (NSImage *) dragged_image | 9632 | - (void) draggedImage: (NSImage *) dragged_image |
| 9634 | movedTo: (NSPoint) screen_point | 9633 | movedTo: (NSPoint) screen_point |
| 9635 | { | 9634 | { |
| 9635 | NSPoint mouse_loc; | ||
| 9636 | #ifdef NS_IMPL_COCOA | ||
| 9636 | NSInteger window_number; | 9637 | NSInteger window_number; |
| 9637 | NSWindow *w; | 9638 | NSWindow *w; |
| 9639 | #endif | ||
| 9638 | 9640 | ||
| 9639 | if (dnd_mode == RETURN_FRAME_NEVER) | 9641 | mouse_loc = [NSEvent mouseLocation]; |
| 9640 | return; | ||
| 9641 | 9642 | ||
| 9642 | window_number = [NSWindow windowNumberAtPoint: [NSEvent mouseLocation] | 9643 | #ifdef NS_IMPL_COCOA |
| 9643 | belowWindowWithWindowNumber: 0]; | 9644 | if (dnd_mode != RETURN_FRAME_NEVER) |
| 9644 | w = [NSApp windowWithWindowNumber: window_number]; | 9645 | { |
| 9646 | window_number = [NSWindow windowNumberAtPoint: mouse_loc | ||
| 9647 | belowWindowWithWindowNumber: 0]; | ||
| 9648 | w = [NSApp windowWithWindowNumber: window_number]; | ||
| 9645 | 9649 | ||
| 9646 | if (!w || w != self) | 9650 | if (!w || w != self) |
| 9647 | dnd_mode = RETURN_FRAME_NOW; | 9651 | dnd_mode = RETURN_FRAME_NOW; |
| 9648 | 9652 | ||
| 9649 | if (dnd_mode != RETURN_FRAME_NOW | 9653 | if (dnd_mode != RETURN_FRAME_NOW |
| 9650 | || ![[w delegate] isKindOfClass: [EmacsView class]]) | 9654 | || ![[w delegate] isKindOfClass: [EmacsView class]]) |
| 9651 | return; | 9655 | goto out; |
| 9652 | 9656 | ||
| 9653 | dnd_return_frame = ((EmacsView *) [w delegate])->emacsframe; | 9657 | dnd_return_frame = ((EmacsView *) [w delegate])->emacsframe; |
| 9654 | 9658 | ||
| 9655 | /* FIXME: there must be a better way to leave the event loop. */ | 9659 | /* FIXME: there must be a better way to leave the event loop. */ |
| 9656 | [NSException raise: @"" | 9660 | [NSException raise: @"" |
| 9657 | format: @"Must return DND frame"]; | 9661 | format: @"Must return DND frame"]; |
| 9658 | } | 9662 | } |
| 9659 | #endif | 9663 | #endif |
| 9660 | 9664 | ||
| 9665 | out: | ||
| 9666 | |||
| 9667 | if (dnd_move_tooltip_with_frame) | ||
| 9668 | ns_move_tooltip_to_mouse_location (mouse_loc); | ||
| 9669 | } | ||
| 9670 | |||
| 9661 | - (BOOL) mustNotDropOn: (NSView *) receiver | 9671 | - (BOOL) mustNotDropOn: (NSView *) receiver |
| 9662 | { | 9672 | { |
| 9663 | return ([receiver window] == self | 9673 | return ([receiver window] == self |
| @@ -9669,6 +9679,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9669 | withMode: (enum ns_return_frame_mode) mode | 9679 | withMode: (enum ns_return_frame_mode) mode |
| 9670 | returnFrameTo: (struct frame **) frame_return | 9680 | returnFrameTo: (struct frame **) frame_return |
| 9671 | prohibitSame: (BOOL) prohibit_same_frame | 9681 | prohibitSame: (BOOL) prohibit_same_frame |
| 9682 | followTooltip: (BOOL) follow_tooltip | ||
| 9672 | { | 9683 | { |
| 9673 | NSImage *image; | 9684 | NSImage *image; |
| 9674 | #ifdef NS_IMPL_COCOA | 9685 | #ifdef NS_IMPL_COCOA |
| @@ -9681,6 +9692,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9681 | dnd_mode = mode; | 9692 | dnd_mode = mode; |
| 9682 | dnd_return_frame = NULL; | 9693 | dnd_return_frame = NULL; |
| 9683 | dnd_allow_same_frame = !prohibit_same_frame; | 9694 | dnd_allow_same_frame = !prohibit_same_frame; |
| 9695 | dnd_move_tooltip_with_frame = follow_tooltip; | ||
| 9684 | 9696 | ||
| 9685 | /* Now draw transparency onto the image. */ | 9697 | /* Now draw transparency onto the image. */ |
| 9686 | [image lockFocus]; | 9698 | [image lockFocus]; |
| @@ -9728,6 +9740,10 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c) | |||
| 9728 | #endif | 9740 | #endif |
| 9729 | unblock_input (); | 9741 | unblock_input (); |
| 9730 | 9742 | ||
| 9743 | /* The drop happened, so delete the tooltip. */ | ||
| 9744 | if (follow_tooltip) | ||
| 9745 | Fx_hide_tip (); | ||
| 9746 | |||
| 9731 | /* Assume all buttons have been released since the drag-and-drop | 9747 | /* Assume all buttons have been released since the drag-and-drop |
| 9732 | operation is now over. */ | 9748 | operation is now over. */ |
| 9733 | if (!dnd_return_frame) | 9749 | if (!dnd_return_frame) |