comparison src/window.c @ 35800:fe8277459ef3

(enum window_part): New enumeration. (Qleft_fringe, Qright_fringe): Replace Qleft_bitmap_area and Qright_bitmap_area. (coordinates_in_window): Return an enumerator from enum window_part. Fix handling of right scroll bar. (Fcoordinates_in_window_p): Doc fix. Return `left-fringe' and `right-fringe' instead of `left-bitmap-area' and `right-bitmap-area'. Use enumerators from enum window_part instead of hard-coded integers. (check_window_containing, window_from_coordinates): Use enumerators from enum window_part instead of hard-coded integers. (syms_of_window): Replace Qleft_bitmap_area and Qright_bitmap_area.with Qleft_fringe and Qright_fringe.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 31 Jan 2001 20:26:26 +0000
parents 22d10a2fa31a
children ca8a0bbc64f7
comparison
equal deleted inserted replaced
35799:74655128ce2d 35800:fe8277459ef3
49 49
50 #ifndef max 50 #ifndef max
51 #define max(a, b) ((a) < (b) ? (b) : (a)) 51 #define max(a, b) ((a) < (b) ? (b) : (a))
52 #endif 52 #endif
53 53
54 /* Values returned from coordinates_in_window. */
55
56 enum window_part
57 {
58 ON_NOTHING,
59 ON_TEXT,
60 ON_MODE_LINE,
61 ON_VERTICAL_BORDER,
62 ON_HEADER_LINE,
63 ON_LEFT_FRINGE,
64 ON_RIGHT_FRINGE
65 };
66
54 67
55 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; 68 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
56 Lisp_Object Qwindow_size_fixed, Qleft_bitmap_area, Qright_bitmap_area; 69 Lisp_Object Qwindow_size_fixed, Qleft_fringe, Qright_fringe;
57 extern Lisp_Object Qheight, Qwidth; 70 extern Lisp_Object Qheight, Qwidth;
58 71
59 static struct window *decode_window P_ ((Lisp_Object)); 72 static struct window *decode_window P_ ((Lisp_Object));
60 static Lisp_Object select_window_1 P_ ((Lisp_Object, int)); 73 static Lisp_Object select_window_1 P_ ((Lisp_Object, int));
61 static int count_windows P_ ((struct window *)); 74 static int count_windows P_ ((struct window *));
497 if it is in the bitmap area to the left/right of the window, 510 if it is in the bitmap area to the left/right of the window,
498 return 5 or 6, and convert *X and *Y to window-relative corrdinates. 511 return 5 or 6, and convert *X and *Y to window-relative corrdinates.
499 512
500 X and Y are frame relative pixel coordinates. */ 513 X and Y are frame relative pixel coordinates. */
501 514
502 static int 515 static enum window_part
503 coordinates_in_window (w, x, y) 516 coordinates_in_window (w, x, y)
504 register struct window *w; 517 register struct window *w;
505 register int *x, *y; 518 register int *x, *y;
506 { 519 {
507 /* Let's make this a global enum later, instead of using numbers 520 /* Let's make this a global enum later, instead of using numbers
508 everywhere. */ 521 everywhere. */
509 enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER,
510 ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE};
511
512 struct frame *f = XFRAME (WINDOW_FRAME (w)); 522 struct frame *f = XFRAME (WINDOW_FRAME (w));
513 int left_x, right_x, top_y, bottom_y; 523 int left_x, right_x, top_y, bottom_y;
514 int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); 524 int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f);
515 int part; 525 enum window_part part;
516 int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f); 526 int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f);
517 int x0 = XFASTINT (w->left) * ux; 527 int x0 = XFASTINT (w->left) * ux;
518 int x1 = x0 + XFASTINT (w->width) * ux; 528 int x1 = x0 + XFASTINT (w->width) * ux;
519 529
520 if (*x < x0 || *x >= x1) 530 if (*x < x0 || *x >= x1)
581 else if (*y < top_y 591 else if (*y < top_y
582 || *y >= bottom_y 592 || *y >= bottom_y
583 || *x < (left_x 593 || *x < (left_x
584 - flags_area_width 594 - flags_area_width
585 - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux) 595 - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux)
586 || *x > right_x + flags_area_width) 596 || *x > (right_x
597 + flags_area_width
598 + FRAME_RIGHT_SCROLL_BAR_WIDTH (f) * ux))
587 { 599 {
588 part = ON_NOTHING; 600 part = ON_NOTHING;
589 } 601 }
590 else if (FRAME_WINDOW_P (f)) 602 else if (FRAME_WINDOW_P (f))
591 { 603 {
652 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 664 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
653 Scoordinates_in_window_p, 2, 2, 0, 665 Scoordinates_in_window_p, 2, 2, 0,
654 "Return non-nil if COORDINATES are in WINDOW.\n\ 666 "Return non-nil if COORDINATES are in WINDOW.\n\
655 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ 667 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
656 measured in characters from the upper-left corner of the frame.\n\ 668 measured in characters from the upper-left corner of the frame.\n\
657 (0 . 0) denotes the character in the upper left corner of the\n\ 669 \(0 . 0) denotes the character in the upper left corner of the\n\
658 frame.\n\ 670 frame.\n\
659 If COORDINATES are in the text portion of WINDOW,\n\ 671 If COORDINATES are in the text portion of WINDOW,\n\
660 the coordinates relative to the window are returned.\n\ 672 the coordinates relative to the window are returned.\n\
661 If they are in the mode line of WINDOW, `mode-line' is returned.\n\ 673 If they are in the mode line of WINDOW, `mode-line' is returned.\n\
662 If they are in the top mode line of WINDOW, `header-line' is returned.\n\ 674 If they are in the top mode line of WINDOW, `header-line' is returned.\n\
663 If they are in the bitmap-area to the left of the window,\n\ 675 If they are in the fringe to the left of the window,\n\
664 `left-bitmap-area' is returned, if they are in the area on the right of\n\ 676 `left-fringe' is returned, if they are in the area on the right of\n\
665 the window, `right-bitmap-area' is returned.\n\ 677 the window, `right-fringe' is returned.\n\
666 If they are on the border between WINDOW and its right sibling,\n\ 678 If they are on the border between WINDOW and its right sibling,\n\
667 `vertical-line' is returned.") 679 `vertical-line' is returned.")
668 (coordinates, window) 680 (coordinates, window)
669 register Lisp_Object coordinates, window; 681 register Lisp_Object coordinates, window;
670 { 682 {
684 x = PIXEL_X_FROM_CANON_X (f, lx); 696 x = PIXEL_X_FROM_CANON_X (f, lx);
685 y = PIXEL_Y_FROM_CANON_Y (f, ly); 697 y = PIXEL_Y_FROM_CANON_Y (f, ly);
686 698
687 switch (coordinates_in_window (w, &x, &y)) 699 switch (coordinates_in_window (w, &x, &y))
688 { 700 {
689 case 0: /* NOT in window at all. */ 701 case ON_NOTHING:
690 return Qnil; 702 return Qnil;
691 703
692 case 1: /* In text part of window. */ 704 case ON_TEXT:
693 /* X and Y are now window relative pixel coordinates. 705 /* X and Y are now window relative pixel coordinates. Convert
694 Convert them to canonical char units before returning 706 them to canonical char units before returning them. */
695 them. */
696 return Fcons (CANON_X_FROM_PIXEL_X (f, x), 707 return Fcons (CANON_X_FROM_PIXEL_X (f, x),
697 CANON_Y_FROM_PIXEL_Y (f, y)); 708 CANON_Y_FROM_PIXEL_Y (f, y));
698 709
699 case 2: /* In mode line of window. */ 710 case ON_MODE_LINE:
700 return Qmode_line; 711 return Qmode_line;
701 712
702 case 3: /* On right border of window. */ 713 case ON_VERTICAL_BORDER:
703 return Qvertical_line; 714 return Qvertical_line;
704 715
705 case 4: 716 case ON_HEADER_LINE:
706 return Qheader_line; 717 return Qheader_line;
707 718
708 case 5: 719 case ON_LEFT_FRINGE:
709 return Qleft_bitmap_area; 720 return Qleft_fringe;
710 721
711 case 6: 722 case ON_RIGHT_FRINGE:
712 return Qright_bitmap_area; 723 return Qright_fringe;
713 724
714 default: 725 default:
715 abort (); 726 abort ();
716 } 727 }
717 } 728 }
736 check_window_containing (w, user_data) 747 check_window_containing (w, user_data)
737 struct window *w; 748 struct window *w;
738 void *user_data; 749 void *user_data;
739 { 750 {
740 struct check_window_data *cw = (struct check_window_data *) user_data; 751 struct check_window_data *cw = (struct check_window_data *) user_data;
741 int found; 752 enum window_part found;
753 int continue_p = 1;
742 754
743 found = coordinates_in_window (w, cw->x, cw->y); 755 found = coordinates_in_window (w, cw->x, cw->y);
744 if (found) 756 if (found != ON_NOTHING)
745 { 757 {
746 *cw->part = found - 1; 758 *cw->part = found - 1;
747 XSETWINDOW (*cw->window, w); 759 XSETWINDOW (*cw->window, w);
760 continue_p = 0;
748 } 761 }
749 762
750 return !found; 763 return continue_p;
751 } 764 }
752 765
753 766
754 /* Find the window containing frame-relative pixel position X/Y and 767 /* Find the window containing frame-relative pixel position X/Y and
755 return it as a Lisp_Object. If X, Y is on the window's modeline, 768 return it as a Lisp_Object. If X, Y is on the window's modeline,
785 bar exists. */ 798 bar exists. */
786 if (NILP (window) 799 if (NILP (window)
787 && tool_bar_p 800 && tool_bar_p
788 && WINDOWP (f->tool_bar_window) 801 && WINDOWP (f->tool_bar_window)
789 && XINT (XWINDOW (f->tool_bar_window)->height) > 0 802 && XINT (XWINDOW (f->tool_bar_window)->height) > 0
790 && coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)) 803 && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)
804 != ON_NOTHING))
791 { 805 {
792 *part = 0; 806 *part = 0;
793 window = f->tool_bar_window; 807 window = f->tool_bar_window;
794 } 808 }
795 809
5629 } 5643 }
5630 5644
5631 void 5645 void
5632 syms_of_window () 5646 syms_of_window ()
5633 { 5647 {
5634 Qleft_bitmap_area = intern ("left-bitmap-area"); 5648 Qleft_fringe = intern ("left-fringe");
5635 staticpro (&Qleft_bitmap_area); 5649 staticpro (&Qleft_fringe);
5636 Qright_bitmap_area = intern ("right-bitmap-area"); 5650 Qright_fringe = intern ("right-fringe");
5637 staticpro (&Qright_bitmap_area); 5651 staticpro (&Qright_fringe);
5638 5652
5639 Qwindow_size_fixed = intern ("window-size-fixed"); 5653 Qwindow_size_fixed = intern ("window-size-fixed");
5640 staticpro (&Qwindow_size_fixed); 5654 staticpro (&Qwindow_size_fixed);
5641 5655
5642 staticpro (&Qwindow_configuration_change_hook); 5656 staticpro (&Qwindow_configuration_change_hook);