Mercurial > emacs
comparison src/window.c @ 71396:58383949ec48
(size_window): New arg FIRST_ONLY. All callers changed.
(adjust_window_trailing_edge): Specially compute FIRST_PARALLEL
for the case of a top-level window and the following minibuffer.
Don't exit because of no `next' when there is a parent.
Use the FIRST_ONLY feature when resizing following windows.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 Jun 2006 21:59:30 +0000 |
parents | 0c8a94363573 |
children | dfc0eccac6a1 a387c138b28e 4094c5298ae1 |
comparison
equal
deleted
inserted
replaced
71395:923b7f99b0d7 | 71396:58383949ec48 |
---|---|
61 static void window_scroll P_ ((Lisp_Object, int, int, int)); | 61 static void window_scroll P_ ((Lisp_Object, int, int, int)); |
62 static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); | 62 static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); |
63 static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); | 63 static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); |
64 static int window_min_size_1 P_ ((struct window *, int)); | 64 static int window_min_size_1 P_ ((struct window *, int)); |
65 static int window_min_size P_ ((struct window *, int, int, int *)); | 65 static int window_min_size P_ ((struct window *, int, int, int *)); |
66 static void size_window P_ ((Lisp_Object, int, int, int)); | 66 static void size_window P_ ((Lisp_Object, int, int, int, int, int)); |
67 static int freeze_window_start P_ ((struct window *, void *)); | 67 static int freeze_window_start P_ ((struct window *, void *)); |
68 static int window_fixed_size_p P_ ((struct window *, int, int)); | 68 static int window_fixed_size_p P_ ((struct window *, int, int)); |
69 static void enlarge_window P_ ((Lisp_Object, int, int)); | 69 static void enlarge_window P_ ((Lisp_Object, int, int)); |
70 static Lisp_Object window_list P_ ((void)); | 70 static Lisp_Object window_list P_ ((void)); |
71 static int add_window_to_list P_ ((struct window *, void *)); | 71 static int add_window_to_list P_ ((struct window *, void *)); |
2824 return new_sizes; | 2824 return new_sizes; |
2825 } | 2825 } |
2826 | 2826 |
2827 /* Set WINDOW's height or width to SIZE. WIDTH_P non-zero means set | 2827 /* Set WINDOW's height or width to SIZE. WIDTH_P non-zero means set |
2828 WINDOW's width. Resize WINDOW's children, if any, so that they | 2828 WINDOW's width. Resize WINDOW's children, if any, so that they |
2829 keep their proportionate size relative to WINDOW. Propagate | 2829 keep their proportionate size relative to WINDOW. |
2830 WINDOW's top or left edge position to children. Delete windows | 2830 |
2831 that become too small unless NODELETE_P is non-zero. | 2831 If FIRST_ONLY is 1, change only the first of WINDOW's children when |
2832 they are in series. If LAST_ONLY is 1, change only the last of | |
2833 WINDOW's children when they are in series. | |
2834 | |
2835 Propagate WINDOW's top or left edge position to children. Delete | |
2836 windows that become too small unless NODELETE_P is non-zero. | |
2832 | 2837 |
2833 If NODELETE_P is 2, that means we do delete windows that are | 2838 If NODELETE_P is 2, that means we do delete windows that are |
2834 too small, even if they were too small before! */ | 2839 too small, even if they were too small before! */ |
2835 | 2840 |
2836 static void | 2841 static void |
2837 size_window (window, size, width_p, nodelete_p) | 2842 size_window (window, size, width_p, nodelete_p, first_only, last_only) |
2838 Lisp_Object window; | 2843 Lisp_Object window; |
2839 int size, width_p, nodelete_p; | 2844 int size, width_p, nodelete_p; |
2845 int first_only, last_only; | |
2840 { | 2846 { |
2841 struct window *w = XWINDOW (window); | 2847 struct window *w = XWINDOW (window); |
2842 struct window *c; | 2848 struct window *c; |
2843 Lisp_Object child, *forward, *sideward; | 2849 Lisp_Object child, *forward, *sideward; |
2844 int old_size, min_size, safe_min_size; | 2850 int old_size, min_size, safe_min_size; |
2909 w->orig_total_lines = Qnil; | 2915 w->orig_total_lines = Qnil; |
2910 } | 2916 } |
2911 | 2917 |
2912 if (!NILP (*sideward)) | 2918 if (!NILP (*sideward)) |
2913 { | 2919 { |
2920 /* We have a chain of parallel siblings whose size should all change. */ | |
2914 for (child = *sideward; !NILP (child); child = c->next) | 2921 for (child = *sideward; !NILP (child); child = c->next) |
2915 { | 2922 { |
2916 c = XWINDOW (child); | 2923 c = XWINDOW (child); |
2917 if (width_p) | 2924 if (width_p) |
2918 c->left_col = w->left_col; | 2925 c->left_col = w->left_col; |
2919 else | 2926 else |
2920 c->top_line = w->top_line; | 2927 c->top_line = w->top_line; |
2921 size_window (child, size, width_p, nodelete_p); | 2928 size_window (child, size, width_p, nodelete_p, |
2922 } | 2929 first_only, last_only); |
2930 } | |
2931 } | |
2932 else if (!NILP (*forward) && last_only) | |
2933 { | |
2934 /* Change the last in a series of siblings. */ | |
2935 Lisp_Object last_child; | |
2936 int child_size; | |
2937 | |
2938 for (child = *forward; !NILP (child); child = c->next) | |
2939 { | |
2940 c = XWINDOW (child); | |
2941 last_child = child; | |
2942 } | |
2943 | |
2944 child_size = XINT (width_p ? c->total_cols : c->total_lines); | |
2945 size_window (last_child, | |
2946 size - old_size + child_size, | |
2947 width_p, nodelete_p, first_only, last_only); | |
2948 } | |
2949 else if (!NILP (*forward) && first_only) | |
2950 { | |
2951 /* Change the first in a series of siblings. */ | |
2952 int child_size; | |
2953 | |
2954 child = *forward; | |
2955 c = XWINDOW (child); | |
2956 | |
2957 if (width_p) | |
2958 c->left_col = w->left_col; | |
2959 else | |
2960 c->top_line = w->top_line; | |
2961 | |
2962 child_size = XINT (width_p ? c->total_cols : c->total_lines); | |
2963 size_window (child, | |
2964 size - old_size + child_size, | |
2965 width_p, nodelete_p, first_only, last_only); | |
2923 } | 2966 } |
2924 else if (!NILP (*forward)) | 2967 else if (!NILP (*forward)) |
2925 { | 2968 { |
2926 int fixed_size, each, extra, n; | 2969 int fixed_size, each, extra, n; |
2927 int resize_fixed_p, nfixed; | 2970 int resize_fixed_p, nfixed; |
2928 int last_pos, first_pos, nchildren, total; | 2971 int last_pos, first_pos, nchildren, total; |
2929 int *new_sizes = NULL; | 2972 int *new_sizes = NULL; |
2930 | 2973 |
2931 /* Determine the fixed-size portion of the this window, and the | 2974 /* Determine the fixed-size portion of this window, and the |
2932 number of child windows. */ | 2975 number of child windows. */ |
2933 fixed_size = nchildren = nfixed = total = 0; | 2976 fixed_size = nchildren = nfixed = total = 0; |
2934 for (child = *forward; !NILP (child); child = c->next, ++nchildren) | 2977 for (child = *forward; !NILP (child); child = c->next, ++nchildren) |
2935 { | 2978 { |
2936 int child_size; | 2979 int child_size; |
2989 } | 3032 } |
2990 | 3033 |
2991 /* Set new height. Note that size_window also propagates | 3034 /* Set new height. Note that size_window also propagates |
2992 edge positions to children, so it's not a no-op if we | 3035 edge positions to children, so it's not a no-op if we |
2993 didn't change the child's size. */ | 3036 didn't change the child's size. */ |
2994 size_window (child, new_size, width_p, 1); | 3037 size_window (child, new_size, width_p, 1, first_only, last_only); |
2995 | 3038 |
2996 /* Remember the bottom/right edge position of this child; it | 3039 /* Remember the bottom/right edge position of this child; it |
2997 will be used to set the top/left edge of the next child. */ | 3040 will be used to set the top/left edge of the next child. */ |
2998 last_pos += new_size; | 3041 last_pos += new_size; |
2999 } | 3042 } |
3008 for (child = *forward; !NILP (child); child = c->next) | 3051 for (child = *forward; !NILP (child); child = c->next) |
3009 { | 3052 { |
3010 int child_size; | 3053 int child_size; |
3011 c = XWINDOW (child); | 3054 c = XWINDOW (child); |
3012 child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines); | 3055 child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines); |
3013 size_window (child, child_size, width_p, 2); | 3056 size_window (child, child_size, width_p, 2, first_only, last_only); |
3014 } | 3057 } |
3015 } | 3058 } |
3016 } | 3059 } |
3017 | 3060 |
3018 /* Set WINDOW's height to HEIGHT, and recursively change the height of | 3061 /* Set WINDOW's height to HEIGHT, and recursively change the height of |
3024 set_window_height (window, height, nodelete) | 3067 set_window_height (window, height, nodelete) |
3025 Lisp_Object window; | 3068 Lisp_Object window; |
3026 int height; | 3069 int height; |
3027 int nodelete; | 3070 int nodelete; |
3028 { | 3071 { |
3029 size_window (window, height, 0, nodelete); | 3072 size_window (window, height, 0, nodelete, 0, 0); |
3030 } | 3073 } |
3031 | 3074 |
3032 | 3075 |
3033 /* Set WINDOW's width to WIDTH, and recursively change the width of | 3076 /* Set WINDOW's width to WIDTH, and recursively change the width of |
3034 WINDOW's children. NODELETE non-zero means don't delete windows | 3077 WINDOW's children. NODELETE non-zero means don't delete windows |
3039 set_window_width (window, width, nodelete) | 3082 set_window_width (window, width, nodelete) |
3040 Lisp_Object window; | 3083 Lisp_Object window; |
3041 int width; | 3084 int width; |
3042 int nodelete; | 3085 int nodelete; |
3043 { | 3086 { |
3044 size_window (window, width, 1, nodelete); | 3087 size_window (window, width, 1, nodelete, 0, 0); |
3045 } | 3088 } |
3046 | 3089 |
3047 /* Change window heights in windows rooted in WINDOW by N lines. */ | 3090 /* Change window heights in windows rooted in WINDOW by N lines. */ |
3048 | 3091 |
3049 void | 3092 void |
4279 { | 4322 { |
4280 Lisp_Object first_parallel = Qnil; | 4323 Lisp_Object first_parallel = Qnil; |
4281 | 4324 |
4282 if (NILP (window)) | 4325 if (NILP (window)) |
4283 { | 4326 { |
4284 /* This can happen if WINDOW on the previous iteration was | 4327 /* This happens if WINDOW on the previous iteration was |
4285 at top level of the tree and we did not exit. */ | 4328 at top level of the window tree. */ |
4286 Fset_window_configuration (old_config); | 4329 Fset_window_configuration (old_config); |
4287 error ("Specified window edge is fixed"); | 4330 error ("Specified window edge is fixed"); |
4288 } | 4331 } |
4289 | 4332 |
4290 p = XWINDOW (window); | 4333 p = XWINDOW (window); |
4294 direction. If so, set FIRST_PARALLEL to the first one. */ | 4337 direction. If so, set FIRST_PARALLEL to the first one. */ |
4295 if (horiz_flag) | 4338 if (horiz_flag) |
4296 { | 4339 { |
4297 if (! NILP (parent) && !NILP (XWINDOW (parent)->vchild)) | 4340 if (! NILP (parent) && !NILP (XWINDOW (parent)->vchild)) |
4298 first_parallel = XWINDOW (parent)->vchild; | 4341 first_parallel = XWINDOW (parent)->vchild; |
4342 else if (NILP (parent) && !NILP (p->next)) | |
4343 { | |
4344 /* Handle the vertical chain of main window and minibuffer | |
4345 which has no parent. */ | |
4346 first_parallel = window; | |
4347 while (! NILP (XWINDOW (first_parallel)->prev)) | |
4348 first_parallel = XWINDOW (first_parallel)->prev; | |
4349 } | |
4299 } | 4350 } |
4300 else | 4351 else |
4301 { | 4352 { |
4302 if (! NILP (parent) && !NILP (XWINDOW (parent)->hchild)) | 4353 if (! NILP (parent) && !NILP (XWINDOW (parent)->hchild)) |
4303 first_parallel = XWINDOW (parent)->hchild; | 4354 first_parallel = XWINDOW (parent)->hchild; |
4304 } | 4355 } |
4305 | 4356 |
4306 /* If this level's succession is in the desired dimension, | 4357 /* If this level's succession is in the desired dimension, |
4307 and this window is the last one, its trailing edge is fixed. */ | 4358 and this window is the last one, and there is no higher level, |
4308 if (NILP (XWINDOW (window)->next) && NILP (first_parallel)) | 4359 its trailing edge is fixed. */ |
4360 if (NILP (XWINDOW (window)->next) && NILP (first_parallel) | |
4361 && NILP (parent)) | |
4309 { | 4362 { |
4310 Fset_window_configuration (old_config); | 4363 Fset_window_configuration (old_config); |
4311 error ("Specified window edge is fixed"); | 4364 error ("Specified window edge is fixed"); |
4312 } | 4365 } |
4313 | 4366 |
4345 } | 4398 } |
4346 | 4399 |
4347 XSETINT (CURBEG (p->next), | 4400 XSETINT (CURBEG (p->next), |
4348 XINT (CURBEG (p->next)) + delta); | 4401 XINT (CURBEG (p->next)) + delta); |
4349 size_window (p->next, XINT (CURSIZE (p->next)) - delta, | 4402 size_window (p->next, XINT (CURSIZE (p->next)) - delta, |
4350 horiz_flag, 0); | 4403 horiz_flag, 0, 1, 0); |
4351 break; | 4404 break; |
4352 } | 4405 } |
4353 } | 4406 } |
4354 else | 4407 else |
4355 /* Here we have a chain of parallel siblings, in the other dimension. | 4408 /* Here we have a chain of parallel siblings, in the other dimension. |
4357 for (child = first_parallel; | 4410 for (child = first_parallel; |
4358 ! NILP (child); | 4411 ! NILP (child); |
4359 child = XWINDOW (child)->next) | 4412 child = XWINDOW (child)->next) |
4360 if (! EQ (child, window)) | 4413 if (! EQ (child, window)) |
4361 size_window (child, XINT (CURSIZE (child)) + delta, | 4414 size_window (child, XINT (CURSIZE (child)) + delta, |
4362 horiz_flag, 0); | 4415 horiz_flag, 0, 0, 1); |
4363 | 4416 |
4364 window = parent; | 4417 window = parent; |
4365 } | 4418 } |
4366 | 4419 |
4367 /* If we made a window so small it got deleted, | 4420 /* If we made a window so small it got deleted, |