From: Dmitry Antipov Date: Mon, 12 Aug 2013 09:34:00 +0000 (+0400) Subject: Avoid looping over all frame windows to freeze and unfreeze. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~309 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d2e113bc86fba063f39cf5d1893ee47b4cf43a9a;p=emacs.git Avoid looping over all frame windows to freeze and unfreeze. * window.h (struct window): Drop frozen_window_start_p. (freeze_window_starts): Drop prototype. * frame.h (struct frame): New frozen_window_starts flag. (FRAME_WINDOWS_FROZEN): New macro. * window.c (freeze_window_start, freeze_window_starts): Remove. (select_window, replace_window): Adjust users. * xdisp.c (resize_mini_window): Use FRAME_WINDOWS_FROZEN. (window_frozen_p): New function. (redisplay_window): Use it. --- diff --git a/src/ChangeLog b/src/ChangeLog index 759f66bc1b4..679b82ba63c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-08-12 Dmitry Antipov + + Avoid looping over all frame windows to freeze and unfreeze. + * window.h (struct window): Drop frozen_window_start_p. + (freeze_window_starts): Drop prototype. + * frame.h (struct frame): New frozen_window_starts flag. + (FRAME_WINDOWS_FROZEN): New macro. + * window.c (freeze_window_start, freeze_window_starts): + Remove. + (select_window, replace_window): Adjust users. + * xdisp.c (resize_mini_window): Use FRAME_WINDOWS_FROZEN. + (window_frozen_p): New function. + (redisplay_window): Use it. + 2013-08-12 Paul Eggert Fix some fd issues when running subprocesses (Bug#15035). diff --git a/src/frame.h b/src/frame.h index 33e4bb71d7a..e44003b15ca 100644 --- a/src/frame.h +++ b/src/frame.h @@ -410,6 +410,10 @@ struct frame /* Nonzero means that the pointer is invisible. */ unsigned pointer_invisible :1; + /* Nonzero means that all windows except mini-window and + selected window on this frame have frozen window starts. */ + unsigned frozen_window_starts : 1; + /* Nonzero if we should actually display the scroll bars on this frame. */ enum vertical_scroll_bar_type vertical_scroll_bar_type; @@ -761,6 +765,10 @@ default_pixels_per_inch_y (void) /* Not really implemented. */ #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline +/* Nonzero if all windows except selected window and mini window + are frozen on frame F. */ +#define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts + /* Nonzero if a size change has been requested for frame F but not yet really put into effect. This can be true temporarily when an X event comes in at a bad time. */ diff --git a/src/window.c b/src/window.c index 31b5b2717a4..47a7b58ba9b 100644 --- a/src/window.c +++ b/src/window.c @@ -69,7 +69,6 @@ static int get_leaf_windows (struct window *, struct window **, int); static void window_scroll (Lisp_Object, EMACS_INT, bool, int); static void window_scroll_pixel_based (Lisp_Object, int, bool, int); static void window_scroll_line_based (Lisp_Object, int, bool, int); -static int freeze_window_start (struct window *, void *); static Lisp_Object window_list (void); static int add_window_to_list (struct window *, void *); static Lisp_Object next_window (Lisp_Object, Lisp_Object, @@ -499,7 +498,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) CHECK_LIVE_WINDOW (window); w = XWINDOW (window); - w->frozen_window_start_p = 0; /* Make the selected window's buffer current. */ Fset_buffer (w->contents); @@ -2055,7 +2053,6 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) wset_window_end_vpos (n, make_number (0)); wset_window_end_pos (n, make_number (0)); n->window_end_valid = 0; - n->frozen_window_start_p = 0; } tem = o->next; @@ -6453,38 +6450,6 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u return cont; } - -/* Freeze or unfreeze the window start of W unless it is a - mini-window or the selected window. FREEZE_P non-null means freeze - the window start. */ - -static int -freeze_window_start (struct window *w, void *freeze_p) -{ - if (MINI_WINDOW_P (w) - || (WINDOWP (selected_window) /* Can be nil in corner cases. */ - && (w == XWINDOW (selected_window) - || (MINI_WINDOW_P (XWINDOW (selected_window)) - && ! NILP (Vminibuf_scroll_window) - && w == XWINDOW (Vminibuf_scroll_window))))) - freeze_p = NULL; - - w->frozen_window_start_p = freeze_p != NULL; - return 1; -} - - -/* Freeze or unfreeze the window starts of all leaf windows on frame - F, except the selected window and a mini-window. FREEZE_P non-zero - means freeze the window start. */ - -void -freeze_window_starts (struct frame *f, bool freeze_p) -{ - foreach_window (f, freeze_window_start, freeze_p ? f : 0); -} - - /*********************************************************************** Initialization ***********************************************************************/ diff --git a/src/window.h b/src/window.h index 24949e1e287..260a672d93a 100644 --- a/src/window.h +++ b/src/window.h @@ -316,11 +316,6 @@ struct window Currently only used for menu bar windows of frames. */ unsigned pseudo_window_p : 1; - /* 1 means the window start of this window is frozen and may not - be changed during redisplay. If point is not in the window, - accept that. */ - unsigned frozen_window_start_p : 1; - /* Non-zero means fringes are drawn outside display margins. Otherwise draw them between margin areas and text. */ unsigned fringes_outside_margins : 1; @@ -888,7 +883,6 @@ extern Lisp_Object window_from_coordinates (struct frame *, int, int, extern void resize_frame_windows (struct frame *, int, bool); extern void restore_window_configuration (Lisp_Object); extern void delete_all_child_windows (Lisp_Object); -extern void freeze_window_starts (struct frame *, bool); extern void grow_mini_window (struct window *, int); extern void shrink_mini_window (struct window *); extern int window_relative_x_coord (struct window *, enum window_part, int); diff --git a/src/xdisp.c b/src/xdisp.c index 67f4720e170..37f2c94b5f8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10460,7 +10460,8 @@ resize_mini_window (struct window *w, int exact_p) if (height > WINDOW_TOTAL_LINES (w)) { int old_height = WINDOW_TOTAL_LINES (w); - freeze_window_starts (f, 1); + + FRAME_WINDOWS_FROZEN (f) = 1; grow_mini_window (w, height - WINDOW_TOTAL_LINES (w)); window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height; } @@ -10468,7 +10469,8 @@ resize_mini_window (struct window *w, int exact_p) && (exact_p || BEGV == ZV)) { int old_height = WINDOW_TOTAL_LINES (w); - freeze_window_starts (f, 0); + + FRAME_WINDOWS_FROZEN (f) = 0; shrink_mini_window (w); window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height; } @@ -10479,19 +10481,21 @@ resize_mini_window (struct window *w, int exact_p) if (height > WINDOW_TOTAL_LINES (w)) { int old_height = WINDOW_TOTAL_LINES (w); - freeze_window_starts (f, 1); + + FRAME_WINDOWS_FROZEN (f) = 1; grow_mini_window (w, height - WINDOW_TOTAL_LINES (w)); window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height; } else if (height < WINDOW_TOTAL_LINES (w)) { int old_height = WINDOW_TOTAL_LINES (w); - freeze_window_starts (f, 0); + + FRAME_WINDOWS_FROZEN (f) = 0; shrink_mini_window (w); if (height) { - freeze_window_starts (f, 1); + FRAME_WINDOWS_FROZEN (f) = 1; grow_mini_window (w, height - WINDOW_TOTAL_LINES (w)); } @@ -10874,6 +10878,31 @@ mode_line_update_needed (struct window *w) && (w->column_number_displayed != current_column ())); } +/* Nonzero if window start of W is frozen and may not be changed during + redisplay. */ + +static bool +window_frozen_p (struct window *w) +{ + if (FRAME_WINDOWS_FROZEN (XFRAME (WINDOW_FRAME (w)))) + { + Lisp_Object window; + + XSETWINDOW (window, w); + if (MINI_WINDOW_P (w)) + return 0; + else if (EQ (window, selected_window)) + return 0; + else if (MINI_WINDOW_P (XWINDOW (selected_window)) + && EQ (window, Vminibuf_scroll_window)) + /* This special window can't be frozen too. */ + return 0; + else + return 1; + } + return 0; +} + /*********************************************************************** Mode Lines and Frame Titles ***********************************************************************/ @@ -15510,7 +15539,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) /* Handle case where place to start displaying has been specified, unless the specified location is outside the accessible range. */ - if (w->force_start || w->frozen_window_start_p) + if (w->force_start || window_frozen_p (w)) { /* We set this later on if we have to adjust point. */ int new_vpos = -1; @@ -15555,7 +15584,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) goto need_larger_matrices; } - if (w->cursor.vpos < 0 && !w->frozen_window_start_p) + if (w->cursor.vpos < 0 && !window_frozen_p (w)) { /* If point does not appear, try to move point so it does appear. The desired matrix has been built above, so we