summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/macfns.c14
-rw-r--r--src/w32fns.c17
-rw-r--r--src/xfns.c17
3 files changed, 24 insertions, 24 deletions
diff --git a/src/macfns.c b/src/macfns.c
index 9d23f47b5ed..de6a055fce6 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -3840,13 +3840,15 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
if (INTEGERP (top))
*root_y = XINT (top);
- else if (*root_y + XINT (dy) - height < 0)
- *root_y -= XINT (dy);
- else
- {
- *root_y -= height;
+ else if (*root_y + XINT (dy) + height <= FRAME_MAC_DISPLAY_INFO (f)->height)
+ /* It fits below the pointer */
*root_y += XINT (dy);
- }
+ else if (height + XINT (dy) <= *root_y)
+ /* It fits above the pointer. */
+ *root_y -= height + XINT (dy);
+ else
+ /* Put it on the top. */
+ *root_y = 0;
if (INTEGERP (left))
*root_x = XINT (left);
diff --git a/src/w32fns.c b/src/w32fns.c
index d1e4e49bb03..647267972dc 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -7411,16 +7411,15 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
if (INTEGERP (top))
*root_y = XINT (top);
- else if (*root_y + XINT (dy) - height < 0)
- *root_y -= XINT (dy);
- /* If there's not enough place below the pointer, put tip above it. */
- else if (*root_y + XINT (dy) >= FRAME_W32_DISPLAY_INFO (f)->height)
- *root_y -= XINT (dy);
- else
- {
- *root_y -= height;
+ else if (*root_y + XINT (dy) + height <= FRAME_W32_DISPLAY_INFO (f)->height)
+ /* It fits below the pointer */
*root_y += XINT (dy);
- }
+ else if (height + XINT (dy) <= *root_y)
+ /* It fits above the pointer. */
+ *root_y -= height + XINT (dy);
+ else
+ /* Put it on the top. */
+ *root_y = 0;
if (INTEGERP (left))
*root_x = XINT (left);
diff --git a/src/xfns.c b/src/xfns.c
index ee4a7bf3b00..667b1411d1c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4940,16 +4940,15 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
if (INTEGERP (top))
*root_y = XINT (top);
- else if (*root_y + XINT (dy) - height < 0)
- *root_y -= XINT (dy);
- else if (*root_y + XINT (dy) >= FRAME_X_DISPLAY_INFO (f)->height)
- /* Put tip above the pointer. */
- *root_y -= XINT (dy);
- else
- {
- *root_y -= height;
+ else if (*root_y + XINT (dy) + height <= FRAME_X_DISPLAY_INFO (f)->height)
+ /* It fits below the pointer */
*root_y += XINT (dy);
- }
+ else if (height + XINT (dy) <= *root_y)
+ /* It fits above the pointer. */
+ *root_y -= height + XINT (dy);
+ else
+ /* Put it on the top. */
+ *root_y = 0;
if (INTEGERP (left))
*root_x = XINT (left);