aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-12-17 15:11:56 +0000
committerGerd Moellmann2000-12-17 15:11:56 +0000
commitb0228ace9ea0bb5d752df7aa128566171d0d4793 (patch)
tree3dd2494bf695009346c8c2c53418355cb1a20e21 /src
parentc844a81af87170828e3b49c83b3518dcd5807364 (diff)
downloademacs-b0228ace9ea0bb5d752df7aa128566171d0d4793.tar.gz
emacs-b0228ace9ea0bb5d752df7aa128566171d0d4793.zip
(coordinates_in_window): Fix computation for
position on vertical line between mode lines.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog3
-rw-r--r--src/window.c136
2 files changed, 85 insertions, 54 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2bf00546592..ccae9e2a070 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,8 @@
12000-12-17 Gerd Moellmann <gerd@gnu.org> 12000-12-17 Gerd Moellmann <gerd@gnu.org>
2 2
3 * window.c (coordinates_in_window): Fix computation for
4 position on vertical line between mode lines.
5
3 * xfns.c (unwind_create_frame): Return t if frame was deleted. 6 * xfns.c (unwind_create_frame): Return t if frame was deleted.
4 Don't alter tip_frame or tip_window. 7 Don't alter tip_frame or tip_window.
5 (unwind_create_tip_frame): Set tip_frame to nil only if frame 8 (unwind_create_tip_frame): Set tip_frame to nil only if frame
diff --git a/src/window.c b/src/window.c
index b407fac9bbe..0e8c807cb32 100644
--- a/src/window.c
+++ b/src/window.c
@@ -497,21 +497,28 @@ 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 }
@@ -530,50 +537,59 @@ coordinates_in_window (w, x, y)
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
551 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
552 {
553 if (abs (*x - x0) < ux / 2)
554 part = ON_VERTICAL_BORDER;
555 }
556 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2)
557 part = ON_VERTICAL_BORDER;
544 } 558 }
545 559 else if (WINDOW_WANTS_HEADER_LINE_P (w)
546 if (WINDOW_WANTS_HEADER_LINE_P (w) 560 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)
547 && *y >= top_y 561 && *y >= top_y)
548 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
549 { 562 {
550 if (!WINDOW_RIGHTMOST_P (w) 563 part = ON_HEADER_LINE;
551 && (abs (*x - ((XFASTINT (w->left) + XFASTINT (w->width)) 564
552 * CANON_X_UNIT (f))) 565 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
553 < CANON_X_UNIT (f) / 2)) 566 {
554 return ON_VERTICAL_BORDER; 567 if (abs (*x - x0) < ux / 2)
555 return ON_HEADER_LINE; 568 part = ON_VERTICAL_BORDER;
569 }
570 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2)
571 part = ON_VERTICAL_BORDER;
556 } 572 }
557 573 /* Outside anything interesting? */
558 /* Completely outside anything interesting? */ 574 else if (*y < top_y
559 if (*y < top_y 575 || *y >= bottom_y
560 || *y >= bottom_y 576 || *x < (left_x
561 || *x < (left_x 577 - flags_area_width
562 - flags_area_width 578 - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux)
563 - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) 579 || *x > right_x + flags_area_width)
564 * CANON_X_UNIT (f))) 580 {
565 || *x > right_x + flags_area_width) 581 part = ON_NOTHING;
566 return ON_NOTHING; 582 }
567 583 else if (FRAME_WINDOW_P (f))
568 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. */
@@ -581,7 +597,13 @@ coordinates_in_window (w, x, y)
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
@@ -596,24 +618,30 @@ coordinates_in_window (w, x, y)
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. */
630 part = ON_VERTICAL_BORDER;
631 }
632 else
633 {
634 /* Convert X and Y to window-relative pixel coordinates. */
635 *x -= left_x;
636 *y -= top_y;
637 part = ON_TEXT;
638 }
609 } 639 }
610 640
611 /* Convert X and Y to window-relative pixel coordinates. */ 641 return part;
612 *x -= left_x;
613 *y -= top_y;
614 return ON_TEXT;
615} 642}
616 643
644
617DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 645DEFUN ("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\