X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fwindow.c;h=85a196b6fd9bae19b7341e47702f07f7777b5a52;hb=f8b0dcc32dce11bef09e2fbcde040aecd1f86fd1;hp=2f3a6b80103440f24eee2c0ae75c2c6e8e21647a;hpb=cb9f6f4eadc44f1becb32cbbd1db26449e347755;p=chise%2Fxemacs-chise.git- diff --git a/src/window.c b/src/window.c index 2f3a6b8..85a196b 100644 --- a/src/window.c +++ b/src/window.c @@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA. */ #include "window.h" #include "elhash.h" #include "commands.h" +#include "gutter.h" Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configurationp; Lisp_Object Qscroll_up, Qscroll_down, Qdisplay_buffer; @@ -231,7 +232,7 @@ finalize_window (void *header, int for_disksave) DEFINE_LRECORD_IMPLEMENTATION ("window", window, mark_window, print_window, finalize_window, - 0, 0, struct window); + 0, 0, 0, struct window); #define INIT_DISP_VARIABLE(field, initialization) \ @@ -252,7 +253,7 @@ Lisp_Object allocate_window (void) { Lisp_Object val; - struct window *p = alloc_lcrecord_type (struct window, lrecord_window); + struct window *p = alloc_lcrecord_type (struct window, &lrecord_window); zero_lcrecord (p); XSETWINDOW (val, p); @@ -641,7 +642,7 @@ window_full_width_p (struct window *w) return window_is_leftmost (w) && window_is_rightmost (w); } -static int +int window_is_highest (struct window *w) { Lisp_Object parent, current_ancestor, window; @@ -669,7 +670,7 @@ window_is_highest (struct window *w) return 0; } -static int +int window_is_lowest (struct window *w) { Lisp_Object parent, current_ancestor, window; @@ -972,32 +973,6 @@ window_right_margin_width (struct window *w) return margin_width_internal (w, 0); } -static int -window_top_toolbar_height (struct window *w) -{ - /* #### implement this shit. */ - return 0; -} - -/* #### Currently used in scrollbar.c. Does it actually need to be? */ -int -window_bottom_toolbar_height (struct window *w) -{ - return 0; -} - -static int -window_left_toolbar_width (struct window *w) -{ - return 0; -} - -static int -window_right_toolbar_width (struct window *w) -{ - return 0; -} - /***************************************************************************** Window Gutters @@ -1019,47 +994,45 @@ window_right_toolbar_width (struct window *w) int window_top_gutter_height (struct window *w) { - int toolbar_height = window_top_toolbar_height (w); + int gutter = WINDOW_REAL_TOP_GUTTER_BOUNDS (w); if (!NILP (w->hchild) || !NILP (w->vchild)) return 0; #ifdef HAVE_SCROLLBARS if (!NILP (w->scrollbar_on_top_p)) - return window_scrollbar_height (w) + toolbar_height; + return window_scrollbar_height (w) + gutter; else #endif - return toolbar_height; + return gutter; } int window_bottom_gutter_height (struct window *w) { - int other_height; + int gutter = WINDOW_REAL_BOTTOM_GUTTER_BOUNDS (w); if (!NILP (w->hchild) || !NILP (w->vchild)) return 0; - else - other_height = - window_modeline_height (w) + window_bottom_toolbar_height (w); + + gutter += window_modeline_height (w); #ifdef HAVE_SCROLLBARS if (NILP (w->scrollbar_on_top_p)) - return window_scrollbar_height (w) + other_height; + return window_scrollbar_height (w) + gutter; else #endif - return other_height; + return gutter; } int window_left_gutter_width (struct window *w, int modeline) { - int gutter = window_left_toolbar_width (w); + int gutter = WINDOW_REAL_LEFT_GUTTER_BOUNDS (w); if (!NILP (w->hchild) || !NILP (w->vchild)) return 0; - #ifdef HAVE_SCROLLBARS if (!modeline && !NILP (w->scrollbar_on_left_p)) gutter += window_scrollbar_width (w); @@ -1071,7 +1044,7 @@ window_left_gutter_width (struct window *w, int modeline) int window_right_gutter_width (struct window *w, int modeline) { - int gutter = window_right_toolbar_width (w); + int gutter = WINDOW_REAL_RIGHT_GUTTER_BOUNDS (w); if (!NILP (w->hchild) || !NILP (w->vchild)) return 0; @@ -1345,7 +1318,7 @@ is non-nil, do not include space occupied by clipped lines. if (NILP (window)) window = Fselected_window (Qnil); - CHECK_WINDOW (window); + CHECK_LIVE_WINDOW (window); w = XWINDOW (window); start = marker_position (w->start[CURRENT_DISP]); @@ -3319,7 +3292,7 @@ make_dummy_parent (Lisp_Object window) { Lisp_Object new; struct window *o = XWINDOW (window); - struct window *p = alloc_lcrecord_type (struct window, lrecord_window); + struct window *p = alloc_lcrecord_type (struct window, &lrecord_window); XSETWINDOW (new, p); copy_lcrecord (p, o); @@ -3366,7 +3339,7 @@ and put SIZE columns in the first of the pair. if (NILP (window)) window = Fselected_window (Qnil); else - CHECK_WINDOW (window); + CHECK_LIVE_WINDOW (window); o = XWINDOW (window); f = XFRAME (WINDOW_FRAME (o)); @@ -3926,6 +3899,8 @@ change_window_height (struct window *win, int delta, int widthflag, SET_LAST_MODIFIED (w, 0); SET_LAST_FACECHANGE (w); MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); + /* overkill maybe, but better to be correct */ + MARK_FRAME_GUTTERS_CHANGED (f); } #undef MINSIZE #undef CURBEG @@ -4304,7 +4279,7 @@ If WINDOW is nil, the selected window is used. if (NILP (window)) window = Fselected_window (Qnil); else - CHECK_WINDOW (window); + CHECK_LIVE_WINDOW (window); w = XWINDOW (window); b = XBUFFER (w->buffer); @@ -4621,8 +4596,8 @@ struct saved_window struct window_config { struct lcrecord_header header; - int frame_width; - int frame_height; + /* int frame_width; No longer needed, JV + int frame_height; */ #if 0 /* FSFmacs */ Lisp_Object selected_frame; #endif @@ -4630,6 +4605,7 @@ struct window_config Lisp_Object current_buffer; Lisp_Object minibuffer_scroll_window; Lisp_Object root_window; + int minibuf_height; /* 0 = no minibuffer, <0, size in lines, >0 in pixels */ /* Record the values of window-min-width and window-min-height so that window sizes remain consistent with them. */ int min_width, min_height; @@ -4710,7 +4686,7 @@ DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("window-configuration", window_configuration, mark_window_config, print_window_config, - 0, 0, 0, sizeof_window_config, + 0, 0, 0, 0, sizeof_window_config, struct window_config); @@ -4761,9 +4737,10 @@ window_config_equal (Lisp_Object conf1, Lisp_Object conf2) EQ (fig1->current_window, fig2->current_window) && EQ (fig1->current_buffer, fig2->current_buffer) && EQ (fig1->root_window, fig2->root_window) && - EQ (fig1->minibuffer_scroll_window, fig2->minibuffer_scroll_window) && + EQ (fig1->minibuffer_scroll_window, fig2->minibuffer_scroll_window))) + /* && fig1->frame_width == fig2->frame_width && - fig1->frame_height == fig2->frame_height)) + fig1->frame_height == fig2->frame_height)) */ return 0; for (i = 0; i < fig1->saved_windows_count; i++) @@ -4859,8 +4836,15 @@ by `current-window-configuration' (which see). struct frame *f; struct gcpro gcpro1; Lisp_Object old_window_config; - int previous_frame_height; - int previous_frame_width; + /* int previous_frame_height; + int previous_frame_width;*/ + int previous_pixel_top; + int previous_pixel_height; + int previous_pixel_left; + int previous_pixel_width; + int previous_minibuf_height, previous_minibuf_top,previous_minibuf_width; + int real_font_height; + int converted_minibuf_height,target_minibuf_height; int specpdl_count = specpdl_depth (); GCPRO1 (configuration); @@ -4925,6 +4909,20 @@ by `current-window-configuration' (which see). mark_windows_in_use (f, 1); +#if 0 + /* JV: This is bogus, + First of all, the units are inconsistent. The frame sizes are measured + in characters but the window sizes are stored in pixels. So if a + font size change happened between saving and restoring, the + frame "sizes" maybe equal but the windows still should be + resized. This is tickled alot by the new "character size + stays constant" policy in 21.0. It leads to very wierd + glitches (and possibly craches when asserts are tickled). + + Just changing the units doens't help because changing the + toolbar configuration can also change the pixel positions. + Luckily there is a much simpler way of doing this, see below. + */ previous_frame_width = FRAME_WIDTH (f); previous_frame_height = FRAME_HEIGHT (f); /* If the frame has been resized since this window configuration was @@ -4934,7 +4932,37 @@ by `current-window-configuration' (which see). if (config->frame_height != FRAME_HEIGHT (f) || config->frame_width != FRAME_WIDTH (f)) change_frame_size (f, config->frame_height, config->frame_width, 0); - +#endif + + previous_pixel_top = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top; + previous_pixel_height = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_height; + previous_pixel_left = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left; + previous_pixel_width = XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_width; + + /* remember some properties of the minibuffer */ + + default_face_height_and_width (frame, &real_font_height, 0); + assert(real_font_height > 0); + + if (FRAME_HAS_MINIBUF_P (f) && ! FRAME_MINIBUF_ONLY_P (f)) + { + previous_minibuf_height + = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; + previous_minibuf_top + = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_top; + previous_minibuf_width + = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_width; + } + else + { + previous_minibuf_height = 0; + previous_minibuf_width = 0; + } + converted_minibuf_height = + (previous_minibuf_height % real_font_height) == 0 ? + - (previous_minibuf_height / real_font_height ) : /* lines */ + previous_minibuf_height; /* pixels */ + /* Temporarily avoid any problems with windows that are smaller than they are supposed to be. */ window_min_height = 1; @@ -5100,11 +5128,61 @@ by `current-window-configuration' (which see). currently selected, or just set the selected window of the window config's frame. */ +#if 0 /* Set the frame height to the value it had before this function. */ if (previous_frame_height != FRAME_HEIGHT (f) || previous_frame_width != FRAME_WIDTH (f)) change_frame_size (f, previous_frame_height, previous_frame_width, 0); - +#endif + /* We just reset the size and position of the minibuffer, to its old + value, which needn't be valid. So we do some magic to see which value + to actually take. Then we set it. + + The magic: + We take the old value if is in the same units but differs from the + current value. + + #### Now we get more cases correct then ever before, but + are we treating all? For instance what if the frames minibuf window + is no longer the same one? + */ + target_minibuf_height = previous_minibuf_height; + if (converted_minibuf_height && + (converted_minibuf_height * config->minibuf_height) > 0 && + (converted_minibuf_height != config->minibuf_height)) + { + target_minibuf_height = config->minibuf_height < 0 ? + - (config->minibuf_height * real_font_height) : + config->minibuf_height; + target_minibuf_height = + max(target_minibuf_height,real_font_height); + } + if (previous_minibuf_height) + { + XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top + = previous_minibuf_top - + (target_minibuf_height - previous_minibuf_height); + set_window_pixheight (FRAME_MINIBUF_WINDOW (f), + target_minibuf_height, 0); + set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), + previous_minibuf_width, 0); + } + + /* This is a better way to deal with frame resizing, etc. + What we _actually_ want is for the old (just restored) + root window to fit + into the place of the new one. So we just do that. Simple! */ + XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top = previous_pixel_top; + /* Note that this function also updates the subwindow + "pixel_top"s */ + set_window_pixheight (FRAME_ROOT_WINDOW (f), + previous_pixel_height - + (target_minibuf_height - previous_minibuf_height), 0); + XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = previous_pixel_left; + /* Note that this function also updates the subwindow + "pixel_left"s */ + set_window_pixwidth (FRAME_ROOT_WINDOW (f), previous_pixel_width, 0); + /* If restoring in the current frame make the window current, otherwise just update the frame selected_window slot to be the restored current_window. */ @@ -5319,6 +5397,8 @@ its value is -not- saved. struct frame *f = decode_frame (frame); struct window_config *config; int n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); + int minibuf_height; + int real_font_height; if (n_windows <= countof (Vwindow_configuration_free_list)) config = XWINDOW_CONFIGURATION (allocate_managed_lcrecord @@ -5328,11 +5408,11 @@ its value is -not- saved. /* More than ten windows; just allocate directly */ config = (struct window_config *) alloc_lcrecord (sizeof_window_config_for_n_windows (n_windows), - lrecord_window_configuration); + &lrecord_window_configuration); XSETWINDOW_CONFIGURATION (result, config); - + /* config->frame_width = FRAME_WIDTH (f); - config->frame_height = FRAME_HEIGHT (f); + config->frame_height = FRAME_HEIGHT (f); */ config->current_window = FRAME_SELECTED_WINDOW (f); XSETBUFFER (config->current_buffer, current_buffer); config->minibuffer_scroll_window = Vminibuffer_scroll_window; @@ -5341,6 +5421,22 @@ its value is -not- saved. config->min_width = window_min_width; config->saved_windows_count = n_windows; save_window_save (FRAME_ROOT_WINDOW (f), config, 0); + + /* save the minibuffer height using the heuristics from + change_frame_size_1 */ + + XSETFRAME (frame, f); /* frame could have been nil ! */ + default_face_height_and_width (frame, &real_font_height, 0); + assert(real_font_height > 0); + + if (FRAME_HAS_MINIBUF_P (f) && ! FRAME_MINIBUF_ONLY_P (f)) + minibuf_height = XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; + else + minibuf_height = 0; + config->minibuf_height = (minibuf_height % real_font_height) == 0 ? + - (minibuf_height / real_font_height ) : /* lines */ + minibuf_height; /* pixels */ + return result; } @@ -5577,7 +5673,7 @@ If non-nil, this is a buffer and \\[scroll-other-window] should scroll its windo { Vwindow_configuration_free_list[i] = make_lcrecord_list (sizeof_window_config_for_n_windows (i + 1), - lrecord_window_configuration); + &lrecord_window_configuration); staticpro (&Vwindow_configuration_free_list[i]); } }