diff options
| author | Martin Rudalics | 2011-10-15 12:12:00 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2011-10-15 12:12:00 +0200 |
| commit | c7b08b0d14568494d515f125e2fbe2ebbe08fa65 (patch) | |
| tree | 421db161ccb6721e6f6cf994b8af48e4fb593715 /src | |
| parent | 3d1337be7b53c158b3b6c4959fa9a7ed8f6f4ed6 (diff) | |
| download | emacs-c7b08b0d14568494d515f125e2fbe2ebbe08fa65.tar.gz emacs-c7b08b0d14568494d515f125e2fbe2ebbe08fa65.zip | |
Rewrite and delabelize vertical border check. (Bug#5357) (Bug#9618)
* window.c (coordinates_in_window): Rewrite and delabelize
vertical border check. (Bug#5357) (Bug#9618)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/window.c | 81 |
2 files changed, 35 insertions, 51 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 79503c147e3..2c72e97b7f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-10-15 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (coordinates_in_window): Rewrite and delabelize | ||
| 4 | vertical border check. (Bug#5357) (Bug#9618) | ||
| 5 | |||
| 1 | 2011-10-14 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2011-10-14 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * xterm.c (frame_highlight, frame_unhighlight): Ignore unexplained | 8 | * xterm.c (frame_highlight, frame_unhighlight): Ignore unexplained |
diff --git a/src/window.c b/src/window.c index ba06779846a..c3b4384137d 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -919,22 +919,45 @@ static enum window_part | |||
| 919 | coordinates_in_window (register struct window *w, int x, int y) | 919 | coordinates_in_window (register struct window *w, int x, int y) |
| 920 | { | 920 | { |
| 921 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 921 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 922 | int left_x, right_x; | ||
| 923 | enum window_part part; | 922 | enum window_part part; |
| 924 | int ux = FRAME_COLUMN_WIDTH (f); | 923 | int ux = FRAME_COLUMN_WIDTH (f); |
| 925 | int x0 = WINDOW_LEFT_EDGE_X (w); | 924 | int left_x = WINDOW_LEFT_EDGE_X (w); |
| 926 | int x1 = WINDOW_RIGHT_EDGE_X (w); | 925 | int right_x = WINDOW_RIGHT_EDGE_X (w); |
| 926 | int top_y = WINDOW_TOP_EDGE_Y (w); | ||
| 927 | int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); | ||
| 927 | /* The width of the area where the vertical line can be dragged. | 928 | /* The width of the area where the vertical line can be dragged. |
| 928 | (Between mode lines for instance. */ | 929 | (Between mode lines for instance. */ |
| 929 | int grabbable_width = ux; | 930 | int grabbable_width = ux; |
| 930 | int lmargin_width, rmargin_width, text_left, text_right; | 931 | int lmargin_width, rmargin_width, text_left, text_right; |
| 931 | int top_y = WINDOW_TOP_EDGE_Y (w); | ||
| 932 | int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); | ||
| 933 | 932 | ||
| 934 | /* Outside any interesting row? */ | 933 | /* Outside any interesting row or column? */ |
| 935 | if (y < top_y || y >= bottom_y) | 934 | if (y < top_y || y >= bottom_y || x < left_x || x >= right_x) |
| 936 | return ON_NOTHING; | 935 | return ON_NOTHING; |
| 937 | 936 | ||
| 937 | /* On the mode line or header line? */ | ||
| 938 | if ((WINDOW_WANTS_MODELINE_P (w) | ||
| 939 | && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w) | ||
| 940 | && (part = ON_MODE_LINE)) | ||
| 941 | || (WINDOW_WANTS_HEADER_LINE_P (w) | ||
| 942 | && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w) | ||
| 943 | && (part = ON_HEADER_LINE))) | ||
| 944 | { | ||
| 945 | /* If it's under/over the scroll bar portion of the mode/header | ||
| 946 | line, say it's on the vertical line. That's to be able to | ||
| 947 | resize windows horizontally in case we're using toolkit scroll | ||
| 948 | bars. Note: If scrollbars are on the left, the window that | ||
| 949 | must be eventually resized is that on the left of WINDOW. */ | ||
| 950 | if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) | ||
| 951 | && !WINDOW_LEFTMOST_P (w) | ||
| 952 | && eabs (x - left_x) < grabbable_width) | ||
| 953 | || (!WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) | ||
| 954 | && !WINDOW_RIGHTMOST_P (w) | ||
| 955 | && eabs (x - right_x) < grabbable_width)) | ||
| 956 | return ON_VERTICAL_BORDER; | ||
| 957 | else | ||
| 958 | return part; | ||
| 959 | } | ||
| 960 | |||
| 938 | /* In what's below, we subtract 1 when computing right_x because we | 961 | /* In what's below, we subtract 1 when computing right_x because we |
| 939 | want the rightmost pixel, which is given by left_pixel+width-1. */ | 962 | want the rightmost pixel, which is given by left_pixel+width-1. */ |
| 940 | if (w->pseudo_window_p) | 963 | if (w->pseudo_window_p) |
| @@ -948,50 +971,6 @@ coordinates_in_window (register struct window *w, int x, int y) | |||
| 948 | right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; | 971 | right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; |
| 949 | } | 972 | } |
| 950 | 973 | ||
| 951 | /* On the mode line or header line? If it's near the start of | ||
| 952 | the mode or header line of window that's has a horizontal | ||
| 953 | sibling, say it's on the vertical line. That's to be able | ||
| 954 | to resize windows horizontally in case we're using toolkit | ||
| 955 | scroll bars. */ | ||
| 956 | |||
| 957 | if (WINDOW_WANTS_MODELINE_P (w) | ||
| 958 | && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) | ||
| 959 | { | ||
| 960 | part = ON_MODE_LINE; | ||
| 961 | |||
| 962 | header_vertical_border_check: | ||
| 963 | /* We're somewhere on the mode line. We consider the place | ||
| 964 | between mode lines of horizontally adjacent mode lines | ||
| 965 | as the vertical border. If scroll bars on the left, | ||
| 966 | return the right window. */ | ||
| 967 | if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) | ||
| 968 | || WINDOW_RIGHTMOST_P (w)) | ||
| 969 | && !WINDOW_LEFTMOST_P (w) | ||
| 970 | && eabs (x - x0) < grabbable_width) | ||
| 971 | return ON_VERTICAL_BORDER; | ||
| 972 | |||
| 973 | /* Make sure we're not at the rightmost position of a | ||
| 974 | mode-/header-line and there's yet another window on the | ||
| 975 | right. (Bug#1372) */ | ||
| 976 | else if ((WINDOW_RIGHTMOST_P (w) || x < x1) | ||
| 977 | && eabs (x - x1) < grabbable_width) | ||
| 978 | return ON_VERTICAL_BORDER; | ||
| 979 | |||
| 980 | if (x < x0 || x >= x1) | ||
| 981 | return ON_NOTHING; | ||
| 982 | |||
| 983 | return part; | ||
| 984 | } | ||
| 985 | |||
| 986 | if (WINDOW_WANTS_HEADER_LINE_P (w) | ||
| 987 | && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) | ||
| 988 | { | ||
| 989 | part = ON_HEADER_LINE; | ||
| 990 | goto header_vertical_border_check; | ||
| 991 | } | ||
| 992 | |||
| 993 | if (x < x0 || x >= x1) return ON_NOTHING; | ||
| 994 | |||
| 995 | /* Outside any interesting column? */ | 974 | /* Outside any interesting column? */ |
| 996 | if (x < left_x || x > right_x) | 975 | if (x < left_x || x > right_x) |
| 997 | return ON_SCROLL_BAR; | 976 | return ON_SCROLL_BAR; |