comparison src/window.c @ 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 580a6ea34172
children 43b10f3ac90c
comparison
equal deleted inserted replaced
109093:8c569638df0f 109094:3c35c7d2d79b
650 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w)), 650 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w)),
651 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w)), 651 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w)),
652 Qnil)))); 652 Qnil))));
653 } 653 }
654 654
655 static void
656 calc_absolute_offset(struct window *w, int *add_x, int *add_y)
657 {
658 struct frame *f = XFRAME (w->frame);
659 *add_y = f->top_pos;
660 #ifdef FRAME_MENUBAR_HEIGHT
661 *add_y += FRAME_MENUBAR_HEIGHT (f);
662 #endif
663 #ifdef FRAME_TOOLBAR_HEIGHT
664 *add_y += FRAME_TOOLBAR_HEIGHT (f);
665 #endif
666 #ifdef FRAME_NS_TITLEBAR_HEIGHT
667 *add_y += FRAME_NS_TITLEBAR_HEIGHT (f);
668 #endif
669 *add_x = f->left_pos;
670 }
671
672 DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges,
673 Swindow_absolute_pixel_edges, 0, 1, 0,
674 doc: /* Return a list of the edge pixel coordinates of WINDOW.
675 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
676 the top left corner of the display.
677
678 RIGHT is one more than the rightmost x position occupied by WINDOW.
679 BOTTOM is one more than the bottommost y position occupied by WINDOW.
680 The pixel edges include the space used by WINDOW's scroll bar, display
681 margins, fringes, header line, and/or mode line. For the pixel edges
682 of just the text area, use `window-inside-pixel-edges'. */)
683 (window)
684 Lisp_Object window;
685 {
686 register struct window *w = decode_any_window (window);
687 int add_x, add_y;
688 calc_absolute_offset(w, &add_x, &add_y);
689
690 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x),
691 Fcons (make_number (WINDOW_TOP_EDGE_Y (w) + add_y),
692 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w) + add_x),
693 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w) + add_y),
694 Qnil))));
695 }
696
655 DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, 697 DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0,
656 doc: /* Return a list of the edge coordinates of WINDOW. 698 doc: /* Return a list of the edge coordinates of WINDOW.
657 The list has the form (LEFT TOP RIGHT BOTTOM). 699 The list has the form (LEFT TOP RIGHT BOTTOM).
658 TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, 700 TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns,
659 all relative to 0, 0 at top left corner of frame. 701 all relative to 0, 0 at top left corner of frame.
701 make_number (WINDOW_BOX_RIGHT_EDGE_X (w) 743 make_number (WINDOW_BOX_RIGHT_EDGE_X (w)
702 - WINDOW_RIGHT_MARGIN_WIDTH (w) 744 - WINDOW_RIGHT_MARGIN_WIDTH (w)
703 - WINDOW_RIGHT_FRINGE_WIDTH (w)), 745 - WINDOW_RIGHT_FRINGE_WIDTH (w)),
704 make_number (WINDOW_BOTTOM_EDGE_Y (w) 746 make_number (WINDOW_BOTTOM_EDGE_Y (w)
705 - WINDOW_MODE_LINE_HEIGHT (w))); 747 - WINDOW_MODE_LINE_HEIGHT (w)));
748 }
749
750 DEFUN ("window-inside-absolute-pixel-edges",
751 Fwindow_inside_absolute_pixel_edges,
752 Swindow_inside_absolute_pixel_edges, 0, 1, 0,
753 doc: /* Return a list of the edge pixel coordinates of WINDOW.
754 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
755 the top left corner of the display.
756
757 RIGHT is one more than the rightmost x position of WINDOW's text area.
758 BOTTOM is one more than the bottommost y position of WINDOW's text area.
759 The inside edges do not include the space used by WINDOW's scroll bar,
760 display margins, fringes, header line, and/or mode line. */)
761 (window)
762 Lisp_Object window;
763 {
764 register struct window *w = decode_any_window (window);
765 int add_x, add_y;
766 calc_absolute_offset(w, &add_x, &add_y);
767
768 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w)
769 + WINDOW_LEFT_MARGIN_WIDTH (w)
770 + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x),
771 make_number (WINDOW_TOP_EDGE_Y (w)
772 + WINDOW_HEADER_LINE_HEIGHT (w) + add_y),
773 make_number (WINDOW_BOX_RIGHT_EDGE_X (w)
774 - WINDOW_RIGHT_MARGIN_WIDTH (w)
775 - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x),
776 make_number (WINDOW_BOTTOM_EDGE_Y (w)
777 - WINDOW_MODE_LINE_HEIGHT (w) + add_y));
706 } 778 }
707 779
708 /* Test if the character at column *X, row *Y is within window W. 780 /* Test if the character at column *X, row *Y is within window W.
709 If it is not, return ON_NOTHING; 781 If it is not, return ON_NOTHING;
710 if it is in the window's text area, 782 if it is in the window's text area,
7310 defsubr (&Sset_window_hscroll); 7382 defsubr (&Sset_window_hscroll);
7311 defsubr (&Swindow_redisplay_end_trigger); 7383 defsubr (&Swindow_redisplay_end_trigger);
7312 defsubr (&Sset_window_redisplay_end_trigger); 7384 defsubr (&Sset_window_redisplay_end_trigger);
7313 defsubr (&Swindow_edges); 7385 defsubr (&Swindow_edges);
7314 defsubr (&Swindow_pixel_edges); 7386 defsubr (&Swindow_pixel_edges);
7387 defsubr (&Swindow_absolute_pixel_edges);
7315 defsubr (&Swindow_inside_edges); 7388 defsubr (&Swindow_inside_edges);
7316 defsubr (&Swindow_inside_pixel_edges); 7389 defsubr (&Swindow_inside_pixel_edges);
7390 defsubr (&Swindow_inside_absolute_pixel_edges);
7317 defsubr (&Scoordinates_in_window_p); 7391 defsubr (&Scoordinates_in_window_p);
7318 defsubr (&Swindow_at); 7392 defsubr (&Swindow_at);
7319 defsubr (&Swindow_point); 7393 defsubr (&Swindow_point);
7320 defsubr (&Swindow_start); 7394 defsubr (&Swindow_start);
7321 defsubr (&Swindow_end); 7395 defsubr (&Swindow_end);