changeset 30224:b9f781194989

(Fx_show_tip): If frame parameters contain a position, use that instead of the mouse position. Add parameters DX and DY.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 14 Jul 2000 15:18:29 +0000
parents 1e3c0447c01a
children 2e0e027ab8f8
files src/xfns.c
diffstat 1 files changed, 43 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Fri Jul 14 15:14:58 2000 +0000
+++ b/src/xfns.c	Fri Jul 14 15:18:29 2000 +0000
@@ -9821,22 +9821,32 @@
 }
 
 
-DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 4, 0,
+DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
   "Show STRING in a \"tooltip\" window on frame FRAME.\n\
-A tooltip window is a small X window displaying STRING at\n\
-the current mouse position.\n\
+A tooltip window is a small X window displaying a string.\n\
+\n\
 FRAME nil or omitted means use the selected frame.\n\
+\n\
 PARMS is an optional list of frame parameters which can be\n\
 used to change the tooltip's appearance.\n\
+\n\
 Automatically hide the tooltip after TIMEOUT seconds.\n\
-TIMEOUT nil means use the default timeout of 5 seconds.")
-  (string, frame, parms, timeout)
-     Lisp_Object string, frame, parms, timeout;
+TIMEOUT nil means use the default timeout of 5 seconds.\n\
+\n\
+If the list of frame parameters PARAMS contains a `left' parameters,\n\
+the tooltip is displayed at that x-position.  Otherwise it is\n\
+displayed at the mouse position, with offset DX added (default is 5 if\n\
+DX isn't specified).  Likewise for the y-position; if a `top' frame\n\
+parameter is specified, it determines the y-position of the tooltip\n\
+window, otherwise it is displayed at the mouse position, with offset\n\
+DY added (default is -5).")
+  (string, frame, parms, timeout, dx, dy)
+     Lisp_Object string, frame, parms, timeout, dx, dy;
 {
   struct frame *f;
   struct window *w;
   Window root, child;
-  Lisp_Object buffer;
+  Lisp_Object buffer, top, left;
   struct buffer *old_buffer;
   struct text_pos pos;
   int i, width, height;
@@ -9856,6 +9866,16 @@
     timeout = make_number (5);
   else
     CHECK_NATNUM (timeout, 2);
+  
+  if (NILP (dx))
+    dx = make_number (5);
+  else
+    CHECK_NUMBER (dx, 5);
+  
+  if (NILP (dy))
+    dy = make_number (-5);
+  else
+    CHECK_NUMBER (dy, 6);
 
   /* Hide a previous tip, if any.  */
   Fx_hide_tip ();
@@ -9934,13 +9954,28 @@
   height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
   width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
 
+  /* User-specified position?  */
+  left = Fcdr (Fassq (Qleft, parms));
+  top  = Fcdr (Fassq (Qtop, parms));
+  
   /* Move the tooltip window where the mouse pointer is.  Resize and
      show it.  */
   BLOCK_INPUT;
   XQueryPointer (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
 		 &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);
+  UNBLOCK_INPUT;
+
+  root_x += XINT (dx);
+  root_y += XINT (dy);
+  
+  if (INTEGERP (left))
+    root_x = XINT (left);
+  if (INTEGERP (top))
+    root_y = XINT (top);
+  
+  BLOCK_INPUT;
   XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		     root_x + 5, root_y - height - 5, width, height);
+		     root_x, root_y - height, width, height);
   XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
   UNBLOCK_INPUT;