Mercurial > emacs
comparison src/window.c @ 34640:263ac9dec8b8
(coordinates_in_window): Fix computation for
position on vertical line between mode lines.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sun, 17 Dec 2000 15:11:35 +0000 |
parents | a8944d7e6773 |
children | c794dfe043b6 |
comparison
equal
deleted
inserted
replaced
34639:911e673ddc04 | 34640:263ac9dec8b8 |
---|---|
495 static int | 495 static int |
496 coordinates_in_window (w, x, y) | 496 coordinates_in_window (w, x, y) |
497 register struct window *w; | 497 register struct window *w; |
498 register int *x, *y; | 498 register int *x, *y; |
499 { | 499 { |
500 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
501 int left_x, right_x, top_y, bottom_y; | |
502 int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); | |
503 | |
504 /* Let's make this a global enum later, instead of using numbers | 500 /* Let's make this a global enum later, instead of using numbers |
505 everywhere. */ | 501 everywhere. */ |
506 enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER, | 502 enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER, |
507 ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE}; | 503 ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE}; |
508 | 504 |
505 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
506 int left_x, right_x, top_y, bottom_y; | |
507 int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); | |
508 int part; | |
509 int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f); | |
510 int x0 = XFASTINT (w->left) * ux; | |
511 int x1 = x0 + XFASTINT (w->width) * ux; | |
512 | |
513 if (*x < x0 || *x >= x1) | |
514 return ON_NOTHING; | |
515 | |
509 /* In what's below, we subtract 1 when computing right_x because we | 516 /* In what's below, we subtract 1 when computing right_x because we |
510 want the rightmost pixel, which is given by left_pixel+width-1. */ | 517 want the rightmost pixel, which is given by left_pixel+width-1. */ |
511 if (w->pseudo_window_p) | 518 if (w->pseudo_window_p) |
512 { | 519 { |
513 left_x = 0; | 520 left_x = 0; |
514 right_x = XFASTINT (w->width) * CANON_Y_UNIT (f) - 1; | 521 right_x = XFASTINT (w->width) * CANON_X_UNIT (f) - 1; |
515 top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w); | 522 top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w); |
516 bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); | 523 bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); |
517 } | 524 } |
518 else | 525 else |
519 { | 526 { |
528 /* On the mode line or header line? If it's near the start of | 535 /* On the mode line or header line? If it's near the start of |
529 the mode or header line of window that's has a horizontal | 536 the mode or header line of window that's has a horizontal |
530 sibling, say it's on the vertical line. That's to be able | 537 sibling, say it's on the vertical line. That's to be able |
531 to resize windows horizontally in case we're using toolkit | 538 to resize windows horizontally in case we're using toolkit |
532 scroll bars. */ | 539 scroll bars. */ |
533 | 540 |
534 if (WINDOW_WANTS_MODELINE_P (w) | 541 if (WINDOW_WANTS_MODELINE_P (w) |
535 && *y < bottom_y | 542 && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w) |
536 && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) | 543 && *y < bottom_y) |
537 { | 544 { |
538 if (!WINDOW_RIGHTMOST_P (w) | 545 /* We're somewhere on the mode line. We consider the place |
539 && (abs (*x - ((XFASTINT (w->left) + XFASTINT (w->width)) | 546 between mode lines of horizontally adjacent mode lines |
540 * CANON_X_UNIT (f))) | 547 as the vertical border. If scroll bars on the left, |
541 < CANON_X_UNIT (f) / 2)) | 548 return the right window. */ |
542 return ON_VERTICAL_BORDER; | 549 part = ON_MODE_LINE; |
543 return ON_MODE_LINE; | 550 |
544 } | 551 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) |
545 | 552 { |
546 if (WINDOW_WANTS_HEADER_LINE_P (w) | 553 if (abs (*x - x0) < ux / 2) |
547 && *y >= top_y | 554 part = ON_VERTICAL_BORDER; |
548 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) | 555 } |
549 { | 556 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2) |
550 if (!WINDOW_RIGHTMOST_P (w) | 557 part = ON_VERTICAL_BORDER; |
551 && (abs (*x - ((XFASTINT (w->left) + XFASTINT (w->width)) | 558 } |
552 * CANON_X_UNIT (f))) | 559 else if (WINDOW_WANTS_HEADER_LINE_P (w) |
553 < CANON_X_UNIT (f) / 2)) | 560 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w) |
554 return ON_VERTICAL_BORDER; | 561 && *y >= top_y) |
555 return ON_HEADER_LINE; | 562 { |
556 } | 563 part = ON_HEADER_LINE; |
557 | 564 |
558 /* Completely outside anything interesting? */ | 565 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) |
559 if (*y < top_y | 566 { |
560 || *y >= bottom_y | 567 if (abs (*x - x0) < ux / 2) |
561 || *x < (left_x | 568 part = ON_VERTICAL_BORDER; |
562 - flags_area_width | 569 } |
563 - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) | 570 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2) |
564 * CANON_X_UNIT (f))) | 571 part = ON_VERTICAL_BORDER; |
565 || *x > right_x + flags_area_width) | 572 } |
566 return ON_NOTHING; | 573 /* Outside anything interesting? */ |
567 | 574 else if (*y < top_y |
568 if (FRAME_WINDOW_P (f)) | 575 || *y >= bottom_y |
576 || *x < (left_x | |
577 - flags_area_width | |
578 - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux) | |
579 || *x > right_x + flags_area_width) | |
580 { | |
581 part = ON_NOTHING; | |
582 } | |
583 else if (FRAME_WINDOW_P (f)) | |
569 { | 584 { |
570 if (!w->pseudo_window_p | 585 if (!w->pseudo_window_p |
571 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f) | 586 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f) |
572 && !WINDOW_RIGHTMOST_P (w) | 587 && !WINDOW_RIGHTMOST_P (w) |
573 && (abs (*x - right_x - flags_area_width) < CANON_X_UNIT (f) / 2)) | 588 && (abs (*x - right_x - flags_area_width) < ux / 2)) |
574 return ON_VERTICAL_BORDER; | 589 { |
575 | 590 part = ON_VERTICAL_BORDER; |
576 if (*x < left_x || *x > right_x) | 591 } |
592 else if (*x < left_x || *x > right_x) | |
577 { | 593 { |
578 /* Other lines than the mode line don't include flags areas and | 594 /* Other lines than the mode line don't include flags areas and |
579 scroll bars on the left. */ | 595 scroll bars on the left. */ |
580 | 596 |
581 /* Convert X and Y to window-relative pixel coordinates. */ | 597 /* Convert X and Y to window-relative pixel coordinates. */ |
582 *x -= left_x; | 598 *x -= left_x; |
583 *y -= top_y; | 599 *y -= top_y; |
584 return *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; | 600 part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; |
601 } | |
602 else | |
603 { | |
604 *x -= left_x; | |
605 *y -= top_y; | |
606 part = ON_TEXT; | |
585 } | 607 } |
586 } | 608 } |
587 else | 609 else |
588 { | 610 { |
589 /* Need to say "*x > right_x" rather than >=, since on character | 611 /* Need to say "*x > right_x" rather than >=, since on character |
594 scroll bars on the left. */ | 616 scroll bars on the left. */ |
595 | 617 |
596 /* Convert X and Y to window-relative pixel coordinates. */ | 618 /* Convert X and Y to window-relative pixel coordinates. */ |
597 *x -= left_x; | 619 *x -= left_x; |
598 *y -= top_y; | 620 *y -= top_y; |
599 return *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; | 621 part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; |
600 } | 622 } |
601 | |
602 /* Here, too, "*x > right_x" is because of character terminals. */ | 623 /* Here, too, "*x > right_x" is because of character terminals. */ |
603 if (!w->pseudo_window_p | 624 else if (!w->pseudo_window_p |
604 && !WINDOW_RIGHTMOST_P (w) | 625 && !WINDOW_RIGHTMOST_P (w) |
605 && *x > right_x - CANON_X_UNIT (f)) | 626 && *x > right_x - ux) |
606 /* On the border on the right side of the window? Assume that | 627 { |
607 this area begins at RIGHT_X minus a canonical char width. */ | 628 /* On the border on the right side of the window? Assume that |
608 return ON_VERTICAL_BORDER; | 629 this area begins at RIGHT_X minus a canonical char width. */ |
609 } | 630 part = ON_VERTICAL_BORDER; |
610 | 631 } |
611 /* Convert X and Y to window-relative pixel coordinates. */ | 632 else |
612 *x -= left_x; | 633 { |
613 *y -= top_y; | 634 /* Convert X and Y to window-relative pixel coordinates. */ |
614 return ON_TEXT; | 635 *x -= left_x; |
615 } | 636 *y -= top_y; |
637 part = ON_TEXT; | |
638 } | |
639 } | |
640 | |
641 return part; | |
642 } | |
643 | |
616 | 644 |
617 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | 645 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, |
618 Scoordinates_in_window_p, 2, 2, 0, | 646 Scoordinates_in_window_p, 2, 2, 0, |
619 "Return non-nil if COORDINATES are in WINDOW.\n\ | 647 "Return non-nil if COORDINATES are in WINDOW.\n\ |
620 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ | 648 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ |