changeset 7025:24e759919770

(Fmouse_pixel_position, Fset_mouse_pixel_position): New functions. (syms_of_frame): Set up Lisp functions.
author Richard M. Stallman <rms@gnu.org>
date Fri, 22 Apr 1994 21:45:11 +0000
parents f00ad05e91b0
children 55f9a506180d
files src/frame.c
diffstat 1 files changed, 56 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/frame.c	Fri Apr 22 20:20:49 1994 +0000
+++ b/src/frame.c	Fri Apr 22 21:45:11 1994 +0000
@@ -935,9 +935,40 @@
   return Fcons (lispy_dummy, Fcons (x, y));
 }
 
+DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
+       Smouse_pixel_position, 0, 0, 0,
+  "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
+The position is given in pixel units, where (0, 0) is the\n\
+upper-left corner.\n\
+If Emacs is running on a mouseless terminal or hasn't been programmed\n\
+to read the mouse position, it returns the selected frame for FRAME\n\
+and nil for X and Y.")
+  ()
+{
+  FRAME_PTR f;
+  Lisp_Object lispy_dummy;
+  enum scroll_bar_part party_dummy;
+  Lisp_Object x, y;
+  int col, row;
+  unsigned long long_dummy;
+
+  f = selected_frame;
+  x = y = Qnil;
+
+  /* It's okay for the hook to refrain from storing anything.  */
+  if (mouse_position_hook)
+    (*mouse_position_hook) (&f,
+			    &lispy_dummy, &party_dummy,
+			    &x, &y,
+			    &long_dummy);
+  XSET (lispy_dummy, Lisp_Frame, f);
+  return Fcons (lispy_dummy, Fcons (x, y));
+}
+
 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
   "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
-WARNING:  If you use this under X, you should do `unfocus-frame' afterwards.")
+WARNING:  If you use this under X windows,\n\
+you should call `unfocus-frame' afterwards.")
   (frame, x, y)
      Lisp_Object frame, x, y;
 {
@@ -954,6 +985,28 @@
 
   return Qnil;
 }
+
+DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
+       Sset_mouse_pixel_position, 3, 3, 0,
+  "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
+WARNING:  If you use this under X windows,\n\
+you should call `unfocus-frame' afterwards.")
+  (frame, x, y)
+     Lisp_Object frame, x, y;
+{
+  CHECK_LIVE_FRAME (frame, 0);
+  CHECK_NUMBER (x, 2);
+  CHECK_NUMBER (y, 1);
+
+  /* I think this should be done with a hook.  */
+#ifdef HAVE_X_WINDOWS
+  if (FRAME_X_P (XFRAME (frame)))
+    /* Warping the mouse will cause  enternotify and focus events. */
+    x_set_mouse_pixel_position (XFRAME (frame), x, y);
+#endif
+
+  return Qnil;
+}
 
 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
        0, 1, "",
@@ -1650,7 +1703,9 @@
   defsubr (&Sprevious_frame);
   defsubr (&Sdelete_frame);
   defsubr (&Smouse_position);
+  defsubr (&Smouse_pixel_position);
   defsubr (&Sset_mouse_position);
+  defsubr (&Sset_mouse_pixel_position);
 #if 0
   defsubr (&Sframe_configuration);
   defsubr (&Srestore_frame_configuration);