aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorGerd Moellmann2001-01-31 20:28:13 +0000
committerGerd Moellmann2001-01-31 20:28:13 +0000
commit7442878f82e55dfbc8372e025ab63a59bd2ae03f (patch)
treefdc0efafc1da2721564d59d0d3c6b7680d153c49 /src/window.c
parent1f9228342c27083f11e547151acef612cf967763 (diff)
downloademacs-7442878f82e55dfbc8372e025ab63a59bd2ae03f.tar.gz
emacs-7442878f82e55dfbc8372e025ab63a59bd2ae03f.zip
(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.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/src/window.c b/src/window.c
index 6f1fd59145a..848cc6512ec 100644
--- a/src/window.c
+++ b/src/window.c
@@ -51,9 +51,22 @@ Boston, MA 02111-1307, USA. */
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
56enum 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
55Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; 68Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
56Lisp_Object Qwindow_size_fixed, Qleft_bitmap_area, Qright_bitmap_area; 69Lisp_Object Qwindow_size_fixed, Qleft_fringe, Qright_fringe;
57extern Lisp_Object Qheight, Qwidth; 70extern Lisp_Object Qheight, Qwidth;
58 71
59static struct window *decode_window P_ ((Lisp_Object)); 72static struct window *decode_window P_ ((Lisp_Object));
@@ -499,20 +512,17 @@ and BOTTOM is one more than the bottommost row used by WINDOW\n\
499 512
500 X and Y are frame relative pixel coordinates. */ 513 X and Y are frame relative pixel coordinates. */
501 514
502static int 515static enum window_part
503coordinates_in_window (w, x, y) 516coordinates_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;
@@ -583,7 +593,9 @@ coordinates_in_window (w, x, 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 }
@@ -654,15 +666,15 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
654 "Return non-nil if COORDINATES are in WINDOW.\n\ 666 "Return non-nil if COORDINATES are in WINDOW.\n\
655COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ 667COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
656measured in characters from the upper-left corner of the frame.\n\ 668measured 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\
658frame.\n\ 670frame.\n\
659If COORDINATES are in the text portion of WINDOW,\n\ 671If 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\
661If they are in the mode line of WINDOW, `mode-line' is returned.\n\ 673If they are in the mode line of WINDOW, `mode-line' is returned.\n\
662If they are in the top mode line of WINDOW, `header-line' is returned.\n\ 674If they are in the top mode line of WINDOW, `header-line' is returned.\n\
663If they are in the bitmap-area to the left of the window,\n\ 675If 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\
666If they are on the border between WINDOW and its right sibling,\n\ 678If 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)
@@ -686,30 +698,29 @@ If they are on the border between WINDOW and its right sibling,\n\
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 ();
@@ -738,16 +749,18 @@ check_window_containing (w, user_data)
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
@@ -787,7 +800,8 @@ window_from_coordinates (f, x, y, part, tool_bar_p)
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;
@@ -5631,10 +5645,10 @@ init_window ()
5631void 5645void
5632syms_of_window () 5646syms_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);