aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-09-26 11:15:40 +0000
committerGerd Moellmann2001-09-26 11:15:40 +0000
commit5d3cc43c0c7f9959dbb57d914655cd5f5ad74b71 (patch)
treefca69bdb986ce44d2b366932e33300fd04e022b0 /src
parent9a636f377f27dc4f084b7a6714e826770862056f (diff)
downloademacs-5d3cc43c0c7f9959dbb57d914655cd5f5ad74b71.tar.gz
emacs-5d3cc43c0c7f9959dbb57d914655cd5f5ad74b71.zip
(required_matrix_width, required_matrix_height): New
functions. (allocate_matrices_for_window_redisplay) (allocate_matrices_for_frame_redisplay: Use them. Remove parameters CH_DIM.
Diffstat (limited to 'src')
-rw-r--r--src/dispnew.c116
1 files changed, 73 insertions, 43 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index abc41ad2a27..02ce752692d 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -131,9 +131,8 @@ static int count_match P_ ((struct glyph *, struct glyph *,
131static unsigned line_draw_cost P_ ((struct glyph_matrix *, int)); 131static unsigned line_draw_cost P_ ((struct glyph_matrix *, int));
132static void update_frame_line P_ ((struct frame *, int)); 132static void update_frame_line P_ ((struct frame *, int));
133static struct dim allocate_matrices_for_frame_redisplay 133static struct dim allocate_matrices_for_frame_redisplay
134 P_ ((Lisp_Object, int, int, struct dim, int, int *)); 134 P_ ((Lisp_Object, int, int, int, int *));
135static void allocate_matrices_for_window_redisplay P_ ((struct window *, 135static void allocate_matrices_for_window_redisplay P_ ((struct window *));
136 struct dim));
137static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim)); 136static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim));
138static void adjust_frame_glyphs P_ ((struct frame *)); 137static void adjust_frame_glyphs P_ ((struct frame *));
139struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *)); 138struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *));
@@ -1857,11 +1856,10 @@ check_matrix_invariants (w)
1857#define CHANGED_LEAF_MATRIX (1 << 1) 1856#define CHANGED_LEAF_MATRIX (1 << 1)
1858 1857
1859static struct dim 1858static struct dim
1860allocate_matrices_for_frame_redisplay (window, x, y, ch_dim, 1859allocate_matrices_for_frame_redisplay (window, x, y, dim_only_p,
1861 dim_only_p, window_change_flags) 1860 window_change_flags)
1862 Lisp_Object window; 1861 Lisp_Object window;
1863 int x, y; 1862 int x, y;
1864 struct dim ch_dim;
1865 int dim_only_p; 1863 int dim_only_p;
1866 int *window_change_flags; 1864 int *window_change_flags;
1867{ 1865{
@@ -1891,11 +1889,11 @@ allocate_matrices_for_frame_redisplay (window, x, y, ch_dim,
1891 /* Get the dimension of the window sub-matrix for W, depending 1889 /* Get the dimension of the window sub-matrix for W, depending
1892 on whether this a combination or a leaf window. */ 1890 on whether this a combination or a leaf window. */
1893 if (!NILP (w->hchild)) 1891 if (!NILP (w->hchild))
1894 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, ch_dim, 1892 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y,
1895 dim_only_p, 1893 dim_only_p,
1896 window_change_flags); 1894 window_change_flags);
1897 else if (!NILP (w->vchild)) 1895 else if (!NILP (w->vchild))
1898 dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y, ch_dim, 1896 dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y,
1899 dim_only_p, 1897 dim_only_p,
1900 window_change_flags); 1898 window_change_flags);
1901 else 1899 else
@@ -1910,8 +1908,8 @@ allocate_matrices_for_frame_redisplay (window, x, y, ch_dim,
1910 1908
1911 /* Width and height MUST be chosen so that there are no 1909 /* Width and height MUST be chosen so that there are no
1912 holes in the frame matrix. */ 1910 holes in the frame matrix. */
1913 dim.width = XINT (w->width); 1911 dim.width = required_matrix_width (w);
1914 dim.height = XINT (w->height); 1912 dim.height = required_matrix_height (w);
1915 1913
1916 /* Will matrix be re-allocated? */ 1914 /* Will matrix be re-allocated? */
1917 if (x != w->desired_matrix->matrix_x 1915 if (x != w->desired_matrix->matrix_x
@@ -1976,28 +1974,78 @@ allocate_matrices_for_frame_redisplay (window, x, y, ch_dim,
1976} 1974}
1977 1975
1978 1976
1977/* Return the required height of glyph matrices for window W. */
1978
1979int
1980required_matrix_height (w)
1981 struct window *w;
1982{
1983#ifdef HAVE_WINDOW_SYSTEM
1984 struct frame *f = XFRAME (w->frame);
1985
1986 if (FRAME_WINDOW_P (f))
1987 {
1988 int ch_height = FRAME_SMALLEST_FONT_HEIGHT (f);
1989 int window_pixel_height = window_box_height (w) + abs (w->vscroll);
1990 return (((window_pixel_height + ch_height - 1)
1991 / ch_height)
1992 /* One partially visible line at the top and
1993 bottom of the window. */
1994 + 2
1995 /* 2 for top and mode line. */
1996 + 2);
1997 }
1998#endif /* HAVE_WINDOW_SYSTEM */
1999
2000 return XINT (w->height);
2001}
2002
2003
2004/* Return the required width of glyph matrices for window W. */
2005
2006int
2007required_matrix_width (w)
2008 struct window *w;
2009{
2010#ifdef HAVE_WINDOW_SYSTEM
2011 struct frame *f = XFRAME (w->frame);
2012 if (FRAME_WINDOW_P (f))
2013 {
2014 int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f);
2015 int window_pixel_width = XFLOATINT (w->width) * CANON_X_UNIT (f);
2016
2017 /* Compute number of glyphs needed in a glyph row. */
2018 return (((window_pixel_width + ch_width - 1)
2019 / ch_width)
2020 /* 2 partially visible columns in the text area. */
2021 + 2
2022 /* One partially visible column at the right
2023 edge of each marginal area. */
2024 + 1 + 1);
2025 }
2026#endif /* HAVE_WINDOW_SYSTEM */
2027
2028 return XINT (w->width);
2029}
2030
2031
1979/* Allocate window matrices for window-based redisplay. W is the 2032/* Allocate window matrices for window-based redisplay. W is the
1980 window whose matrices must be allocated/reallocated. CH_DIM is the 2033 window whose matrices must be allocated/reallocated. CH_DIM is the
1981 size of the smallest character that could potentially be used on W. */ 2034 size of the smallest character that could potentially be used on W. */
1982 2035
1983static void 2036static void
1984allocate_matrices_for_window_redisplay (w, ch_dim) 2037allocate_matrices_for_window_redisplay (w)
1985 struct window *w; 2038 struct window *w;
1986 struct dim ch_dim;
1987{ 2039{
1988 struct frame *f = XFRAME (w->frame);
1989
1990 while (w) 2040 while (w)
1991 { 2041 {
1992 if (!NILP (w->vchild)) 2042 if (!NILP (w->vchild))
1993 allocate_matrices_for_window_redisplay (XWINDOW (w->vchild), ch_dim); 2043 allocate_matrices_for_window_redisplay (XWINDOW (w->vchild));
1994 else if (!NILP (w->hchild)) 2044 else if (!NILP (w->hchild))
1995 allocate_matrices_for_window_redisplay (XWINDOW (w->hchild), ch_dim); 2045 allocate_matrices_for_window_redisplay (XWINDOW (w->hchild));
1996 else 2046 else
1997 { 2047 {
1998 /* W is a leaf window. */ 2048 /* W is a leaf window. */
1999 int window_pixel_width = XFLOATINT (w->width) * CANON_X_UNIT (f);
2000 int window_pixel_height = window_box_height (w) + abs (w->vscroll);
2001 struct dim dim; 2049 struct dim dim;
2002 2050
2003 /* If matrices are not yet allocated, allocate them now. */ 2051 /* If matrices are not yet allocated, allocate them now. */
@@ -2007,25 +2055,8 @@ allocate_matrices_for_window_redisplay (w, ch_dim)
2007 w->current_matrix = new_glyph_matrix (NULL); 2055 w->current_matrix = new_glyph_matrix (NULL);
2008 } 2056 }
2009 2057
2010 /* Compute number of glyphs needed in a glyph row. */ 2058 dim.width = required_matrix_width (w);
2011 dim.width = (((window_pixel_width + ch_dim.width - 1) 2059 dim.height = required_matrix_height (w);
2012 / ch_dim.width)
2013 /* 2 partially visible columns in the text area. */
2014 + 2
2015 /* One partially visible column at the right
2016 edge of each marginal area. */
2017 + 1 + 1);
2018
2019 /* Compute number of glyph rows needed. */
2020 dim.height = (((window_pixel_height + ch_dim.height - 1)
2021 / ch_dim.height)
2022 /* One partially visible line at the top and
2023 bottom of the window. */
2024 + 2
2025 /* 2 for top and mode line. */
2026 + 2);
2027
2028 /* Change matrices. */
2029 adjust_glyph_matrix (w, w->desired_matrix, 0, 0, dim); 2060 adjust_glyph_matrix (w, w->desired_matrix, 0, 0, dim);
2030 adjust_glyph_matrix (w, w->current_matrix, 0, 0, dim); 2061 adjust_glyph_matrix (w, w->current_matrix, 0, 0, dim);
2031 } 2062 }
@@ -2273,7 +2304,7 @@ adjust_frame_glyphs_for_frame_redisplay (f)
2273 matrix_dim 2304 matrix_dim
2274 = allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f), 2305 = allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f),
2275 0, top_window_y, 2306 0, top_window_y,
2276 ch_dim, 1, 2307 1,
2277 &window_change_flags); 2308 &window_change_flags);
2278 2309
2279 /* Add in menu bar lines, if any. */ 2310 /* Add in menu bar lines, if any. */
@@ -2289,7 +2320,7 @@ adjust_frame_glyphs_for_frame_redisplay (f)
2289 { 2320 {
2290 /* Do it for window matrices. */ 2321 /* Do it for window matrices. */
2291 allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f), 2322 allocate_matrices_for_frame_redisplay (FRAME_ROOT_WINDOW (f),
2292 0, top_window_y, ch_dim, 0, 2323 0, top_window_y, 0,
2293 &window_change_flags); 2324 &window_change_flags);
2294 2325
2295 /* Size of frame matrices must equal size of frame. Note 2326 /* Size of frame matrices must equal size of frame. Note
@@ -2349,8 +2380,7 @@ adjust_frame_glyphs_for_window_redisplay (f)
2349#endif 2380#endif
2350 2381
2351 /* Allocate/reallocate window matrices. */ 2382 /* Allocate/reallocate window matrices. */
2352 allocate_matrices_for_window_redisplay (XWINDOW (FRAME_ROOT_WINDOW (f)), 2383 allocate_matrices_for_window_redisplay (XWINDOW (FRAME_ROOT_WINDOW (f)));
2353 ch_dim);
2354 2384
2355 /* Allocate/ reallocate matrices of the dummy window used to display 2385 /* Allocate/ reallocate matrices of the dummy window used to display
2356 the menu bar under X when no X toolkit support is available. */ 2386 the menu bar under X when no X toolkit support is available. */
@@ -2373,7 +2403,7 @@ adjust_frame_glyphs_for_window_redisplay (f)
2373 XSETFASTINT (w->left, 0); 2403 XSETFASTINT (w->left, 0);
2374 XSETFASTINT (w->height, FRAME_MENU_BAR_LINES (f)); 2404 XSETFASTINT (w->height, FRAME_MENU_BAR_LINES (f));
2375 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f)); 2405 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f));
2376 allocate_matrices_for_window_redisplay (w, ch_dim); 2406 allocate_matrices_for_window_redisplay (w);
2377 } 2407 }
2378#endif /* not USE_X_TOOLKIT */ 2408#endif /* not USE_X_TOOLKIT */
2379 2409
@@ -2393,7 +2423,7 @@ adjust_frame_glyphs_for_window_redisplay (f)
2393 XSETFASTINT (w->left, 0); 2423 XSETFASTINT (w->left, 0);
2394 XSETFASTINT (w->height, FRAME_TOOL_BAR_LINES (f)); 2424 XSETFASTINT (w->height, FRAME_TOOL_BAR_LINES (f));
2395 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f)); 2425 XSETFASTINT (w->width, FRAME_WINDOW_WIDTH (f));
2396 allocate_matrices_for_window_redisplay (w, ch_dim); 2426 allocate_matrices_for_window_redisplay (w);
2397} 2427}
2398 2428
2399 2429