diff options
| author | Gerd Moellmann | 2000-11-28 13:45:21 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-11-28 13:45:21 +0000 |
| commit | 1cb794ba1fa15fe8b315aaf46fbc5c41ca69bddc (patch) | |
| tree | 635f63dfc82c30a3ba59d69ce417e38ae9cc606a /src/window.c | |
| parent | fa6d1ca87008ac2c054ad636102c3a395f43f6e7 (diff) | |
| download | emacs-1cb794ba1fa15fe8b315aaf46fbc5c41ca69bddc.tar.gz emacs-1cb794ba1fa15fe8b315aaf46fbc5c41ca69bddc.zip | |
(coordinates_in_window): If on a mode or header line,
but sufficiently close to its start, return ``on vertical
border''. This gives us a way to drag windows horizontally when
using toolkit scroll bars.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/src/window.c b/src/window.c index d3386c31a2a..0362a7ab46a 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -495,6 +495,11 @@ coordinates_in_window (w, x, y) | |||
| 495 | int left_x, right_x, top_y, bottom_y; | 495 | int left_x, right_x, top_y, bottom_y; |
| 496 | int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); | 496 | int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); |
| 497 | 497 | ||
| 498 | /* Let's make this a global enum later, instead of using numbers | ||
| 499 | everywhere. */ | ||
| 500 | enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER, | ||
| 501 | ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE}; | ||
| 502 | |||
| 498 | /* In what's below, we subtract 1 when computing right_x because we | 503 | /* In what's below, we subtract 1 when computing right_x because we |
| 499 | want the rightmost pixel, which is given by left_pixel+width-1. */ | 504 | want the rightmost pixel, which is given by left_pixel+width-1. */ |
| 500 | if (w->pseudo_window_p) | 505 | if (w->pseudo_window_p) |
| @@ -514,6 +519,7 @@ coordinates_in_window (w, x, y) | |||
| 514 | bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); | 519 | bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); |
| 515 | } | 520 | } |
| 516 | 521 | ||
| 522 | /* Completely outside anything interesting? */ | ||
| 517 | if (*y < top_y | 523 | if (*y < top_y |
| 518 | || *y >= bottom_y | 524 | || *y >= bottom_y |
| 519 | || *x < (left_x | 525 | || *x < (left_x |
| @@ -521,19 +527,37 @@ coordinates_in_window (w, x, y) | |||
| 521 | - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) | 527 | - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) |
| 522 | * CANON_X_UNIT (f))) | 528 | * CANON_X_UNIT (f))) |
| 523 | || *x > right_x + flags_area_width) | 529 | || *x > right_x + flags_area_width) |
| 524 | /* Completely outside anything interesting. */ | 530 | return ON_NOTHING; |
| 525 | return 0; | 531 | |
| 526 | else if (WINDOW_WANTS_MODELINE_P (w) | 532 | /* On the mode line or header line? If it's near the start of |
| 527 | && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) | 533 | the mode or header line of window that's has a horizontal |
| 528 | /* On the mode line. */ | 534 | sibling, say it's on the vertical line. That's to be able |
| 529 | return 2; | 535 | to resize windows horizontally in case we're using toolkit |
| 530 | else if (WINDOW_WANTS_HEADER_LINE_P (w) | 536 | scroll bars. */ |
| 531 | && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) | 537 | |
| 532 | /* On the top line. */ | 538 | if (WINDOW_WANTS_MODELINE_P (w) |
| 533 | return 4; | 539 | && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) |
| 540 | { | ||
| 541 | if (XFASTINT (w->left) > 0 | ||
| 542 | && (abs (*x - XFASTINT (w->left) * CANON_X_UNIT (f)) | ||
| 543 | < CANON_X_UNIT (f) / 2)) | ||
| 544 | return ON_VERTICAL_BORDER; | ||
| 545 | return ON_MODE_LINE; | ||
| 546 | } | ||
| 547 | |||
| 548 | if (WINDOW_WANTS_HEADER_LINE_P (w) | ||
| 549 | && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) | ||
| 550 | { | ||
| 551 | if (XFASTINT (w->left) > 0 | ||
| 552 | && (abs (*x - XFASTINT (w->left) * CANON_X_UNIT (f)) | ||
| 553 | < CANON_X_UNIT (f) / 2)) | ||
| 554 | return ON_VERTICAL_BORDER; | ||
| 555 | return ON_HEADER_LINE; | ||
| 556 | } | ||
| 557 | |||
| 534 | /* Need to say "*x > right_x" rather than >=, since on character | 558 | /* Need to say "*x > right_x" rather than >=, since on character |
| 535 | terminals, the vertical line's x coordinate is right_x. */ | 559 | terminals, the vertical line's x coordinate is right_x. */ |
| 536 | else if (*x < left_x || *x > right_x) | 560 | if (*x < left_x || *x > right_x) |
| 537 | { | 561 | { |
| 538 | /* Other lines than the mode line don't include flags areas and | 562 | /* Other lines than the mode line don't include flags areas and |
| 539 | scroll bars on the left. */ | 563 | scroll bars on the left. */ |
| @@ -541,22 +565,21 @@ coordinates_in_window (w, x, y) | |||
| 541 | /* Convert X and Y to window-relative pixel coordinates. */ | 565 | /* Convert X and Y to window-relative pixel coordinates. */ |
| 542 | *x -= left_x; | 566 | *x -= left_x; |
| 543 | *y -= top_y; | 567 | *y -= top_y; |
| 544 | return *x < left_x ? 5 : 6; | 568 | return *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; |
| 545 | } | 569 | } |
| 570 | |||
| 546 | /* Here, too, "*x > right_x" is because of character terminals. */ | 571 | /* Here, too, "*x > right_x" is because of character terminals. */ |
| 547 | else if (!w->pseudo_window_p | 572 | if (!w->pseudo_window_p |
| 548 | && !WINDOW_RIGHTMOST_P (w) | 573 | && !WINDOW_RIGHTMOST_P (w) |
| 549 | && *x > right_x - CANON_X_UNIT (f)) | 574 | && *x > right_x - CANON_X_UNIT (f)) |
| 550 | /* On the border on the right side of the window? Assume that | 575 | /* On the border on the right side of the window? Assume that |
| 551 | this area begins at RIGHT_X minus a canonical char width. */ | 576 | this area begins at RIGHT_X minus a canonical char width. */ |
| 552 | return 3; | 577 | return ON_VERTICAL_BORDER; |
| 553 | else | 578 | |
| 554 | { | 579 | /* Convert X and Y to window-relative pixel coordinates. */ |
| 555 | /* Convert X and Y to window-relative pixel coordinates. */ | 580 | *x -= left_x; |
| 556 | *x -= left_x; | 581 | *y -= top_y; |
| 557 | *y -= top_y; | 582 | return ON_TEXT; |
| 558 | return 1; | ||
| 559 | } | ||
| 560 | } | 583 | } |
| 561 | 584 | ||
| 562 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | 585 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, |