aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2017-05-16 22:36:21 +0100
committerAlan Third2017-05-21 00:09:41 +0100
commitc969b3997168de2bbe781fbcb08b67b15eddc02d (patch)
tree964dd52acb810107d583c652c958c1bcd353472e /src
parentee54d2f4e439b4a211c8fb7541ce22bac65bde8f (diff)
downloademacs-c969b3997168de2bbe781fbcb08b67b15eddc02d.tar.gz
emacs-c969b3997168de2bbe781fbcb08b67b15eddc02d.zip
Show tooltip on correct screen (bug#26905)
* src/nsfns.m (compute_tip_xy): Find the correct screen for the tooltip and constrain it to that screen.
Diffstat (limited to 'src')
-rw-r--r--src/nsfns.m27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index cbe0ffb8580..04565a99bb7 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2760,6 +2760,7 @@ compute_tip_xy (struct frame *f,
2760 EmacsView *view = FRAME_NS_VIEW (f); 2760 EmacsView *view = FRAME_NS_VIEW (f);
2761 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 2761 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
2762 NSPoint pt; 2762 NSPoint pt;
2763 NSScreen *screen;
2763 2764
2764 /* Start with user-specified or mouse position. */ 2765 /* Start with user-specified or mouse position. */
2765 left = Fcdr (Fassq (Qleft, parms)); 2766 left = Fcdr (Fassq (Qleft, parms));
@@ -2794,13 +2795,25 @@ compute_tip_xy (struct frame *f,
2794 - height); 2795 - height);
2795 } 2796 }
2796 2797
2798 /* Find the screen that pt is on. */
2799 for (screen in [NSScreen screens])
2800#ifdef NS_IMPL_COCOA
2801 if (CGRectContainsPoint ([screen frame], pt))
2802#else
2803 if (pt.x >= screen.frame.origin.x
2804 && pt.x < screen.frame.origin.x + screen.frame.size.width
2805 && pt.y >= screen.frame.origin.y
2806 && pt.y < screen.frame.origin.y + screen.frame.size.height)
2807#endif
2808 break;
2809
2797 /* Ensure in bounds. (Note, screen origin = lower left.) */ 2810 /* Ensure in bounds. (Note, screen origin = lower left.) */
2798 if (INTEGERP (left) || INTEGERP (right)) 2811 if (INTEGERP (left) || INTEGERP (right))
2799 *root_x = pt.x; 2812 *root_x = pt.x;
2800 else if (pt.x + XINT (dx) <= 0) 2813 else if (pt.x + XINT (dx) <= screen.frame.origin.x)
2801 *root_x = 0; /* Can happen for negative dx */ 2814 *root_x = screen.frame.origin.x; /* Can happen for negative dx */
2802 else if (pt.x + XINT (dx) + width 2815 else if (pt.x + XINT (dx) + width
2803 <= x_display_pixel_width (FRAME_DISPLAY_INFO (f))) 2816 <= screen.frame.origin.x + screen.frame.size.width)
2804 /* It fits to the right of the pointer. */ 2817 /* It fits to the right of the pointer. */
2805 *root_x = pt.x + XINT (dx); 2818 *root_x = pt.x + XINT (dx);
2806 else if (width + XINT (dx) <= pt.x) 2819 else if (width + XINT (dx) <= pt.x)
@@ -2808,20 +2821,20 @@ compute_tip_xy (struct frame *f,
2808 *root_x = pt.x - width - XINT (dx); 2821 *root_x = pt.x - width - XINT (dx);
2809 else 2822 else
2810 /* Put it left justified on the screen -- it ought to fit that way. */ 2823 /* Put it left justified on the screen -- it ought to fit that way. */
2811 *root_x = 0; 2824 *root_x = screen.frame.origin.x;
2812 2825
2813 if (INTEGERP (top) || INTEGERP (bottom)) 2826 if (INTEGERP (top) || INTEGERP (bottom))
2814 *root_y = pt.y; 2827 *root_y = pt.y;
2815 else if (pt.y - XINT (dy) - height >= 0) 2828 else if (pt.y - XINT (dy) - height >= screen.frame.origin.y)
2816 /* It fits below the pointer. */ 2829 /* It fits below the pointer. */
2817 *root_y = pt.y - height - XINT (dy); 2830 *root_y = pt.y - height - XINT (dy);
2818 else if (pt.y + XINT (dy) + height 2831 else if (pt.y + XINT (dy) + height
2819 <= x_display_pixel_height (FRAME_DISPLAY_INFO (f))) 2832 <= screen.frame.origin.y + screen.frame.size.height)
2820 /* It fits above the pointer */ 2833 /* It fits above the pointer */
2821 *root_y = pt.y + XINT (dy); 2834 *root_y = pt.y + XINT (dy);
2822 else 2835 else
2823 /* Put it on the top. */ 2836 /* Put it on the top. */
2824 *root_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - height; 2837 *root_y = screen.frame.origin.y + screen.frame.size.height - height;
2825} 2838}
2826 2839
2827 2840