Mercurial > emacs
comparison src/dispnew.c @ 39448:b74c165ef22f
(required_matrix_width, required_matrix_height): New
functions.
(allocate_matrices_for_window_redisplay)
(allocate_matrices_for_frame_redisplay: Use them. Remove
parameters CH_DIM.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 26 Sep 2001 11:15:40 +0000 |
parents | 73dd40615520 |
children | 5f60884970a8 |
comparison
equal
deleted
inserted
replaced
39447:97363868cbb1 | 39448:b74c165ef22f |
---|---|
129 static int count_match P_ ((struct glyph *, struct glyph *, | 129 static int count_match P_ ((struct glyph *, struct glyph *, |
130 struct glyph *, struct glyph *)); | 130 struct glyph *, struct glyph *)); |
131 static unsigned line_draw_cost P_ ((struct glyph_matrix *, int)); | 131 static unsigned line_draw_cost P_ ((struct glyph_matrix *, int)); |
132 static void update_frame_line P_ ((struct frame *, int)); | 132 static void update_frame_line P_ ((struct frame *, int)); |
133 static struct dim allocate_matrices_for_frame_redisplay | 133 static 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 *)); |
135 static void allocate_matrices_for_window_redisplay P_ ((struct window *, | 135 static void allocate_matrices_for_window_redisplay P_ ((struct window *)); |
136 struct dim)); | |
137 static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim)); | 136 static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim)); |
138 static void adjust_frame_glyphs P_ ((struct frame *)); | 137 static void adjust_frame_glyphs P_ ((struct frame *)); |
139 struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *)); | 138 struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *)); |
140 static void free_glyph_matrix P_ ((struct glyph_matrix *)); | 139 static void free_glyph_matrix P_ ((struct glyph_matrix *)); |
141 static void adjust_glyph_matrix P_ ((struct window *, struct glyph_matrix *, | 140 static void adjust_glyph_matrix P_ ((struct window *, struct glyph_matrix *, |
1855 size. */ | 1854 size. */ |
1856 | 1855 |
1857 #define CHANGED_LEAF_MATRIX (1 << 1) | 1856 #define CHANGED_LEAF_MATRIX (1 << 1) |
1858 | 1857 |
1859 static struct dim | 1858 static struct dim |
1860 allocate_matrices_for_frame_redisplay (window, x, y, ch_dim, | 1859 allocate_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 { |
1868 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); | 1866 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
1869 int x0 = x, y0 = y; | 1867 int x0 = x, y0 = y; |
1889 w = XWINDOW (window); | 1887 w = XWINDOW (window); |
1890 | 1888 |
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 |
1902 { | 1900 { |
1903 /* If not already done, allocate sub-matrix structures. */ | 1901 /* If not already done, allocate sub-matrix structures. */ |
1908 *window_change_flags |= NEW_LEAF_MATRIX; | 1906 *window_change_flags |= NEW_LEAF_MATRIX; |
1909 } | 1907 } |
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 |
1918 || y != w->desired_matrix->matrix_y | 1916 || y != w->desired_matrix->matrix_y |
1919 || dim.width != w->desired_matrix->matrix_w | 1917 || dim.width != w->desired_matrix->matrix_w |
1974 | 1972 |
1975 return total; | 1973 return total; |
1976 } | 1974 } |
1977 | 1975 |
1978 | 1976 |
1977 /* Return the required height of glyph matrices for window W. */ | |
1978 | |
1979 int | |
1980 required_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 | |
2006 int | |
2007 required_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 |
1983 static void | 2036 static void |
1984 allocate_matrices_for_window_redisplay (w, ch_dim) | 2037 allocate_matrices_for_window_redisplay (w) |
1985 struct window *w; | 2038 struct window *w; |
1986 struct dim ch_dim; | 2039 { |
1987 { | |
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. */ |
2004 if (w->desired_matrix == NULL) | 2052 if (w->desired_matrix == NULL) |
2005 { | 2053 { |
2006 w->desired_matrix = new_glyph_matrix (NULL); | 2054 w->desired_matrix = new_glyph_matrix (NULL); |
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 } |
2032 | 2063 |
2033 w = NILP (w->next) ? NULL : XWINDOW (w->next); | 2064 w = NILP (w->next) ? NULL : XWINDOW (w->next); |
2271 matrix. */ | 2302 matrix. */ |
2272 window_change_flags = 0; | 2303 window_change_flags = 0; |
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. */ |
2280 matrix_dim.height += top_window_y; | 2311 matrix_dim.height += top_window_y; |
2281 | 2312 |
2287 absolutely necessary since it requires a frame redraw. */ | 2318 absolutely necessary since it requires a frame redraw. */ |
2288 if (pool_changed_p || window_change_flags) | 2319 if (pool_changed_p || window_change_flags) |
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 |
2296 that we are called for X frames with window widths NOT equal | 2327 that we are called for X frames with window widths NOT equal |
2297 to the frame width (from CHANGE_FRAME_SIZE_1). */ | 2328 to the frame width (from CHANGE_FRAME_SIZE_1). */ |
2347 #else | 2378 #else |
2348 ch_dim.width = ch_dim.height = 1; | 2379 ch_dim.width = ch_dim.height = 1; |
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. */ |
2357 #ifndef USE_X_TOOLKIT | 2387 #ifndef USE_X_TOOLKIT |
2358 { | 2388 { |
2371 adjust glyph matrices of W. */ | 2401 adjust glyph matrices of W. */ |
2372 XSETFASTINT (w->top, 0); | 2402 XSETFASTINT (w->top, 0); |
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 |
2380 /* Allocate/ reallocate matrices of the tool bar window. If we | 2410 /* Allocate/ reallocate matrices of the tool bar window. If we |
2381 don't have a tool bar window yet, make one. */ | 2411 don't have a tool bar window yet, make one. */ |
2391 | 2421 |
2392 XSETFASTINT (w->top, FRAME_MENU_BAR_LINES (f)); | 2422 XSETFASTINT (w->top, FRAME_MENU_BAR_LINES (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 |
2400 /* Adjust/ allocate message buffer of frame F. | 2430 /* Adjust/ allocate message buffer of frame F. |
2401 | 2431 |