Function: mouse-position-in-root-frame

mouse-position-in-root-frame is a function defined in frame.c.

Signature

(mouse-position-in-root-frame)

Documentation

Return mouse position in selected frame's root frame.

Return the position of mouse-position in coordinates of the root frame of the frame returned by 'mouse-position'.

Source Code

// Defined in /usr/src/emacs/src/frame.c
{
  Lisp_Object pos = mouse_position (true);
  Lisp_Object frame = XCAR (pos);

  if (!FRAMEP (frame))
    return Qnil;
  else
    {
      struct frame *f = XFRAME (frame);
      int x = XFIXNUM (XCAR (XCDR (pos))) + f->left_pos;
      int y = XFIXNUM (XCDR (XCDR (pos))) + f->top_pos;

      f = FRAME_PARENT_FRAME (f);

      while (f)
	{
	  x = x + f->left_pos;
	  y = y + f->top_pos;
	  f = FRAME_PARENT_FRAME (f);
	}

      return Fcons (make_fixnum (x), make_fixnum (y));
    }
}