Mercurial > emacs
changeset 109094:3c35c7d2d79b
New functions that return window edges with absolute coords (bug#5721).
* window.c (calc_absolute_offset, Fwindow_absolute_pixel_edges)
(Fwindow_inside_absolute_pixel_edges): New functions (bug#5721).
author | Jan D <jan.h.d@swipnet.se> |
---|---|
date | Thu, 01 Jul 2010 14:34:40 +0200 |
parents | 8c569638df0f |
children | c9fdfb1ca05e |
files | src/ChangeLog src/window.c |
diffstat | 2 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Thu Jul 01 14:20:14 2010 +0200 +++ b/src/ChangeLog Thu Jul 01 14:34:40 2010 +0200 @@ -1,5 +1,8 @@ 2010-07-01 Jan Djärv <jan.h.d@swipnet.se> + * window.c (calc_absolute_offset, Fwindow_absolute_pixel_edges) + (Fwindow_inside_absolute_pixel_edges): New functions (bug#5721). + * nsfns.m (compute_tip_xy): Do not convert coordinates from frame parameters, they are already absolute.
--- a/src/window.c Thu Jul 01 14:20:14 2010 +0200 +++ b/src/window.c Thu Jul 01 14:34:40 2010 +0200 @@ -652,6 +652,48 @@ Qnil)))); } +static void +calc_absolute_offset(struct window *w, int *add_x, int *add_y) +{ + struct frame *f = XFRAME (w->frame); + *add_y = f->top_pos; +#ifdef FRAME_MENUBAR_HEIGHT + *add_y += FRAME_MENUBAR_HEIGHT (f); +#endif +#ifdef FRAME_TOOLBAR_HEIGHT + *add_y += FRAME_TOOLBAR_HEIGHT (f); +#endif +#ifdef FRAME_NS_TITLEBAR_HEIGHT + *add_y += FRAME_NS_TITLEBAR_HEIGHT (f); +#endif + *add_x = f->left_pos; +} + +DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, + Swindow_absolute_pixel_edges, 0, 1, 0, + doc: /* Return a list of the edge pixel coordinates of WINDOW. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at +the top left corner of the display. + +RIGHT is one more than the rightmost x position occupied by WINDOW. +BOTTOM is one more than the bottommost y position occupied by WINDOW. +The pixel edges include the space used by WINDOW's scroll bar, display +margins, fringes, header line, and/or mode line. For the pixel edges +of just the text area, use `window-inside-pixel-edges'. */) + (window) + Lisp_Object window; +{ + register struct window *w = decode_any_window (window); + int add_x, add_y; + calc_absolute_offset(w, &add_x, &add_y); + + return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x), + Fcons (make_number (WINDOW_TOP_EDGE_Y (w) + add_y), + Fcons (make_number (WINDOW_RIGHT_EDGE_X (w) + add_x), + Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w) + add_y), + Qnil)))); +} + DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, doc: /* Return a list of the edge coordinates of WINDOW. The list has the form (LEFT TOP RIGHT BOTTOM). @@ -705,6 +747,36 @@ - WINDOW_MODE_LINE_HEIGHT (w))); } +DEFUN ("window-inside-absolute-pixel-edges", + Fwindow_inside_absolute_pixel_edges, + Swindow_inside_absolute_pixel_edges, 0, 1, 0, + doc: /* Return a list of the edge pixel coordinates of WINDOW. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at +the top left corner of the display. + +RIGHT is one more than the rightmost x position of WINDOW's text area. +BOTTOM is one more than the bottommost y position of WINDOW's text area. +The inside edges do not include the space used by WINDOW's scroll bar, +display margins, fringes, header line, and/or mode line. */) + (window) + Lisp_Object window; +{ + register struct window *w = decode_any_window (window); + int add_x, add_y; + calc_absolute_offset(w, &add_x, &add_y); + + return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) + + WINDOW_LEFT_MARGIN_WIDTH (w) + + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x), + make_number (WINDOW_TOP_EDGE_Y (w) + + WINDOW_HEADER_LINE_HEIGHT (w) + add_y), + make_number (WINDOW_BOX_RIGHT_EDGE_X (w) + - WINDOW_RIGHT_MARGIN_WIDTH (w) + - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x), + make_number (WINDOW_BOTTOM_EDGE_Y (w) + - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); +} + /* Test if the character at column *X, row *Y is within window W. If it is not, return ON_NOTHING; if it is in the window's text area, @@ -7312,8 +7384,10 @@ defsubr (&Sset_window_redisplay_end_trigger); defsubr (&Swindow_edges); defsubr (&Swindow_pixel_edges); + defsubr (&Swindow_absolute_pixel_edges); defsubr (&Swindow_inside_edges); defsubr (&Swindow_inside_pixel_edges); + defsubr (&Swindow_inside_absolute_pixel_edges); defsubr (&Scoordinates_in_window_p); defsubr (&Swindow_at); defsubr (&Swindow_point);