i.e. dy is offset from top of frame instead of bottom.
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);
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);
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);