diff options
| author | Jan D | 2010-07-01 14:34:40 +0200 |
|---|---|---|
| committer | Jan D | 2010-07-01 14:34:40 +0200 |
| commit | 9d5405ec3c2761b5970fbb37397375ae62dc1833 (patch) | |
| tree | 6cca052c4c2653ed43a139606938b82d1225c3bb /src | |
| parent | 7a18115b47a70b38ead24ee29ec308c4f2da007f (diff) | |
| download | emacs-9d5405ec3c2761b5970fbb37397375ae62dc1833.tar.gz emacs-9d5405ec3c2761b5970fbb37397375ae62dc1833.zip | |
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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/window.c | 74 |
2 files changed, 77 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8a49d47b266..ce75b2800b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2010-07-01 Jan Djärv <jan.h.d@swipnet.se> | 1 | 2010-07-01 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 2 | ||
| 3 | * window.c (calc_absolute_offset, Fwindow_absolute_pixel_edges) | ||
| 4 | (Fwindow_inside_absolute_pixel_edges): New functions (bug#5721). | ||
| 5 | |||
| 3 | * nsfns.m (compute_tip_xy): Do not convert coordinates from frame | 6 | * nsfns.m (compute_tip_xy): Do not convert coordinates from frame |
| 4 | parameters, they are already absolute. | 7 | parameters, they are already absolute. |
| 5 | 8 | ||
diff --git a/src/window.c b/src/window.c index c105e37c462..deca842243a 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -652,6 +652,48 @@ of just the text area, use `window-inside-pixel-edges'. */) | |||
| 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). |
| @@ -705,6 +747,36 @@ display margins, fringes, header line, and/or mode line. */) | |||
| 705 | - WINDOW_MODE_LINE_HEIGHT (w))); | 747 | - WINDOW_MODE_LINE_HEIGHT (w))); |
| 706 | } | 748 | } |
| 707 | 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)); | ||
| 778 | } | ||
| 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, |
| @@ -7312,8 +7384,10 @@ frame to be redrawn only if it is a tty frame. */); | |||
| 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); |