428
|
1 /* Synchronize redisplay structures and output changes.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
1318
|
3 Copyright (C) 1995, 1996, 2002, 2003 Ben Wing.
|
428
|
4 Copyright (C) 1996 Chuck Thompson.
|
863
|
5 Copyright (C) 1999, 2002 Andy Piper.
|
428
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 /* This file has been Mule-ized. */
|
|
27
|
|
28 /* Author: Chuck Thompson */
|
|
29
|
|
30 /* Heavily hacked for modularity, gutter and subwindow support by Andy
|
|
31 Piper. */
|
|
32
|
|
33 #include <config.h>
|
|
34 #include "lisp.h"
|
|
35
|
|
36 #include "buffer.h"
|
|
37 #include "window.h"
|
872
|
38 #include "frame-impl.h"
|
|
39 #include "device-impl.h"
|
428
|
40 #include "glyphs.h"
|
|
41 #include "redisplay.h"
|
|
42 #include "faces.h"
|
446
|
43 #include "gutter.h"
|
428
|
44
|
|
45 static int compare_runes (struct window *w, struct rune *crb,
|
|
46 struct rune *drb);
|
|
47 static void redraw_cursor_in_window (struct window *w,
|
|
48 int run_end_begin_glyphs);
|
|
49 static void redisplay_output_display_block (struct window *w, struct display_line *dl,
|
|
50 int block, int start, int end, int start_pixpos,
|
434
|
51 int cursor_start, int cursor_width,
|
428
|
52 int cursor_height);
|
434
|
53 static void redisplay_normalize_display_box (struct display_box* dest,
|
428
|
54 struct display_glyph_area* src);
|
|
55 static int redisplay_display_boxes_in_window_p (struct window* w,
|
|
56 struct display_box* db,
|
|
57 struct display_glyph_area* dga);
|
434
|
58 static void redisplay_clear_clipped_region (Lisp_Object locale, face_index findex,
|
|
59 struct display_box* dest,
|
|
60 struct display_glyph_area* glyphsrc,
|
428
|
61 int fullheight_p, Lisp_Object);
|
1318
|
62 static void redisplay_redraw_exposed_windows (Lisp_Object window, int x,
|
|
63 int y, int width, int height);
|
428
|
64
|
|
65 /*****************************************************************************
|
|
66 sync_rune_structs
|
|
67
|
|
68 Synchronize the given rune blocks.
|
|
69 ****************************************************************************/
|
|
70 static void
|
2286
|
71 sync_rune_structs (struct window *UNUSED (w), rune_dynarr *cra,
|
|
72 rune_dynarr *dra)
|
428
|
73 {
|
|
74 int rune_elt;
|
|
75 int max_move = ((Dynarr_length (dra) > Dynarr_largest (cra))
|
|
76 ? Dynarr_largest (cra)
|
|
77 : Dynarr_length (dra));
|
|
78
|
|
79 if (max_move)
|
|
80 {
|
|
81 /* #### Doing this directly breaks the encapsulation. But, the
|
4187
|
82 running time of this function has a measurable impact on
|
|
83 redisplay performance so avoiding all excess overhead is a
|
|
84 good thing. Is all of this true? */
|
428
|
85 memcpy (cra->base, dra->base, sizeof (struct rune) * max_move);
|
|
86 Dynarr_set_size (cra, max_move);
|
|
87 }
|
|
88 else
|
|
89 Dynarr_reset (cra);
|
|
90
|
|
91 for (rune_elt = max_move; rune_elt < Dynarr_length (dra); rune_elt++)
|
|
92 {
|
|
93 struct rune rb, *crb;
|
|
94 struct rune *drb = Dynarr_atp (dra, rune_elt);
|
|
95
|
|
96 crb = &rb;
|
|
97 memcpy (crb, drb, sizeof (struct rune));
|
|
98 Dynarr_add (cra, *crb);
|
|
99 }
|
|
100 }
|
|
101
|
|
102 /*****************************************************************************
|
|
103 sync_display_line_structs
|
|
104
|
|
105 For the given LINE in window W, make the current display line equal
|
|
106 the desired display line.
|
|
107 ****************************************************************************/
|
442
|
108 void
|
428
|
109 sync_display_line_structs (struct window *w, int line, int do_blocks,
|
|
110 display_line_dynarr *cdla,
|
|
111 display_line_dynarr *ddla)
|
|
112 {
|
|
113 struct display_line dl, *clp, *dlp;
|
|
114 int db_elt;
|
800
|
115 int local = 0;
|
428
|
116
|
4207
|
117 /* #### NOTE: practically, this is not needed because of the memcpy below.
|
|
118 #### However, it's cleaner and bugs-in-the-future proof. -- dvl */
|
|
119 DISPLAY_LINE_INIT (dl);
|
428
|
120 dlp = Dynarr_atp (ddla, line);
|
|
121 if (line >= Dynarr_largest (cdla))
|
|
122 {
|
|
123 clp = &dl;
|
|
124 clp->display_blocks = Dynarr_new (display_block);
|
800
|
125 local = 1;
|
428
|
126 }
|
|
127 else
|
|
128 {
|
|
129 clp = Dynarr_atp (cdla, line);
|
|
130 if (clp->display_blocks)
|
|
131 Dynarr_reset (clp->display_blocks);
|
|
132 if (clp->left_glyphs)
|
|
133 {
|
|
134 Dynarr_free (clp->left_glyphs);
|
|
135 clp->left_glyphs = 0;
|
|
136 }
|
|
137 if (clp->right_glyphs)
|
|
138 {
|
|
139 Dynarr_free (clp->right_glyphs);
|
|
140 clp->right_glyphs = 0;
|
|
141 }
|
|
142 }
|
|
143 {
|
|
144 display_block_dynarr *tdb = clp->display_blocks;
|
|
145
|
|
146 memcpy (clp, dlp, sizeof (struct display_line));
|
|
147 clp->display_blocks = tdb;
|
|
148 clp->left_glyphs = 0;
|
|
149 clp->right_glyphs = 0;
|
|
150 }
|
|
151
|
800
|
152 if (do_blocks || line < Dynarr_length (cdla))
|
428
|
153 {
|
800
|
154 for (db_elt = 0; db_elt < Dynarr_length (dlp->display_blocks); db_elt++)
|
|
155 {
|
|
156 struct display_block db, *cdb;
|
|
157 struct display_block *ddb = Dynarr_atp (dlp->display_blocks, db_elt);
|
|
158
|
|
159 if (db_elt >= Dynarr_largest (clp->display_blocks))
|
|
160 {
|
|
161 cdb = &db;
|
|
162 memcpy (cdb, ddb, sizeof (struct display_block));
|
|
163 cdb->runes = Dynarr_new (rune);
|
|
164 Dynarr_add (clp->display_blocks, *cdb);
|
|
165 }
|
|
166 else
|
|
167 {
|
|
168 rune_dynarr *tr;
|
|
169
|
|
170 cdb = Dynarr_atp (clp->display_blocks, db_elt);
|
|
171 tr = cdb->runes;
|
|
172 memcpy (cdb, ddb, sizeof (struct display_block));
|
|
173 cdb->runes = tr;
|
|
174 Dynarr_increment (clp->display_blocks);
|
|
175 }
|
|
176
|
|
177 sync_rune_structs (w, cdb->runes, ddb->runes);
|
|
178 }
|
428
|
179 }
|
|
180
|
800
|
181 if (local)
|
|
182 Dynarr_add (cdla, *clp);
|
|
183 else if (line >= Dynarr_length (cdla))
|
428
|
184 {
|
800
|
185 assert (line == Dynarr_length (cdla));
|
|
186 Dynarr_increment (cdla);
|
428
|
187 }
|
|
188 }
|
|
189
|
|
190 /*****************************************************************************
|
|
191 compare_runes
|
|
192
|
448
|
193 Compare two runes to see if each of their fields is equal. If so,
|
428
|
194 return true otherwise return false.
|
|
195 ****************************************************************************/
|
|
196 static int
|
|
197 compare_runes (struct window *w, struct rune *crb, struct rune *drb)
|
|
198 {
|
665
|
199 /* Do not compare the values of charbpos and endpos. They do not
|
428
|
200 affect the display characteristics. */
|
|
201
|
|
202 /* Note: (hanoi 6) spends 95% of its time in redisplay, and about
|
|
203 30% here. Not using bitfields for rune.type alone gives a redisplay
|
|
204 speed up of 10%.
|
|
205
|
|
206 #### In profile arcs run of a normal Gnus session this function
|
|
207 is run 6.76 million times, only to return 1 in 6.73 million of
|
|
208 those.
|
|
209
|
|
210 In addition a quick look GCC sparc assembly shows that GCC is not
|
|
211 doing a good job here.
|
|
212 1. The function is not inlined (too complicated?)
|
|
213 2. It seems to be reloading the crb and drb variables all the
|
|
214 time.
|
|
215 3. It doesn't seem to notice that the second half of these if's
|
|
216 are really a switch statement.
|
|
217
|
|
218 So I (JV) conjecture
|
|
219
|
|
220 #### It would really be worth it to arrange for this function to
|
|
221 be (almost) a single call to memcmp. */
|
434
|
222
|
442
|
223 if (crb->xpos != drb->xpos)
|
428
|
224 return 0;
|
|
225 else if (crb->width != drb->width)
|
|
226 return 0;
|
|
227 else if (crb->cursor_type != drb->cursor_type)
|
|
228 return 0;
|
|
229 else if (crb->type != drb->type)
|
|
230 return 0;
|
|
231 else if (crb->type == RUNE_CHAR &&
|
|
232 (crb->object.chr.ch != drb->object.chr.ch))
|
|
233 return 0;
|
|
234 else if (crb->type == RUNE_HLINE &&
|
|
235 (crb->object.hline.thickness != drb->object.hline.thickness ||
|
|
236 crb->object.hline.yoffset != drb->object.hline.yoffset))
|
|
237 return 0;
|
434
|
238 else if (crb->type == RUNE_DGLYPH &&
|
428
|
239 (!EQ (crb->object.dglyph.glyph, drb->object.dglyph.glyph) ||
|
|
240 !EQ (crb->object.dglyph.extent, drb->object.dglyph.extent) ||
|
819
|
241 crb->object.dglyph.xoffset != drb->object.dglyph.xoffset ||
|
|
242 crb->object.dglyph.yoffset != drb->object.dglyph.yoffset ||
|
4187
|
243 crb->object.dglyph.ascent != drb->object.dglyph.ascent ||
|
|
244 crb->object.dglyph.descent != drb->object.dglyph.descent))
|
428
|
245 return 0;
|
|
246 /* Only check dirtiness if we know something has changed. */
|
|
247 else if (crb->type == RUNE_DGLYPH &&
|
442
|
248 (XGLYPH_DIRTYP (crb->object.dglyph.glyph) ||
|
|
249 crb->findex != drb->findex))
|
428
|
250 {
|
442
|
251 /* We need some way of telling redisplay_output_layout () that the
|
4187
|
252 only reason we are outputting it is because something has
|
|
253 changed internally. That way we can optimize whether we need
|
|
254 to clear the layout first and also only output the components
|
|
255 that have changed. The image_instance dirty flag and
|
|
256 display_hash are no good to us because these will invariably
|
|
257 have been set anyway if the layout has changed. So it looks
|
|
258 like we need yet another change flag that we can set here and
|
|
259 then clear in redisplay_output_layout (). */
|
442
|
260 Lisp_Object window, image;
|
|
261 Lisp_Image_Instance* ii;
|
793
|
262 window = wrap_window (w);
|
442
|
263 image = glyph_image_instance (crb->object.dglyph.glyph,
|
793
|
264 window, ERROR_ME_DEBUG_WARN, 1);
|
442
|
265
|
|
266 if (!IMAGE_INSTANCEP (image))
|
|
267 return 0;
|
|
268 ii = XIMAGE_INSTANCE (image);
|
|
269
|
|
270 if (TEXT_IMAGE_INSTANCEP (image) &&
|
|
271 (crb->findex != drb->findex ||
|
|
272 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex)))
|
428
|
273 return 0;
|
442
|
274
|
|
275 /* It is quite common for the two glyphs to be EQ since in many
|
|
276 cases they will actually be the same object. This does not
|
|
277 mean, however, that nothing has changed. We therefore need to
|
|
278 check the current hash of the glyph against the last recorded
|
|
279 display hash and the pending display items. See
|
|
280 update_subwindow (). */
|
|
281 if (image_instance_changed (image) ||
|
|
282 crb->findex != drb->findex ||
|
|
283 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex))
|
|
284 {
|
638
|
285 /* Now we are going to re-output the glyph, but since
|
442
|
286 this is for some internal reason not related to geometry
|
|
287 changes, send a hint to the output routines that they can
|
|
288 take some short cuts. This is most useful for
|
|
289 layouts. This flag should get reset by the output
|
|
290 routines.
|
|
291
|
|
292 #### It is possible for us to get here when the
|
|
293 face_cachel is dirty. I do not know what the implications
|
|
294 of this are.*/
|
|
295 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (ii) = 1;
|
|
296 return 0;
|
|
297 }
|
434
|
298 else
|
428
|
299 return 1;
|
|
300 }
|
442
|
301 /* We now do this last so that glyph checks can do their own thing
|
|
302 for face changes. Face changes quite often happen when we are
|
|
303 trying to output something in the gutter, this would normally
|
|
304 lead to a lot of flashing. The indices can quite often be
|
|
305 different and yet the faces are the same, we do not want to
|
|
306 re-output in this instance. */
|
|
307 else if (crb->findex != drb->findex ||
|
|
308 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex))
|
|
309 return 0;
|
428
|
310 else
|
|
311 return 1;
|
|
312 }
|
|
313
|
851
|
314 #if 0
|
|
315 void
|
|
316 compare_runes_2 (struct window *w, struct rune *crb, struct rune *drb)
|
|
317 {
|
|
318 if (crb->type == DGLYPH)
|
|
319 {
|
|
320 if (!EQ (crb->object.dglyph.glyph, drb->object.dglyph.glyph) ||
|
|
321 !EQ (crb->object.dglyph.extent, drb->object.dglyph.extent) ||
|
|
322 crb->object.dglyph.xoffset != drb->object.dglyph.xoffset ||
|
|
323 crb->object.dglyph.yoffset != drb->object.dglyph.yoffset ||
|
|
324 crb->object.dglyph.ascent != drb->object.dglyph.ascent ||
|
|
325 crb->object.dglyph.descent != drb->object.dglyph.descent)
|
|
326 return 0;
|
|
327 /* Only check dirtiness if we know something has changed. */
|
|
328 else if (XGLYPH_DIRTYP (crb->object.dglyph.glyph) ||
|
|
329 crb->findex != drb->findex)
|
|
330 {
|
|
331 /* We need some way of telling redisplay_output_layout () that the
|
|
332 only reason we are outputting it is because something has
|
|
333 changed internally. That way we can optimize whether we need
|
|
334 to clear the layout first and also only output the components
|
|
335 that have changed. The image_instance dirty flag and
|
|
336 display_hash are no good to us because these will invariably
|
|
337 have been set anyway if the layout has changed. So it looks
|
|
338 like we need yet another change flag that we can set here and
|
|
339 then clear in redisplay_output_layout (). */
|
|
340 Lisp_Object window, image;
|
|
341 Lisp_Image_Instance* ii;
|
|
342 window = wrap_window (w);
|
|
343 image = glyph_image_instance (crb->object.dglyph.glyph,
|
|
344 window, crb->object.dglyph.matchspec,
|
|
345 ERROR_ME_DEBUG_WARN, 1);
|
4187
|
346
|
851
|
347 if (!IMAGE_INSTANCEP (image))
|
|
348 return 0;
|
|
349 ii = XIMAGE_INSTANCE (image);
|
4187
|
350
|
851
|
351 if (TEXT_IMAGE_INSTANCEP (image) &&
|
|
352 (crb->findex != drb->findex ||
|
|
353 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex)))
|
|
354 return 0;
|
4187
|
355
|
851
|
356 /* It is quite common for the two glyphs to be EQ since in many
|
|
357 cases they will actually be the same object. This does not
|
|
358 mean, however, that nothing has changed. We therefore need to
|
|
359 check the current hash of the glyph against the last recorded
|
|
360 display hash and the pending display items. See
|
|
361 update_widget () ^^#### which function?. */
|
|
362 if (image_instance_changed (image) ||
|
|
363 crb->findex != drb->findex ||
|
|
364 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex))
|
|
365 {
|
|
366 /* Now we are going to re-output the glyph, but since
|
|
367 this is for some internal reason not related to geometry
|
|
368 changes, send a hint to the output routines that they can
|
|
369 take some short cuts. This is most useful for
|
|
370 layouts. This flag should get reset by the output
|
|
371 routines.
|
4187
|
372
|
851
|
373 #### It is possible for us to get here when the
|
|
374 face_cachel is dirty. I do not know what the implications
|
|
375 of this are.*/
|
|
376 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (ii) = 1;
|
|
377 return 0;
|
|
378 }
|
|
379 else
|
|
380 return 1;
|
|
381 }
|
|
382 else if (crb->findex != drb->findex ||
|
|
383 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex))
|
|
384 return 0;
|
|
385 else
|
|
386 return 1;
|
|
387 }
|
|
388 else return !(memcmp (crb, drb, sizeof (*crb)) ||
|
|
389 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex));
|
|
390 }
|
|
391 #endif
|
|
392
|
|
393
|
428
|
394 /*****************************************************************************
|
|
395 get_next_display_block
|
|
396
|
|
397 Return the next display starting at or overlapping START_POS. Return
|
|
398 the start of the next region in NEXT_START.
|
|
399 ****************************************************************************/
|
|
400 int
|
|
401 get_next_display_block (layout_bounds bounds, display_block_dynarr *dba,
|
|
402 int start_pos, int *next_start)
|
|
403 {
|
|
404 int next_display_block = NO_BLOCK;
|
|
405 int priority = -1;
|
|
406 int block;
|
|
407
|
|
408 /* If we don't find a display block covering or starting at
|
|
409 start_pos, then we return the starting point of the next display
|
|
410 block or the next division boundary, whichever is closer to
|
|
411 start_pos. */
|
|
412 if (next_start)
|
|
413 {
|
|
414 if (start_pos >= bounds.left_out && start_pos < bounds.left_in)
|
|
415 *next_start = bounds.left_in;
|
|
416 else if (start_pos < bounds.left_white)
|
|
417 *next_start = bounds.left_white;
|
|
418 else if (start_pos < bounds.right_white)
|
|
419 *next_start = bounds.right_white;
|
|
420 else if (start_pos < bounds.right_in)
|
|
421 *next_start = bounds.right_in;
|
|
422 else if (start_pos <= bounds.right_out)
|
|
423 *next_start = bounds.right_out;
|
|
424 else
|
2500
|
425 ABORT ();
|
428
|
426 }
|
|
427
|
|
428 for (block = 0; block < Dynarr_length (dba); block++)
|
|
429 {
|
|
430 struct display_block *db = Dynarr_atp (dba, block);
|
|
431
|
|
432 if (db->start_pos <= start_pos && db->end_pos > start_pos)
|
|
433 {
|
|
434 if ((int) db->type > priority)
|
|
435 {
|
|
436 priority = db->type;
|
|
437 next_display_block = block;
|
|
438 if (next_start)
|
|
439 *next_start = db->end_pos;
|
|
440 }
|
|
441 }
|
|
442 else if (next_start && db->start_pos > start_pos)
|
|
443 {
|
|
444 if (db->start_pos < *next_start)
|
|
445 *next_start = db->start_pos;
|
|
446 }
|
|
447 }
|
|
448
|
|
449 return next_display_block;
|
|
450 }
|
|
451
|
|
452 /*****************************************************************************
|
|
453 get_cursor_size_and_location
|
|
454
|
|
455 Return the information defining the pixel location of the cursor.
|
|
456 ****************************************************************************/
|
|
457 static void
|
|
458 get_cursor_size_and_location (struct window *w, struct display_block *db,
|
|
459 int cursor_location,
|
|
460 int *cursor_start, int *cursor_width,
|
|
461 int *cursor_height)
|
|
462 {
|
|
463 struct rune *rb;
|
|
464 Lisp_Object window;
|
|
465 int defheight, defwidth;
|
|
466
|
|
467 if (Dynarr_length (db->runes) <= cursor_location)
|
2500
|
468 ABORT ();
|
428
|
469
|
793
|
470 window = wrap_window (w);
|
428
|
471
|
|
472 rb = Dynarr_atp (db->runes, cursor_location);
|
|
473 *cursor_start = rb->xpos;
|
|
474
|
|
475 default_face_height_and_width (window, &defheight, &defwidth);
|
|
476 *cursor_height = defheight;
|
|
477
|
|
478 if (rb->type == RUNE_BLANK)
|
|
479 *cursor_width = defwidth;
|
|
480 else
|
|
481 *cursor_width = rb->width;
|
|
482 }
|
|
483
|
|
484 /*****************************************************************************
|
|
485 compare_display_blocks
|
|
486
|
|
487 Given two display blocks, output only those areas where they differ.
|
|
488 ****************************************************************************/
|
|
489 static int
|
|
490 compare_display_blocks (struct window *w, struct display_line *cdl,
|
|
491 struct display_line *ddl, int c_block, int d_block,
|
|
492 int start_pixpos, int cursor_start, int cursor_width,
|
|
493 int cursor_height)
|
|
494 {
|
|
495 struct frame *f = XFRAME (w->frame);
|
|
496 struct display_block *cdb, *ddb;
|
|
497 int start_pos;
|
|
498 int stop_pos;
|
|
499 int force = 0;
|
2286
|
500 #if 0
|
428
|
501 int block_end;
|
2286
|
502 #endif
|
428
|
503
|
|
504 cdb = Dynarr_atp (cdl->display_blocks, c_block);
|
|
505 ddb = Dynarr_atp (ddl->display_blocks, d_block);
|
|
506
|
|
507 assert (cdb->type == ddb->type);
|
|
508
|
|
509 start_pos = -1;
|
|
510 stop_pos = min (Dynarr_length (cdb->runes), Dynarr_length (ddb->runes));
|
|
511
|
2286
|
512 #if 0
|
428
|
513 block_end =
|
|
514 (!Dynarr_length (ddb->runes)
|
|
515 ? 0
|
|
516 : (Dynarr_atp (ddb->runes, Dynarr_length (ddb->runes) - 1)->xpos +
|
|
517 Dynarr_atp (ddb->runes, Dynarr_length (ddb->runes) - 1)->width));
|
2286
|
518 #endif
|
428
|
519
|
|
520 /* If the new block type is not text and the cursor status is
|
|
521 changing and it overlaps the position of this block then force a
|
|
522 full redraw of the block in order to make sure that the cursor is
|
|
523 updated properly. */
|
|
524 if (ddb->type != TEXT
|
|
525 #if 0
|
|
526 /* I'm not sure exactly what this code wants to do, but it's
|
|
527 * not right--it doesn't update when cursor_elt changes from, e.g.,
|
|
528 * 0 to 8, and the new or old cursor loc overlaps this block.
|
|
529 * I've replaced it with the more conservative test below.
|
|
530 * -dkindred@cs.cmu.edu 23-Mar-1997 */
|
|
531 && ((cdl->cursor_elt == -1 && ddl->cursor_elt != -1)
|
|
532 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1))
|
|
533 && (ddl->cursor_elt == -1 ||
|
|
534 (cursor_start
|
|
535 && cursor_width
|
|
536 && (cursor_start + cursor_width) >= start_pixpos
|
|
537 && cursor_start <= block_end))
|
|
538 #else
|
|
539 && (cdl->cursor_elt != ddl->cursor_elt)
|
|
540 #endif
|
|
541 )
|
|
542 force = 1;
|
|
543
|
|
544 if (f->windows_structure_changed ||
|
|
545 /* #### Why is this so? We have face cachels so that we don't
|
4187
|
546 have to recalculate all the display blocks when faces
|
|
547 change. I have fixed this for glyphs and am inclined to think
|
|
548 that faces should "Just Work", but I'm not feeling brave
|
|
549 today. Maybe its because the face cachels represent merged
|
|
550 faces rather than simply instantiations in a particular
|
|
551 domain. */
|
428
|
552 f->faces_changed ||
|
|
553 cdl->ypos != ddl->ypos ||
|
|
554 cdl->ascent != ddl->ascent ||
|
|
555 cdl->descent != ddl->descent ||
|
|
556 cdl->clip != ddl->clip ||
|
|
557 force)
|
|
558 {
|
|
559 start_pos = 0;
|
|
560 force = 1;
|
|
561 }
|
|
562 else
|
|
563 {
|
|
564 int elt = 0;
|
|
565
|
|
566 while (start_pos < 0 && elt < stop_pos)
|
|
567 {
|
|
568 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
569 Dynarr_atp (ddb->runes, elt)))
|
|
570 {
|
|
571 start_pos = elt;
|
|
572 }
|
|
573 else
|
|
574 {
|
|
575 elt++;
|
|
576 }
|
|
577 }
|
|
578
|
|
579 /* If nothing has changed in the area where the blocks overlap, but
|
|
580 there are new blocks in the desired block, then adjust the start
|
|
581 point accordingly. */
|
|
582 if (elt == stop_pos && stop_pos < Dynarr_length (ddb->runes))
|
|
583 start_pos = stop_pos;
|
|
584 }
|
|
585
|
|
586 if (start_pos >= 0)
|
|
587 {
|
|
588 if ((Dynarr_length (ddb->runes) != Dynarr_length (cdb->runes))
|
|
589 || force)
|
|
590 {
|
|
591 stop_pos = Dynarr_length (ddb->runes);
|
|
592 }
|
|
593 else
|
|
594 {
|
|
595 /* If the lines have the same number of runes and we are not
|
|
596 forcing a full redraw because the display line has
|
|
597 changed position then we try and optimize how much of the
|
|
598 line we actually redraw by scanning backwards from the
|
|
599 end for the first changed rune. This optimization is
|
|
600 almost always triggered by face changes. */
|
|
601
|
|
602 int elt = Dynarr_length (ddb->runes) - 1;
|
|
603
|
|
604 while (elt > start_pos)
|
|
605 {
|
|
606 if (!compare_runes (w, Dynarr_atp (cdb->runes, elt),
|
|
607 Dynarr_atp (ddb->runes, elt)))
|
|
608 break;
|
|
609 else
|
|
610 elt--;
|
|
611 }
|
|
612 stop_pos = elt + 1;
|
|
613 }
|
|
614
|
|
615 redisplay_output_display_block (w, ddl, d_block, start_pos,
|
|
616 stop_pos, start_pixpos,
|
|
617 cursor_start, cursor_width,
|
|
618 cursor_height);
|
|
619 return 1;
|
|
620 }
|
|
621
|
|
622 return 0;
|
|
623 }
|
|
624
|
|
625 /*****************************************************************************
|
|
626 clear_left_border
|
|
627
|
|
628 Clear the lefthand outside border.
|
|
629 ****************************************************************************/
|
|
630 static void
|
|
631 clear_left_border (struct window *w, int y, int height)
|
|
632 {
|
|
633 struct frame *f = XFRAME (w->frame);
|
793
|
634 Lisp_Object window = wrap_window (w);
|
428
|
635
|
|
636 redisplay_clear_region (window, DEFAULT_INDEX,
|
|
637 FRAME_LEFT_BORDER_START (f), y,
|
|
638 FRAME_BORDER_WIDTH (f), height);
|
|
639 }
|
|
640
|
|
641 /*****************************************************************************
|
|
642 clear_right_border
|
|
643
|
|
644 Clear the righthand outside border.
|
|
645 ****************************************************************************/
|
|
646 static void
|
|
647 clear_right_border (struct window *w, int y, int height)
|
|
648 {
|
|
649 struct frame *f = XFRAME (w->frame);
|
793
|
650 Lisp_Object window = wrap_window (w);
|
428
|
651
|
|
652 redisplay_clear_region (window, DEFAULT_INDEX,
|
|
653 FRAME_RIGHT_BORDER_START (f),
|
|
654 y, FRAME_BORDER_WIDTH (f), height);
|
|
655 }
|
|
656
|
|
657 /*****************************************************************************
|
|
658 output_display_line
|
|
659
|
|
660 Ensure that the contents of the given display line is correct
|
|
661 on-screen. The force_ parameters are used by redisplay_move_cursor
|
|
662 to correctly update cursor locations and only cursor locations.
|
|
663 ****************************************************************************/
|
|
664 void
|
|
665 output_display_line (struct window *w, display_line_dynarr *cdla,
|
|
666 display_line_dynarr *ddla, int line, int force_start,
|
|
667 int force_end)
|
|
668
|
|
669 {
|
|
670 struct frame *f = XFRAME (w->frame);
|
|
671 struct buffer *b = XBUFFER (w->buffer);
|
|
672 struct buffer *old_b = window_display_buffer (w);
|
|
673 struct display_line *cdl, *ddl;
|
|
674 display_block_dynarr *cdba, *ddba;
|
|
675 int start_pixpos, end_pixpos;
|
|
676 int cursor_start, cursor_width, cursor_height;
|
|
677
|
|
678 int force = (force_start >= 0 || force_end >= 0);
|
|
679 int clear_border = 0;
|
|
680 int must_sync = 0;
|
|
681
|
|
682 if (cdla && line < Dynarr_length (cdla))
|
|
683 {
|
|
684 cdl = Dynarr_atp (cdla, line);
|
|
685 cdba = cdl->display_blocks;
|
|
686 }
|
|
687 else
|
|
688 {
|
|
689 cdl = NULL;
|
|
690 cdba = NULL;
|
|
691 }
|
|
692
|
|
693 ddl = Dynarr_atp (ddla, line); /* assert line < Dynarr_length (ddla) */
|
|
694 ddba = ddl->display_blocks;
|
|
695
|
|
696 if (force_start >= 0 && force_start >= ddl->bounds.left_out)
|
|
697 start_pixpos = force_start;
|
|
698 else
|
|
699 start_pixpos = ddl->bounds.left_out;
|
|
700
|
|
701 if (force_end >= 0 && force_end < ddl->bounds.right_out)
|
|
702 end_pixpos = force_end;
|
|
703 else
|
|
704 end_pixpos = ddl->bounds.right_out;
|
|
705
|
|
706 /* Get the cursor parameters. */
|
|
707 if (ddl->cursor_elt != -1)
|
|
708 {
|
|
709 struct display_block *db;
|
|
710
|
|
711 /* If the lines cursor parameter is not -1 then it indicates
|
4187
|
712 which rune in the TEXT block contains the cursor. This means
|
|
713 that there must be at least one display block. The TEXT
|
|
714 block, if present, must always be the first display block. */
|
428
|
715 assert (Dynarr_length (ddba) != 0);
|
|
716
|
|
717 db = Dynarr_atp (ddba, 0);
|
|
718 assert (db->type == TEXT);
|
|
719
|
|
720 get_cursor_size_and_location (w, db, ddl->cursor_elt, &cursor_start,
|
|
721 &cursor_width, &cursor_height);
|
|
722 }
|
|
723 else
|
|
724 {
|
|
725 cursor_start = cursor_width = cursor_height = 0;
|
|
726 }
|
|
727
|
|
728 /* The modeline should only have a single block and it had better be
|
|
729 a TEXT block. */
|
|
730 if (ddl->modeline)
|
|
731 {
|
|
732 /* The shadow thickness check is necessary if only the sign of
|
4187
|
733 the size changed. */
|
428
|
734 if (cdba && !w->shadow_thickness_changed)
|
|
735 {
|
|
736 must_sync |= compare_display_blocks (w, cdl, ddl, 0, 0,
|
|
737 start_pixpos, 0, 0, 0);
|
|
738 }
|
|
739 else
|
|
740 {
|
|
741 redisplay_output_display_block (w, ddl, 0, 0, -1, start_pixpos,
|
|
742 0, 0, 0);
|
|
743 must_sync = 1;
|
|
744 }
|
|
745
|
|
746 if (must_sync)
|
|
747 clear_border = 1;
|
|
748 }
|
|
749
|
|
750 while (!ddl->modeline && start_pixpos < end_pixpos)
|
|
751 {
|
|
752 int block;
|
|
753 int next_start_pixpos;
|
|
754
|
|
755 block = get_next_display_block (ddl->bounds, ddba, start_pixpos,
|
|
756 &next_start_pixpos);
|
|
757
|
|
758 /* If we didn't find a block then we should blank the area
|
4187
|
759 between start_pos and next_start if necessary. */
|
428
|
760 if (block == NO_BLOCK)
|
|
761 {
|
|
762 /* We only erase those areas which were actually previously
|
4187
|
763 covered by a display block unless the window structure
|
|
764 changed. In that case we clear all areas since the current
|
|
765 structures may actually represent a different buffer. */
|
428
|
766 while (start_pixpos < next_start_pixpos)
|
|
767 {
|
|
768 int block_end;
|
|
769 int old_block;
|
|
770
|
|
771 if (cdba)
|
|
772 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
773 start_pixpos, &block_end);
|
|
774 else
|
|
775 {
|
|
776 old_block = NO_BLOCK;
|
|
777 block_end = next_start_pixpos;
|
|
778 }
|
|
779
|
|
780 if (!cdba || old_block != NO_BLOCK || b != old_b ||
|
|
781 f->windows_structure_changed ||
|
|
782 f->faces_changed ||
|
|
783 force ||
|
|
784 (cdl && (cdl->ypos != ddl->ypos ||
|
|
785 cdl->ascent != ddl->ascent ||
|
|
786 cdl->descent != ddl->descent ||
|
|
787 cdl->top_clip != ddl->top_clip ||
|
|
788 cdl->clip != ddl->clip)))
|
|
789 {
|
|
790 int x, y, width, height;
|
|
791 face_index findex;
|
|
792
|
|
793 must_sync = 1;
|
|
794 x = start_pixpos;
|
|
795 y = DISPLAY_LINE_YPOS (ddl);
|
|
796 width = min (next_start_pixpos, block_end) - x;
|
|
797 height = DISPLAY_LINE_HEIGHT (ddl);
|
|
798
|
|
799 if (x < ddl->bounds.left_in)
|
|
800 {
|
4187
|
801 findex = (ddl->left_margin_findex > DEFAULT_INDEX) ?
|
434
|
802 ddl->left_margin_findex
|
428
|
803 : get_builtin_face_cache_index (w, Vleft_margin_face);
|
|
804 }
|
|
805 else if (x < ddl->bounds.right_in)
|
|
806 {
|
4187
|
807 findex = (ddl->default_findex >= DEFAULT_INDEX) ?
|
|
808 ddl->default_findex
|
|
809 : DEFAULT_INDEX;
|
428
|
810 }
|
|
811 else if (x < ddl->bounds.right_out)
|
|
812 {
|
4187
|
813 findex = (ddl->right_margin_findex > DEFAULT_INDEX) ?
|
434
|
814 ddl->right_margin_findex
|
428
|
815 : get_builtin_face_cache_index (w, Vright_margin_face);
|
|
816 }
|
|
817 else
|
|
818 findex = (face_index) -1;
|
|
819
|
|
820 if (findex != (face_index) -1)
|
|
821 {
|
793
|
822 Lisp_Object window = wrap_window (w);
|
428
|
823
|
|
824
|
|
825 /* Clear the empty area. */
|
|
826 redisplay_clear_region (window, findex, x, y, width, height);
|
|
827
|
|
828 /* Mark that we should clear the border. This is
|
|
829 necessary because italic fonts may leave
|
|
830 droppings in the border. */
|
|
831 clear_border = 1;
|
|
832 }
|
|
833 }
|
|
834
|
|
835 start_pixpos = min (next_start_pixpos, block_end);
|
|
836 }
|
|
837 }
|
|
838 else
|
|
839 {
|
|
840 struct display_block *cdb, *ddb;
|
|
841 int block_end;
|
|
842 int old_block;
|
|
843
|
|
844 if (cdba)
|
|
845 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
846 start_pixpos, &block_end);
|
|
847 else
|
|
848 old_block = NO_BLOCK;
|
|
849
|
|
850 ddb = Dynarr_atp (ddba, block);
|
|
851 cdb = (old_block != NO_BLOCK ? Dynarr_atp (cdba, old_block) : 0);
|
|
852
|
|
853 /* If there was formerly no block over the current
|
|
854 region or if it was a block of a different type, then
|
|
855 output the entire ddb. Otherwise, compare cdb and
|
|
856 ddb and output only the changed region. */
|
434
|
857 if (!force && cdb && ddb->type == cdb->type
|
428
|
858 /* If there was no buffer being display before the
|
4187
|
859 compare anyway as we might be outputting a gutter. */
|
434
|
860 &&
|
428
|
861 (b == old_b || !old_b))
|
|
862 {
|
|
863 must_sync |= compare_display_blocks (w, cdl, ddl, old_block,
|
|
864 block, start_pixpos,
|
|
865 cursor_start, cursor_width,
|
|
866 cursor_height);
|
|
867 }
|
|
868 else
|
|
869 {
|
|
870 int elt;
|
|
871 int first_elt = 0;
|
|
872 int last_elt = -1;
|
|
873
|
|
874 for (elt = 0; elt < Dynarr_length (ddb->runes); elt++)
|
|
875 {
|
|
876 struct rune *rb = Dynarr_atp (ddb->runes, elt);
|
|
877
|
|
878 if (start_pixpos >= rb->xpos
|
|
879 && start_pixpos < rb->xpos + rb->width)
|
|
880 first_elt = elt;
|
|
881
|
|
882 if (end_pixpos > rb->xpos
|
|
883 && end_pixpos <= rb->xpos + rb->width)
|
|
884 {
|
|
885 last_elt = elt + 1;
|
|
886 if (last_elt > Dynarr_length (ddb->runes))
|
|
887 last_elt = Dynarr_length (ddb->runes);
|
|
888 break;
|
|
889 }
|
|
890 }
|
|
891
|
|
892 must_sync = 1;
|
|
893 redisplay_output_display_block (w, ddl, block, first_elt,
|
|
894 last_elt,
|
|
895 start_pixpos,
|
|
896 cursor_start, cursor_width,
|
|
897 cursor_height);
|
|
898 }
|
434
|
899
|
428
|
900 start_pixpos = next_start_pixpos;
|
|
901 }
|
|
902 }
|
|
903
|
|
904 /* Clear the internal border if we are next to it and the window
|
|
905 structure or frame size has changed or if something caused
|
|
906 clear_border to be tripped. */
|
|
907 /* #### Doing this on f->clear sucks but is necessary because of
|
|
908 window-local background values. */
|
|
909 if (f->windows_structure_changed || f->faces_changed || clear_border
|
|
910 || f->clear)
|
|
911 {
|
|
912 int y = DISPLAY_LINE_YPOS (ddl);
|
|
913 int height = DISPLAY_LINE_HEIGHT (ddl);
|
|
914
|
|
915 /* If we are in the gutter then we musn't clear the borders. */
|
|
916 if (y >= WINDOW_TEXT_TOP (w) && (y + height) <= WINDOW_TEXT_BOTTOM (w))
|
|
917 {
|
|
918 if (ddl->modeline)
|
|
919 {
|
|
920 y -= MODELINE_SHADOW_THICKNESS (w);
|
|
921 height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
922 }
|
434
|
923
|
428
|
924 if (window_is_leftmost (w))
|
|
925 clear_left_border (w, y, height);
|
|
926 if (window_is_rightmost (w))
|
|
927 clear_right_border (w, y, height);
|
|
928 }
|
|
929 }
|
|
930
|
|
931 if (cdla)
|
|
932 sync_display_line_structs (w, line, must_sync, cdla, ddla);
|
|
933 }
|
|
934
|
|
935 /*****************************************************************************
|
|
936 redisplay_move_cursor
|
|
937
|
|
938 For the given window W, move the cursor to NEW_POINT. Returns a
|
|
939 boolean indicating success or failure.
|
|
940 ****************************************************************************/
|
|
941
|
826
|
942 #define ADJ_CHARPOS (rb->charpos + dl->offset)
|
428
|
943 #define ADJ_ENDPOS (rb->endpos + dl->offset)
|
|
944
|
|
945 int
|
665
|
946 redisplay_move_cursor (struct window *w, Charbpos new_point, int no_output_end)
|
428
|
947 {
|
|
948 struct frame *f = XFRAME (w->frame);
|
|
949 struct device *d = XDEVICE (f->device);
|
|
950
|
|
951 display_line_dynarr *cla = window_display_lines (w, CURRENT_DISP);
|
|
952 struct display_line *dl;
|
|
953 struct display_block *db;
|
|
954 struct rune *rb;
|
|
955 int x = w->last_point_x[CURRENT_DISP];
|
|
956 int y = w->last_point_y[CURRENT_DISP];
|
|
957
|
|
958 /*
|
|
959 * Bail if cursor_in_echo_area is non-zero and we're fiddling with
|
|
960 * the cursor in a non-active minibuffer window, since that is a
|
|
961 * special case that is handled elsewhere and this function need
|
|
962 * not handle it. Return 1 so the caller will assume we
|
|
963 * succeeded.
|
|
964 */
|
|
965 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
966 w != XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
|
967 return 1;
|
|
968
|
|
969 if (y < 0 || y >= Dynarr_length (cla))
|
|
970 return 0;
|
|
971
|
|
972 dl = Dynarr_atp (cla, y);
|
|
973 db = get_display_block_from_line (dl, TEXT);
|
|
974
|
|
975 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
976 return 0;
|
|
977
|
|
978 rb = Dynarr_atp (db->runes, x);
|
|
979
|
|
980 if (rb->cursor_type == CURSOR_OFF)
|
|
981 return 0;
|
826
|
982 else if (ADJ_CHARPOS == new_point
|
|
983 || (ADJ_ENDPOS && (new_point >= ADJ_CHARPOS)
|
428
|
984 && (new_point <= ADJ_ENDPOS)))
|
|
985 {
|
|
986 w->last_point_x[CURRENT_DISP] = x;
|
|
987 w->last_point_y[CURRENT_DISP] = y;
|
826
|
988 Fset_marker (w->last_point[CURRENT_DISP], make_int (ADJ_CHARPOS),
|
428
|
989 w->buffer);
|
|
990 dl->cursor_elt = x;
|
|
991 return 1;
|
|
992 }
|
|
993 else
|
|
994 {
|
442
|
995 {
|
|
996 MAYBE_DEVMETH (d, frame_output_begin, (f));
|
|
997 MAYBE_DEVMETH (d, window_output_begin, (w));
|
|
998 }
|
|
999 rb->cursor_type = CURSOR_OFF;
|
428
|
1000 dl->cursor_elt = -1;
|
|
1001 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
1002 }
|
|
1003
|
|
1004 w->last_point_x[CURRENT_DISP] = -1;
|
|
1005 w->last_point_y[CURRENT_DISP] = -1;
|
|
1006 Fset_marker (w->last_point[CURRENT_DISP], Qnil, w->buffer);
|
|
1007
|
|
1008 /* If this isn't the selected frame, then erasing the old cursor is
|
|
1009 all we actually had to do. */
|
|
1010 if (w != XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
|
1011 {
|
|
1012 if (!no_output_end)
|
442
|
1013 {
|
|
1014 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1015 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1016 }
|
428
|
1017
|
|
1018 return 1;
|
|
1019 }
|
|
1020
|
|
1021 /* This should only occur in the minibuffer. */
|
|
1022 if (new_point == 0)
|
|
1023 {
|
|
1024 w->last_point_x[CURRENT_DISP] = 0;
|
|
1025 w->last_point_y[CURRENT_DISP] = y;
|
|
1026 Fset_marker (w->last_point[CURRENT_DISP], Qzero, w->buffer);
|
|
1027
|
|
1028 rb = Dynarr_atp (db->runes, 0);
|
|
1029 rb->cursor_type = CURSOR_ON;
|
|
1030 dl->cursor_elt = 0;
|
|
1031
|
|
1032 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
1033
|
|
1034 if (!no_output_end)
|
442
|
1035 {
|
|
1036 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1037 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1038 }
|
428
|
1039 return 1;
|
|
1040 }
|
|
1041 else
|
|
1042 {
|
|
1043 int cur_rb = 0;
|
|
1044 int first = 0;
|
|
1045 int cur_dl, up;
|
|
1046
|
826
|
1047 if (ADJ_CHARPOS < new_point)
|
428
|
1048 {
|
|
1049 up = 1;
|
|
1050 cur_rb = x + 1;
|
|
1051 cur_dl = y;
|
|
1052 }
|
665
|
1053 else /* (rb->charbpos + dl->offset) > new_point */
|
428
|
1054 {
|
|
1055 up = 0;
|
|
1056
|
|
1057 if (!x)
|
|
1058 {
|
|
1059 cur_dl = y - 1;
|
|
1060 first = 0;
|
|
1061 }
|
|
1062 else
|
|
1063 {
|
|
1064 cur_rb = x - 1;
|
|
1065 cur_dl = y;
|
|
1066 first = 1;
|
|
1067 }
|
|
1068 }
|
|
1069
|
434
|
1070 while (up ? (cur_dl < Dynarr_length (cla)) : (cur_dl >= 0))
|
428
|
1071 {
|
|
1072 dl = Dynarr_atp (cla, cur_dl);
|
|
1073 db = get_display_block_from_line (dl, TEXT);
|
|
1074
|
|
1075 if (!up && !first)
|
|
1076 cur_rb = Dynarr_length (db->runes) - 1;
|
|
1077
|
|
1078 while ((!scroll_on_clipped_lines || !dl->clip) &&
|
|
1079 (up ? (cur_rb < Dynarr_length (db->runes)) : (cur_rb >= 0)))
|
|
1080 {
|
|
1081 rb = Dynarr_atp (db->runes, cur_rb);
|
|
1082
|
|
1083 if (rb->cursor_type != IGNORE_CURSOR
|
|
1084 && rb->cursor_type != NO_CURSOR &&
|
826
|
1085 (ADJ_CHARPOS == new_point
|
|
1086 || (ADJ_ENDPOS && (new_point >= ADJ_CHARPOS)
|
|
1087 && (new_point <= ADJ_CHARPOS))))
|
428
|
1088 {
|
|
1089 rb->cursor_type = CURSOR_ON;
|
|
1090 dl->cursor_elt = cur_rb;
|
|
1091
|
|
1092
|
|
1093 output_display_line (w, 0, cla, cur_dl, rb->xpos,
|
|
1094 rb->xpos + rb->width);
|
|
1095
|
|
1096 w->last_point_x[CURRENT_DISP] = cur_rb;
|
|
1097 w->last_point_y[CURRENT_DISP] = cur_dl;
|
|
1098 Fset_marker (w->last_point[CURRENT_DISP],
|
826
|
1099 make_int (ADJ_CHARPOS), w->buffer);
|
428
|
1100
|
|
1101 if (!no_output_end)
|
442
|
1102 {
|
|
1103 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1104 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1105 }
|
428
|
1106 return 1;
|
|
1107 }
|
|
1108
|
|
1109 (up ? cur_rb++ : cur_rb--);
|
|
1110 }
|
|
1111
|
|
1112 (up ? (cur_rb = 0) : (first = 0));
|
|
1113 (up ? cur_dl++ : cur_dl--);
|
|
1114 }
|
|
1115 }
|
|
1116
|
|
1117 if (!no_output_end)
|
442
|
1118 {
|
|
1119 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1120 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1121 }
|
428
|
1122 return 0;
|
|
1123 }
|
826
|
1124 #undef ADJ_CHARPOS
|
428
|
1125 #undef ADJ_ENDPOS
|
|
1126
|
|
1127 /*****************************************************************************
|
|
1128 redraw_cursor_in_window
|
|
1129
|
|
1130 For the given window W, redraw the cursor if it is contained within
|
|
1131 the window.
|
|
1132 ****************************************************************************/
|
|
1133 static void
|
|
1134 redraw_cursor_in_window (struct window *w, int run_end_begin_meths)
|
|
1135 {
|
|
1136 struct frame *f = XFRAME (w->frame);
|
|
1137 struct device *d = XDEVICE (f->device);
|
|
1138
|
|
1139 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
1140 struct display_line *dl;
|
|
1141 struct display_block *db;
|
|
1142 struct rune *rb;
|
|
1143
|
|
1144 int x = w->last_point_x[CURRENT_DISP];
|
|
1145 int y = w->last_point_y[CURRENT_DISP];
|
|
1146
|
|
1147 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
1148 !echo_area_active (f) && minibuf_level == 0)
|
|
1149 {
|
|
1150 MAYBE_DEVMETH (d, set_final_cursor_coords, (f, w->pixel_top, 0));
|
|
1151 }
|
|
1152
|
|
1153 if (y < 0 || y >= Dynarr_length (dla))
|
|
1154 return;
|
|
1155
|
|
1156 if (MINI_WINDOW_P (w) && f != device_selected_frame (d) &&
|
|
1157 !is_surrogate_for_selected_frame (f))
|
|
1158 return;
|
|
1159
|
|
1160 dl = Dynarr_atp (dla, y);
|
|
1161 db = get_display_block_from_line (dl, TEXT);
|
|
1162
|
|
1163 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
1164 return;
|
|
1165
|
|
1166 rb = Dynarr_atp (db->runes, x);
|
|
1167
|
|
1168 /* Don't call the output routine if the block isn't actually the
|
|
1169 cursor. */
|
|
1170 if (rb->cursor_type == CURSOR_ON)
|
|
1171 {
|
|
1172 MAYBE_DEVMETH (d, set_final_cursor_coords,
|
|
1173 (f, dl->ypos - 1, rb->xpos));
|
|
1174
|
|
1175 if (run_end_begin_meths)
|
442
|
1176 {
|
|
1177 MAYBE_DEVMETH (d, frame_output_begin, (f));
|
|
1178 MAYBE_DEVMETH (d, window_output_begin, (w));
|
|
1179 }
|
428
|
1180
|
|
1181 output_display_line (w, 0, dla, y, rb->xpos, rb->xpos + rb->width);
|
|
1182
|
|
1183 if (run_end_begin_meths)
|
442
|
1184 {
|
|
1185 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1186 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1187 }
|
428
|
1188 }
|
|
1189 }
|
|
1190
|
|
1191 /*****************************************************************************
|
|
1192 redisplay_redraw_cursor
|
|
1193
|
|
1194 For the given frame F, redraw the cursor on the selected window.
|
|
1195 This is used to update the cursor after focus changes.
|
|
1196 ****************************************************************************/
|
|
1197 void
|
|
1198 redisplay_redraw_cursor (struct frame *f, int run_end_begin_meths)
|
|
1199 {
|
|
1200 Lisp_Object window;
|
|
1201
|
|
1202 if (!cursor_in_echo_area)
|
|
1203 window = FRAME_SELECTED_WINDOW (f);
|
|
1204 else if (FRAME_HAS_MINIBUF_P (f))
|
|
1205 window = FRAME_MINIBUF_WINDOW (f);
|
|
1206 else
|
|
1207 return;
|
|
1208
|
|
1209 redraw_cursor_in_window (XWINDOW (window), run_end_begin_meths);
|
|
1210 }
|
|
1211
|
|
1212 /****************************************************************************
|
|
1213 redisplay_output_display_block
|
|
1214
|
|
1215 Given a display line, a block number for that start line, output all
|
|
1216 runes between start and end in the specified display block.
|
|
1217 ****************************************************************************/
|
|
1218 static void
|
|
1219 redisplay_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
1220 int start, int end, int start_pixpos, int cursor_start,
|
|
1221 int cursor_width, int cursor_height)
|
|
1222 {
|
|
1223 struct frame *f = XFRAME (w->frame);
|
|
1224 struct device *d = XDEVICE (f->device);
|
442
|
1225 /* Temporarily disabled until generalization is done. */
|
|
1226 #if 0
|
428
|
1227 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
1228 rune_dynarr *rba = db->runes;
|
|
1229 struct rune *rb;
|
|
1230 int xpos, width;
|
|
1231 rb = Dynarr_atp (rba, start);
|
|
1232
|
|
1233 if (!rb)
|
|
1234 /* Nothing to do so don't do anything. */
|
|
1235 return;
|
|
1236
|
|
1237 xpos = max (start_pixpos, rb->xpos);
|
|
1238
|
|
1239 if (end < 0)
|
|
1240 end = Dynarr_length (rba);
|
|
1241
|
|
1242 rb = Dynarr_atp (rba, end - 1);
|
|
1243 width = rb->xpos + rb->width - xpos;
|
442
|
1244 #endif
|
428
|
1245 /* now actually output the block. */
|
|
1246 DEVMETH (d, output_display_block, (w, dl, block, start,
|
|
1247 end, start_pixpos,
|
|
1248 cursor_start, cursor_width,
|
|
1249 cursor_height));
|
|
1250 }
|
|
1251
|
|
1252 /****************************************************************************
|
|
1253 redisplay_unmap_subwindows
|
|
1254
|
|
1255 Remove subwindows from the area in the box defined by the given
|
|
1256 parameters.
|
|
1257 ****************************************************************************/
|
448
|
1258 static void
|
|
1259 redisplay_unmap_subwindows (struct frame* f, int x, int y, int width, int height,
|
|
1260 Lisp_Object ignored_window)
|
428
|
1261 {
|
442
|
1262 Lisp_Object rest;
|
428
|
1263
|
442
|
1264 LIST_LOOP (rest, XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f)))
|
|
1265 {
|
|
1266 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (XCAR (rest));
|
|
1267 if (IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (ii)
|
428
|
1268 &&
|
442
|
1269 IMAGE_INSTANCE_DISPLAY_X (ii)
|
|
1270 + IMAGE_INSTANCE_DISPLAY_WIDTH (ii) > x
|
428
|
1271 &&
|
442
|
1272 IMAGE_INSTANCE_DISPLAY_X (ii) < x + width
|
|
1273 &&
|
|
1274 IMAGE_INSTANCE_DISPLAY_Y (ii)
|
|
1275 + IMAGE_INSTANCE_DISPLAY_HEIGHT (ii) > y
|
434
|
1276 &&
|
442
|
1277 IMAGE_INSTANCE_DISPLAY_Y (ii) < y + height
|
|
1278 &&
|
|
1279 !EQ (XCAR (rest), ignored_window))
|
428
|
1280 {
|
442
|
1281 unmap_subwindow (XCAR (rest));
|
428
|
1282 }
|
|
1283 }
|
|
1284 }
|
|
1285
|
|
1286 /****************************************************************************
|
|
1287 redisplay_unmap_subwindows_maybe
|
|
1288
|
|
1289 Potentially subwindows from the area in the box defined by the given
|
|
1290 parameters.
|
|
1291 ****************************************************************************/
|
1279
|
1292 void
|
|
1293 redisplay_unmap_subwindows_maybe (struct frame *f, int x, int y, int width,
|
|
1294 int height)
|
428
|
1295 {
|
442
|
1296 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1297 {
|
|
1298 redisplay_unmap_subwindows (f, x, y, width, height, Qnil);
|
|
1299 }
|
|
1300 }
|
|
1301
|
1279
|
1302 static void
|
|
1303 redisplay_unmap_subwindows_except_us (struct frame *f, int x, int y, int width,
|
|
1304 int height, Lisp_Object subwindow)
|
428
|
1305 {
|
442
|
1306 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1307 {
|
|
1308 redisplay_unmap_subwindows (f, x, y, width, height, subwindow);
|
|
1309 }
|
|
1310 }
|
|
1311
|
|
1312 /****************************************************************************
|
|
1313 redisplay_output_subwindow
|
|
1314
|
|
1315 output a subwindow. This code borrows heavily from the pixmap stuff,
|
|
1316 although is much simpler not needing to account for partial
|
|
1317 pixmaps, backgrounds etc.
|
|
1318 ****************************************************************************/
|
|
1319 void
|
434
|
1320 redisplay_output_subwindow (struct window *w,
|
428
|
1321 Lisp_Object image_instance,
|
|
1322 struct display_box* db, struct display_glyph_area* dga,
|
2286
|
1323 face_index findex, int UNUSED (cursor_start),
|
|
1324 int UNUSED (cursor_width),
|
|
1325 int UNUSED (cursor_height))
|
428
|
1326 {
|
440
|
1327 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
428
|
1328 Lisp_Object window;
|
|
1329 struct display_glyph_area sdga;
|
|
1330
|
442
|
1331 dga->height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1332 dga->width = IMAGE_INSTANCE_WIDTH (p);
|
|
1333
|
|
1334 /* The first thing we are going to do is update the display
|
|
1335 characteristics of the subwindow. This also clears the dirty
|
|
1336 flags as a side effect. */
|
|
1337 redisplay_subwindow (image_instance);
|
428
|
1338
|
|
1339 /* This makes the glyph area fit into the display area. */
|
|
1340 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1341 return;
|
|
1342
|
793
|
1343 window = wrap_window (w);
|
428
|
1344
|
|
1345 /* Clear the area the subwindow is going into. */
|
|
1346 redisplay_clear_clipped_region (window, findex,
|
|
1347 db, dga, 0, image_instance);
|
|
1348
|
|
1349 /* This shrinks the display box to exactly enclose the glyph
|
|
1350 area. */
|
|
1351 redisplay_normalize_display_box (db, dga);
|
|
1352
|
|
1353 /* if we can't view the whole window we can't view any of it. We
|
|
1354 have to be careful here since we may be being asked to display
|
|
1355 part of a subwindow, the rest of which is on-screen as well. We
|
|
1356 need to allow this case and map the entire subwindow. We also
|
|
1357 need to be careful since the subwindow could be outside the
|
|
1358 window in the gutter or modeline - we also need to allow these
|
|
1359 cases.*/
|
|
1360 sdga.xoffset = -dga->xoffset;
|
|
1361 sdga.yoffset = -dga->yoffset;
|
442
|
1362 sdga.height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1363 sdga.width = IMAGE_INSTANCE_WIDTH (p);
|
434
|
1364
|
446
|
1365 if (redisplay_display_boxes_in_window_p (w, db, &sdga) == 0
|
|
1366 ||
|
|
1367 /* We only want to do full subwindow display for windows that
|
|
1368 are completely in the gutter, otherwise we must clip to be
|
|
1369 safe. */
|
|
1370 display_boxes_in_gutter_p (XFRAME (w->frame), db, &sdga) <= 0)
|
428
|
1371 {
|
|
1372 map_subwindow (image_instance, db->xpos, db->ypos, dga);
|
|
1373 }
|
|
1374 else
|
|
1375 {
|
|
1376 sdga.xoffset = sdga.yoffset = 0;
|
434
|
1377 map_subwindow (image_instance, db->xpos - dga->xoffset,
|
428
|
1378 db->ypos - dga->yoffset, &sdga);
|
|
1379 }
|
|
1380 }
|
|
1381
|
|
1382 /****************************************************************************
|
|
1383 redisplay_output_layout
|
|
1384
|
|
1385 Output a widget hierarchy. This can safely call itself recursively.
|
442
|
1386
|
|
1387 The complexity of outputting layouts is deciding whether to do it or
|
|
1388 not. Consider a layout enclosing some text, the text changes and is
|
|
1389 marked as dirty, but the enclosing layout has not been marked as
|
|
1390 dirty so no updates occur and the text will potentially be truncated.
|
|
1391 Alternatively we hold a back pointer in the image instance to the
|
|
1392 parent and mark the parent as dirty. But the layout code assumes that
|
|
1393 if the layout is dirty then the whole layout should be redisplayed,
|
|
1394 so we then get lots of flashing even though only the text has changed
|
|
1395 size. Of course if the text shrinks in size then we do actually need
|
|
1396 to redisplay the layout to repaint the exposed area. So what happens
|
|
1397 if we make a non-structural change like changing color? Either we
|
|
1398 redisplay everything, or we redisplay nothing. These are exactly the
|
|
1399 issues lwlib has to grapple with. We really need to know what has
|
|
1400 actually changed and make a layout decision based on that. We also
|
|
1401 really need to know what has changed so that we can only make the
|
|
1402 necessary changes in update_subwindow. This has all now been
|
|
1403 implemented, Viva la revolution!
|
428
|
1404 ****************************************************************************/
|
|
1405 void
|
442
|
1406 redisplay_output_layout (Lisp_Object domain,
|
428
|
1407 Lisp_Object image_instance,
|
|
1408 struct display_box* db, struct display_glyph_area* dga,
|
2286
|
1409 face_index findex, int UNUSED (cursor_start),
|
|
1410 int UNUSED (cursor_width), int UNUSED (cursor_height))
|
428
|
1411 {
|
440
|
1412 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
442
|
1413 Lisp_Object rest, window = DOMAIN_WINDOW (domain);
|
3479
|
1414 Ichar_dynarr *buf;
|
442
|
1415 struct window *w = XWINDOW (window);
|
|
1416 struct device *d = DOMAIN_XDEVICE (domain);
|
428
|
1417 int layout_height, layout_width;
|
|
1418
|
442
|
1419 layout_height = glyph_height (image_instance, domain);
|
|
1420 layout_width = glyph_width (image_instance, domain);
|
428
|
1421
|
|
1422 dga->height = layout_height;
|
|
1423 dga->width = layout_width;
|
442
|
1424 #ifdef DEBUG_WIDGET_OUTPUT
|
|
1425 printf ("outputing layout glyph %p\n", p);
|
|
1426 #endif
|
428
|
1427 /* This makes the glyph area fit into the display area. */
|
|
1428 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1429 return;
|
|
1430
|
3479
|
1431 buf = Dynarr_new (Ichar);
|
|
1432
|
428
|
1433 /* Highly dodgy optimization. We want to only output the whole
|
|
1434 layout if we really have to. */
|
442
|
1435 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p)
|
|
1436 || IMAGE_INSTANCE_LAYOUT_CHANGED (p)
|
|
1437 || IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
|
|
1438 || IMAGE_INSTANCE_SIZE_CHANGED (p)
|
|
1439 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
|
428
|
1440 {
|
|
1441 /* First clear the area we are drawing into. This is the easiest
|
|
1442 thing to do since we have many gaps that we have to make sure are
|
|
1443 filled in. */
|
|
1444 redisplay_clear_clipped_region (window, findex, db, dga, 1, Qnil);
|
434
|
1445
|
428
|
1446 /* Output a border if required */
|
|
1447 if (!NILP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1448 {
|
|
1449 int edges = 0;
|
|
1450 enum edge_style style;
|
|
1451 int ypos = db->ypos;
|
863
|
1452 int xpos = db->xpos;
|
428
|
1453 int height = dga->height;
|
863
|
1454 int width = dga->width;
|
434
|
1455
|
863
|
1456 /* The bevel_area routines always draw in from the specified
|
|
1457 area so there is no need to adjust the displayed area to
|
|
1458 make sure that the lines are visible. */
|
4187
|
1459 if (dga->xoffset >= 0)
|
428
|
1460 edges |= EDGE_LEFT;
|
4187
|
1461 if (dga->width - dga->xoffset == layout_width)
|
428
|
1462 edges |= EDGE_RIGHT;
|
4187
|
1463 if (dga->yoffset >= 0)
|
428
|
1464 edges |= EDGE_TOP;
|
|
1465 if (dga->height - dga->yoffset == layout_height)
|
|
1466 edges |= EDGE_BOTTOM;
|
4187
|
1467
|
428
|
1468 if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_in))
|
|
1469 style = EDGE_ETCHED_IN;
|
|
1470 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_out))
|
|
1471 style = EDGE_ETCHED_OUT;
|
|
1472 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qbevel_in))
|
|
1473 style = EDGE_BEVEL_IN;
|
|
1474 else if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1475 {
|
|
1476 style = EDGE_ETCHED_IN;
|
|
1477 if (edges & EDGE_TOP)
|
|
1478 {
|
|
1479 ypos += XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1480 height -= XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1481 }
|
|
1482 }
|
|
1483 else
|
|
1484 style = EDGE_BEVEL_OUT;
|
|
1485
|
434
|
1486 MAYBE_DEVMETH (d, bevel_area,
|
863
|
1487 (w, findex, xpos, ypos, width, height,
|
|
1488 DEFAULT_WIDGET_SHADOW_WIDTH, edges, style));
|
428
|
1489 }
|
|
1490 }
|
434
|
1491
|
428
|
1492 /* This shrinks the display box to exactly enclose the glyph
|
|
1493 area. */
|
|
1494 redisplay_normalize_display_box (db, dga);
|
|
1495
|
|
1496 /* Flip through the widgets in the layout displaying as necessary */
|
|
1497 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (p))
|
|
1498 {
|
442
|
1499 Lisp_Object child = glyph_image_instance (XCAR (rest), image_instance,
|
793
|
1500 ERROR_ME_DEBUG_WARN, 1);
|
428
|
1501
|
|
1502 struct display_box cdb;
|
|
1503 /* For losing HP-UX */
|
|
1504 cdb.xpos = db->xpos;
|
|
1505 cdb.ypos = db->ypos;
|
|
1506 cdb.width = db->width;
|
|
1507 cdb.height = db->height;
|
|
1508
|
|
1509 /* First determine if the image is visible at all */
|
|
1510 if (IMAGE_INSTANCEP (child))
|
|
1511 {
|
440
|
1512 Lisp_Image_Instance* childii = XIMAGE_INSTANCE (child);
|
442
|
1513
|
428
|
1514 /* The enclosing layout offsets are +ve at this point */
|
|
1515 struct display_glyph_area cdga;
|
|
1516 cdga.xoffset = IMAGE_INSTANCE_XOFFSET (childii) - dga->xoffset;
|
|
1517 cdga.yoffset = IMAGE_INSTANCE_YOFFSET (childii) - dga->yoffset;
|
442
|
1518 cdga.width = glyph_width (child, image_instance);
|
|
1519 cdga.height = glyph_height (child, image_instance);
|
|
1520
|
|
1521 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) =
|
|
1522 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p);
|
428
|
1523
|
4207
|
1524 /* Although normalization is done by the output routines we have to
|
|
1525 do it here so that they don't try and clear all of db. This is
|
|
1526 true below also. */
|
428
|
1527 if (redisplay_normalize_glyph_area (&cdb, &cdga))
|
|
1528 {
|
|
1529 redisplay_normalize_display_box (&cdb, &cdga);
|
4207
|
1530 /* Since the display boxes will now be totally in the window if
|
|
1531 they are visible at all we can now check this easily. */
|
428
|
1532 if (cdb.xpos < db->xpos || cdb.ypos < db->ypos
|
|
1533 || cdb.xpos + cdb.width > db->xpos + db->width
|
|
1534 || cdb.ypos + cdb.height > db->ypos + db->height)
|
|
1535 continue;
|
4207
|
1536 /* We have to invert the offset here as normalization will have
|
|
1537 made them positive which the output routines will treat as a
|
|
1538 truly +ve offset. */
|
428
|
1539 cdga.xoffset = -cdga.xoffset;
|
|
1540 cdga.yoffset = -cdga.yoffset;
|
|
1541
|
|
1542 switch (IMAGE_INSTANCE_TYPE (childii))
|
|
1543 {
|
|
1544 case IMAGE_TEXT:
|
|
1545 {
|
|
1546 /* #### This is well hacked and could use some
|
|
1547 generalisation.*/
|
434
|
1548 if (redisplay_normalize_glyph_area (&cdb, &cdga)
|
|
1549 &&
|
442
|
1550 (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1551 IMAGE_INSTANCE_DIRTYP (childii)))
|
428
|
1552 {
|
|
1553 struct display_line dl; /* this is fake */
|
|
1554 Lisp_Object string =
|
|
1555 IMAGE_INSTANCE_TEXT_STRING (childii);
|
442
|
1556 unsigned char charsets[NUM_LEADING_BYTES];
|
4207
|
1557 struct face_cachel *cachel
|
|
1558 = WINDOW_FACE_CACHEL (w, findex);
|
|
1559
|
|
1560 DISPLAY_LINE_INIT (dl);
|
442
|
1561
|
867
|
1562 find_charsets_in_ibyte_string (charsets,
|
4207
|
1563 XSTRING_DATA (string),
|
|
1564 XSTRING_LENGTH (string));
|
442
|
1565 ensure_face_cachel_complete (cachel, window, charsets);
|
|
1566
|
867
|
1567 convert_ibyte_string_into_ichar_dynarr
|
4207
|
1568 (XSTRING_DATA (string), XSTRING_LENGTH (string),
|
|
1569 buf);
|
434
|
1570
|
428
|
1571 redisplay_normalize_display_box (&cdb, &cdga);
|
|
1572 /* Offsets are now +ve again so be careful
|
|
1573 when fixing up the display line. */
|
|
1574 /* Munge boxes into display lines. */
|
|
1575 dl.ypos = (cdb.ypos - cdga.yoffset)
|
442
|
1576 + glyph_ascent (child, image_instance);
|
|
1577 dl.ascent = glyph_ascent (child, image_instance);
|
|
1578 dl.descent = glyph_descent (child, image_instance);
|
428
|
1579 dl.top_clip = cdga.yoffset;
|
4207
|
1580 dl.clip = (dl.ypos + dl.descent)
|
|
1581 - (cdb.ypos + cdb.height);
|
428
|
1582 /* output_string doesn't understand offsets in
|
|
1583 the same way as other routines - we have to
|
|
1584 add the offset to the width so that we
|
|
1585 output the full string. */
|
4207
|
1586 MAYBE_DEVMETH (d, output_string,
|
|
1587 (w, &dl, buf, cdb.xpos,
|
|
1588 cdga.xoffset, cdb.xpos,
|
|
1589 cdga.width + cdga.xoffset,
|
|
1590 findex, 0, 0, 0, 0));
|
428
|
1591 Dynarr_reset (buf);
|
|
1592 }
|
|
1593 }
|
|
1594 break;
|
434
|
1595
|
428
|
1596 case IMAGE_MONO_PIXMAP:
|
|
1597 case IMAGE_COLOR_PIXMAP:
|
442
|
1598 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii)
|
|
1599 || IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1600 redisplay_output_pixmap (w, child, &cdb, &cdga, findex,
|
|
1601 0, 0, 0, 0);
|
|
1602 break;
|
434
|
1603
|
428
|
1604 case IMAGE_WIDGET:
|
442
|
1605 if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (childii), Qlayout))
|
|
1606 {
|
|
1607 redisplay_output_layout (image_instance, child, &cdb, &cdga, findex,
|
|
1608 0, 0, 0);
|
|
1609 break;
|
|
1610 }
|
428
|
1611 case IMAGE_SUBWINDOW:
|
442
|
1612 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1613 IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1614 redisplay_output_subwindow (w, child, &cdb, &cdga, findex,
|
|
1615 0, 0, 0);
|
|
1616 break;
|
434
|
1617
|
428
|
1618 case IMAGE_NOTHING:
|
|
1619 /* nothing is as nothing does */
|
|
1620 break;
|
434
|
1621
|
428
|
1622 case IMAGE_POINTER:
|
|
1623 default:
|
2500
|
1624 ABORT ();
|
428
|
1625 }
|
|
1626 }
|
442
|
1627 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) = 0;
|
428
|
1628 }
|
|
1629 }
|
442
|
1630
|
|
1631 /* Update any display properties. I'm not sure whether this actually
|
|
1632 does anything for layouts except clear the changed flags. */
|
|
1633 redisplay_subwindow (image_instance);
|
|
1634
|
428
|
1635 Dynarr_free (buf);
|
|
1636 }
|
|
1637
|
|
1638 /****************************************************************************
|
|
1639 redisplay_output_pixmap
|
|
1640
|
|
1641
|
|
1642 output a pixmap.
|
|
1643 ****************************************************************************/
|
|
1644 void
|
434
|
1645 redisplay_output_pixmap (struct window *w,
|
428
|
1646 Lisp_Object image_instance,
|
|
1647 struct display_box* db, struct display_glyph_area* dga,
|
|
1648 face_index findex, int cursor_start, int cursor_width,
|
|
1649 int cursor_height, int offset_bitmap)
|
|
1650 {
|
|
1651 struct frame *f = XFRAME (w->frame);
|
|
1652 struct device *d = XDEVICE (f->device);
|
440
|
1653 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
793
|
1654 Lisp_Object window = wrap_window (w);
|
|
1655
|
428
|
1656
|
|
1657 dga->height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
1658 dga->width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
1659
|
819
|
1660 #ifdef DEBUG_REDISPLAY
|
|
1661 printf ("redisplay_output_pixmap(request) \
|
4187
|
1662 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
819
|
1663 db->width, db->height, db->xpos, db->ypos,
|
|
1664 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1665 #endif
|
|
1666
|
428
|
1667 /* This makes the glyph area fit into the display area. */
|
|
1668 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1669 return;
|
|
1670
|
819
|
1671 #ifdef DEBUG_REDISPLAY
|
|
1672 printf ("redisplay_output_pixmap(normalized) \
|
|
1673 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
|
1674 db->width, db->height, db->xpos, db->ypos,
|
|
1675 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1676 #endif
|
|
1677
|
428
|
1678 /* Clear the area the pixmap is going into. The pixmap itself will
|
|
1679 always take care of the full width. We don't want to clear where
|
|
1680 it is going to go in order to avoid flicker. So, all we have to
|
|
1681 take care of is any area above or below the pixmap. If the pixmap
|
|
1682 has a mask in which case we have to clear the whole damn thing
|
|
1683 since we can't yet clear just the area not included in the
|
|
1684 mask. */
|
|
1685 if (!offset_bitmap)
|
|
1686 {
|
|
1687 redisplay_clear_clipped_region (window, findex,
|
434
|
1688 db, dga,
|
442
|
1689 (IMAGE_INSTANCE_PIXMAP_MASK (p) != 0),
|
428
|
1690 Qnil);
|
|
1691
|
|
1692 /* This shrinks the display box to exactly enclose the glyph
|
|
1693 area. */
|
|
1694 redisplay_normalize_display_box (db, dga);
|
|
1695 }
|
|
1696 assert (db->xpos >= 0 && db->ypos >= 0);
|
|
1697
|
|
1698 MAYBE_DEVMETH (d, output_pixmap, (w, image_instance,
|
|
1699 db, dga,
|
|
1700 findex, cursor_start,
|
|
1701 cursor_width, cursor_height,
|
|
1702 offset_bitmap));
|
|
1703 }
|
|
1704
|
|
1705 /****************************************************************************
|
|
1706 redisplay_clear_region
|
|
1707
|
|
1708 Clear the area in the box defined by the given parameters using the
|
|
1709 given face. This has been generalised so that subwindows can be
|
|
1710 coped with effectively.
|
|
1711 ****************************************************************************/
|
|
1712 void
|
|
1713 redisplay_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1714 int width, int height)
|
|
1715 {
|
|
1716 struct window *w = NULL;
|
|
1717 struct frame *f = NULL;
|
|
1718 struct device *d;
|
|
1719 Lisp_Object background_pixmap = Qunbound;
|
|
1720 Lisp_Object fcolor = Qnil, bcolor = Qnil;
|
|
1721
|
|
1722 if (!width || !height)
|
|
1723 return;
|
|
1724
|
|
1725 if (WINDOWP (locale))
|
|
1726 {
|
|
1727 w = XWINDOW (locale);
|
|
1728 f = XFRAME (w->frame);
|
|
1729 }
|
|
1730 else if (FRAMEP (locale))
|
|
1731 {
|
|
1732 w = NULL;
|
|
1733 f = XFRAME (locale);
|
|
1734 }
|
|
1735 else
|
2500
|
1736 ABORT ();
|
428
|
1737
|
|
1738 d = XDEVICE (f->device);
|
|
1739
|
|
1740 /* if we have subwindows in the region we have to unmap them */
|
|
1741 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
|
|
1742
|
|
1743 /* #### This isn't quite right for when this function is called
|
|
1744 from the toolbar code. */
|
434
|
1745
|
428
|
1746 /* Don't use a backing pixmap in the border area */
|
|
1747 if (x >= FRAME_LEFT_BORDER_END (f)
|
|
1748 && x < FRAME_RIGHT_BORDER_START (f)
|
|
1749 && y >= FRAME_TOP_BORDER_END (f)
|
|
1750 && y < FRAME_BOTTOM_BORDER_START (f))
|
|
1751 {
|
|
1752 Lisp_Object temp;
|
434
|
1753
|
428
|
1754 if (w)
|
|
1755 {
|
|
1756 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
434
|
1757
|
428
|
1758 if (IMAGE_INSTANCEP (temp)
|
|
1759 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1760 {
|
|
1761 /* #### maybe we could implement such that a string
|
|
1762 can be a background pixmap? */
|
|
1763 background_pixmap = temp;
|
|
1764 }
|
|
1765 }
|
|
1766 else
|
|
1767 {
|
|
1768 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
434
|
1769
|
428
|
1770 if (IMAGE_INSTANCEP (temp)
|
|
1771 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1772 {
|
|
1773 background_pixmap = temp;
|
|
1774 }
|
|
1775 }
|
434
|
1776 }
|
428
|
1777
|
|
1778 if (!UNBOUNDP (background_pixmap) &&
|
|
1779 XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1780 {
|
|
1781 if (w)
|
|
1782 {
|
|
1783 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1784 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1785 }
|
|
1786 else
|
|
1787 {
|
|
1788 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1789 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1790 }
|
|
1791 }
|
|
1792 else
|
|
1793 {
|
|
1794 fcolor = (w ?
|
|
1795 WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1796 FACE_BACKGROUND (Vdefault_face, locale));
|
434
|
1797
|
428
|
1798 }
|
434
|
1799
|
428
|
1800 if (UNBOUNDP (background_pixmap))
|
|
1801 background_pixmap = Qnil;
|
434
|
1802
|
|
1803 DEVMETH (d, clear_region,
|
428
|
1804 (locale, d, f, findex, x, y, width, height, fcolor, bcolor, background_pixmap));
|
|
1805 }
|
|
1806
|
|
1807 /****************************************************************************
|
|
1808 redisplay_clear_clipped_region
|
|
1809
|
|
1810 Clear the area in the dest display_box not covered by the src
|
442
|
1811 display_glyph_area using the given face. This is a common occurrence
|
428
|
1812 for images shorter than the display line. Clipping can be played
|
|
1813 around with by altering these. glyphsrc should be normalized.
|
|
1814 ****************************************************************************/
|
|
1815 static void
|
434
|
1816 redisplay_clear_clipped_region (Lisp_Object window, face_index findex,
|
|
1817 struct display_box* dest, struct display_glyph_area* glyphsrc,
|
428
|
1818 int fullheight_p, Lisp_Object ignored_subwindow)
|
|
1819 {
|
|
1820 /* assume dest->xpos >= 0 */
|
|
1821 int clear_x;
|
|
1822 struct frame* f = XFRAME (XWINDOW (window)->frame);
|
|
1823
|
|
1824 if (glyphsrc->xoffset > 0)
|
|
1825 {
|
|
1826 clear_x = dest->xpos + glyphsrc->xoffset;
|
|
1827 }
|
|
1828 else
|
|
1829 {
|
|
1830 clear_x = dest->xpos;
|
|
1831 }
|
|
1832
|
|
1833 /* If we need the whole height cleared then just do it. */
|
|
1834 if (fullheight_p)
|
|
1835 {
|
|
1836 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1837 glyphsrc->width, dest->height);
|
|
1838 }
|
|
1839 else
|
|
1840 {
|
434
|
1841 int yoffset = (glyphsrc->yoffset > 0 ? glyphsrc->yoffset : 0);
|
|
1842
|
428
|
1843 /* We need to make sure that subwindows are unmapped from the
|
4187
|
1844 whole area. */
|
428
|
1845 redisplay_unmap_subwindows_except_us (f, clear_x, dest->ypos,
|
|
1846 glyphsrc->width, dest->height,
|
|
1847 ignored_subwindow);
|
|
1848 /* first the top box */
|
|
1849 if (yoffset > 0)
|
|
1850 {
|
|
1851 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1852 glyphsrc->width, yoffset);
|
434
|
1853
|
428
|
1854 }
|
|
1855 /* Then the bottom box */
|
|
1856 if (yoffset + glyphsrc->height < dest->height)
|
|
1857 {
|
|
1858 redisplay_clear_region (window, findex, clear_x,
|
|
1859 dest->ypos + yoffset + glyphsrc->height,
|
434
|
1860 glyphsrc->width,
|
428
|
1861 dest->height - (yoffset + glyphsrc->height));
|
|
1862
|
|
1863 }
|
|
1864 }
|
|
1865 }
|
|
1866
|
|
1867 /*****************************************************************************
|
|
1868 redisplay_normalize_glyph_area
|
|
1869 redisplay_normalize_display_box
|
|
1870
|
819
|
1871 Calculate the visible box for displaying glyphsrc in dest.
|
|
1872
|
|
1873 display_box and display_glyph_area are used to represent an area to
|
|
1874 displayed and where to display it. Using these two structures all
|
|
1875 combinations of clipping and position can be accommodated.
|
|
1876
|
|
1877 dest - display_box
|
|
1878
|
|
1879 xpos - absolute horizontal position of area.
|
|
1880
|
4187
|
1881 ypos - absolute vertical position of area.
|
819
|
1882
|
|
1883 glyphsrc - display_glyph_area
|
|
1884
|
|
1885 xoffset - horizontal offset of the glyph, +ve means display
|
|
1886 the glyph with the x position offset by xoffset, -ve means
|
|
1887 display starting xoffset into the glyph.
|
|
1888
|
|
1889 yoffset - vertical offset of the glyph, +ve means display the
|
|
1890 glyph with y position offset by yoffset, -ve means display
|
|
1891 starting xoffset into the glyph.
|
|
1892
|
428
|
1893 ****************************************************************************/
|
|
1894 int
|
434
|
1895 redisplay_normalize_glyph_area (struct display_box* dest,
|
428
|
1896 struct display_glyph_area* glyphsrc)
|
|
1897 {
|
|
1898 if (dest->xpos + glyphsrc->xoffset > dest->xpos + dest->width
|
|
1899 ||
|
|
1900 dest->ypos + glyphsrc->yoffset > dest->ypos + dest->height
|
|
1901 ||
|
|
1902 -glyphsrc->xoffset >= glyphsrc->width
|
|
1903 ||
|
448
|
1904 -glyphsrc->yoffset >= glyphsrc->height
|
|
1905 ||
|
|
1906 /* #### Not sure why this wasn't coped with before but normalizing
|
|
1907 to zero width or height is definitely wrong. */
|
|
1908 (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width
|
|
1909 &&
|
|
1910 dest->width - glyphsrc->xoffset <= 0)
|
|
1911 ||
|
|
1912 (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height
|
|
1913 &&
|
|
1914 dest->height - glyphsrc->yoffset <= 0))
|
428
|
1915 {
|
|
1916 /* It's all clipped out */
|
|
1917 return 0;
|
|
1918 }
|
|
1919
|
819
|
1920 /* Horizontal offsets. This works because xoffset can be -ve as well
|
|
1921 as +ve. When we enter this function the glyphsrc width and
|
|
1922 height are set to the actual glyph width and height irrespective
|
|
1923 of how much can be displayed. We are trying to clip both the
|
|
1924 offset into the image and the rightmost bounding box. Its
|
|
1925 possible for the glyph width to be much larger than the area we
|
|
1926 are displaying into (e.g. a large glyph in a small frame). */
|
428
|
1927 if (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width)
|
|
1928 {
|
819
|
1929 /* glyphsrc offset is +ve we are trying to display offset from the
|
|
1930 origin (the bounding box contains some space and then the
|
|
1931 glyph). At most the width we want to display is dest->width -
|
|
1932 glyphsrc->xoffset. */
|
428
|
1933 if (glyphsrc->xoffset > 0)
|
|
1934 glyphsrc->width = dest->width - glyphsrc->xoffset;
|
819
|
1935 /* glyphsrc offset is -ve we are trying to display hard up
|
|
1936 against the dest corner inset into the glyphsrc by
|
|
1937 xoffset.*/
|
4187
|
1938 else if (glyphsrc->xoffset < 0)
|
819
|
1939 {
|
|
1940 glyphsrc->width += glyphsrc->xoffset;
|
|
1941 glyphsrc->width = min (glyphsrc->width, dest->width);
|
|
1942 }
|
428
|
1943 else
|
|
1944 glyphsrc->width = dest->width;
|
|
1945 }
|
|
1946
|
4187
|
1947 else if (glyphsrc->xoffset < 0)
|
428
|
1948 glyphsrc->width += glyphsrc->xoffset;
|
|
1949
|
|
1950 /* Vertical offsets. This works because yoffset can be -ve as well as +ve */
|
|
1951 if (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height)
|
|
1952 {
|
819
|
1953 if ((glyphsrc->yoffset > 0) && (dest->height > glyphsrc->yoffset))
|
428
|
1954 glyphsrc->height = dest->height - glyphsrc->yoffset;
|
4187
|
1955 else if (glyphsrc->yoffset < 0)
|
819
|
1956 {
|
|
1957 glyphsrc->height += glyphsrc->yoffset;
|
|
1958 glyphsrc->height = min (glyphsrc->height, dest->height);
|
|
1959 }
|
428
|
1960 else
|
|
1961 glyphsrc->height = dest->height;
|
|
1962 }
|
|
1963
|
819
|
1964 else if (glyphsrc->yoffset < 0)
|
428
|
1965 glyphsrc->height += glyphsrc->yoffset;
|
|
1966
|
|
1967 return 1;
|
|
1968 }
|
|
1969
|
|
1970 static void
|
434
|
1971 redisplay_normalize_display_box (struct display_box* dest,
|
428
|
1972 struct display_glyph_area* glyphsrc)
|
|
1973 {
|
|
1974 /* Adjust the destination area. At the end of this the destination
|
|
1975 area will exactly enclose the glyph area. The only remaining
|
|
1976 adjustment will be offsets into the glyph area. */
|
|
1977
|
|
1978 /* Horizontal adjustment. */
|
|
1979 if (glyphsrc->xoffset > 0)
|
|
1980 {
|
|
1981 dest->xpos += glyphsrc->xoffset;
|
|
1982 dest->width -= glyphsrc->xoffset;
|
|
1983 glyphsrc->xoffset = 0;
|
|
1984 }
|
|
1985 else
|
|
1986 glyphsrc->xoffset = -glyphsrc->xoffset;
|
|
1987
|
|
1988 if (glyphsrc->width < dest->width)
|
|
1989 dest->width = glyphsrc->width;
|
|
1990
|
|
1991 /* Vertical adjustment. */
|
|
1992 if (glyphsrc->yoffset > 0)
|
|
1993 {
|
|
1994 dest->ypos += glyphsrc->yoffset;
|
|
1995 dest->height -= glyphsrc->yoffset;
|
|
1996 glyphsrc->yoffset = 0;
|
|
1997 }
|
|
1998 else
|
|
1999 glyphsrc->yoffset = -glyphsrc->yoffset;
|
|
2000
|
|
2001 if (glyphsrc->height < dest->height)
|
|
2002 dest->height = glyphsrc->height;
|
|
2003 }
|
|
2004
|
|
2005 /*****************************************************************************
|
|
2006 redisplay_display_boxes_in_window_p
|
|
2007
|
446
|
2008 Determine whether the required display_glyph_area is completely inside
|
|
2009 the window. -1 means the display_box is not in the window. 1 means the
|
|
2010 display_box and the display_glyph_area are in the window. 0 means
|
428
|
2011 the display_box is in the window but the display_glyph_area is not.
|
|
2012 ****************************************************************************/
|
|
2013 static int
|
|
2014 redisplay_display_boxes_in_window_p (struct window* w,
|
|
2015 struct display_box* db,
|
|
2016 struct display_glyph_area* dga)
|
|
2017 {
|
|
2018 int left = WINDOW_TEXT_LEFT (w);
|
|
2019 int right = WINDOW_TEXT_RIGHT (w);
|
|
2020 int top = WINDOW_TEXT_TOP (w);
|
|
2021 int bottom = WINDOW_TEXT_BOTTOM (w);
|
|
2022
|
|
2023 if (db->xpos < left || db->ypos < top
|
|
2024 || db->xpos + db->width > right
|
|
2025 || db->ypos + db->height > bottom)
|
446
|
2026 /* We are not displaying in a window at all */
|
|
2027 return -1;
|
434
|
2028
|
428
|
2029 if (db->xpos + dga->xoffset >= left
|
|
2030 &&
|
|
2031 db->ypos + dga->yoffset >= top
|
|
2032 &&
|
|
2033 db->xpos + dga->xoffset + dga->width <= right
|
|
2034 &&
|
|
2035 db->ypos + dga->yoffset + dga->height <= bottom)
|
|
2036 return 1;
|
|
2037
|
446
|
2038 return 0;
|
428
|
2039 }
|
|
2040
|
|
2041 /*****************************************************************************
|
|
2042 redisplay_calculate_display_boxes
|
|
2043
|
|
2044 Convert from rune/display_line co-ordinates to display_box
|
|
2045 co-ordinates.
|
|
2046 ****************************************************************************/
|
|
2047 int
|
|
2048 redisplay_calculate_display_boxes (struct display_line *dl, int xpos,
|
819
|
2049 int xoffset, int yoffset, int start_pixpos,
|
4187
|
2050 int width, struct display_box* dest,
|
428
|
2051 struct display_glyph_area* src)
|
|
2052 {
|
|
2053 dest->xpos = xpos;
|
|
2054 dest->ypos = DISPLAY_LINE_YPOS (dl);
|
|
2055 dest->width = width;
|
|
2056 dest->height = DISPLAY_LINE_HEIGHT (dl);
|
|
2057
|
|
2058 src->xoffset = -xoffset;
|
|
2059 src->width = 0;
|
|
2060 src->height = 0;
|
|
2061
|
819
|
2062 src->yoffset = -dl->top_clip + yoffset;
|
|
2063
|
428
|
2064 if (start_pixpos >=0 && start_pixpos > xpos)
|
|
2065 {
|
|
2066 /* Oops, we're asking for a start outside of the displayable
|
4187
|
2067 area. */
|
428
|
2068 if (start_pixpos > xpos + width)
|
|
2069 return 0;
|
|
2070 dest->xpos = start_pixpos;
|
|
2071 dest->width -= (start_pixpos - xpos);
|
|
2072 /* Offsets are -ve when we want to clip pixels off the displayed
|
4187
|
2073 glyph. */
|
428
|
2074 src->xoffset -= (start_pixpos - xpos);
|
|
2075 }
|
|
2076
|
|
2077 return 1;
|
|
2078 }
|
|
2079
|
|
2080 /*****************************************************************************
|
|
2081 redisplay_clear_top_of_window
|
|
2082
|
|
2083 If window is topmost, clear the internal border above it.
|
|
2084 ****************************************************************************/
|
448
|
2085 void
|
428
|
2086 redisplay_clear_top_of_window (struct window *w)
|
|
2087 {
|
793
|
2088 Lisp_Object window = wrap_window (w);
|
|
2089
|
428
|
2090
|
|
2091 if (!NILP (Fwindow_highest_p (window)))
|
|
2092 {
|
|
2093 struct frame *f = XFRAME (w->frame);
|
|
2094 int x, y, width, height;
|
|
2095
|
|
2096 x = w->pixel_left;
|
|
2097 width = w->pixel_width;
|
|
2098
|
|
2099 if (window_is_leftmost (w))
|
|
2100 {
|
|
2101 x -= FRAME_BORDER_WIDTH (f);
|
|
2102 width += FRAME_BORDER_WIDTH (f);
|
|
2103 }
|
|
2104 if (window_is_rightmost (w))
|
|
2105 width += FRAME_BORDER_WIDTH (f);
|
|
2106
|
|
2107 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
2108 height = FRAME_BORDER_HEIGHT (f) + 1;
|
|
2109
|
|
2110 redisplay_clear_region (window, DEFAULT_INDEX, x, y, width, height);
|
|
2111 }
|
|
2112 }
|
|
2113
|
|
2114 /*****************************************************************************
|
|
2115 redisplay_clear_to_window_end
|
|
2116
|
|
2117 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
2118 text area is handled separately since they may each have their own
|
|
2119 background color.
|
|
2120 ****************************************************************************/
|
|
2121 void
|
|
2122 redisplay_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
2123 {
|
|
2124 struct frame *f = XFRAME (w->frame);
|
|
2125 struct device *d = XDEVICE (f->device);
|
|
2126
|
|
2127 if (HAS_DEVMETH_P (d, clear_to_window_end))
|
|
2128 DEVMETH (d, clear_to_window_end, (w, ypos1, ypos2));
|
|
2129 else
|
|
2130 {
|
|
2131 int height = ypos2 - ypos1;
|
434
|
2132
|
428
|
2133 if (height)
|
|
2134 {
|
|
2135 Lisp_Object window;
|
|
2136 int bflag = 0 ; /* (window_needs_vertical_divider (w) ? 0 : 1);*/
|
|
2137 layout_bounds bounds;
|
434
|
2138
|
428
|
2139 bounds = calculate_display_line_boundaries (w, bflag);
|
793
|
2140 window = wrap_window (w);
|
428
|
2141
|
|
2142 if (window_is_leftmost (w))
|
|
2143 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
2144 ypos1, FRAME_BORDER_WIDTH (f), height);
|
434
|
2145
|
428
|
2146 if (bounds.left_in - bounds.left_out > 0)
|
|
2147 redisplay_clear_region (window,
|
|
2148 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
2149 bounds.left_out, ypos1,
|
|
2150 bounds.left_in - bounds.left_out, height);
|
434
|
2151
|
428
|
2152 if (bounds.right_in - bounds.left_in > 0)
|
434
|
2153 redisplay_clear_region (window,
|
428
|
2154 DEFAULT_INDEX,
|
|
2155 bounds.left_in, ypos1,
|
|
2156 bounds.right_in - bounds.left_in, height);
|
434
|
2157
|
428
|
2158 if (bounds.right_out - bounds.right_in > 0)
|
|
2159 redisplay_clear_region (window,
|
|
2160 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
2161 bounds.right_in, ypos1,
|
|
2162 bounds.right_out - bounds.right_in, height);
|
434
|
2163
|
428
|
2164 if (window_is_rightmost (w))
|
|
2165 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
2166 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
2167 }
|
|
2168 }
|
|
2169 }
|
|
2170
|
|
2171 /*****************************************************************************
|
|
2172 redisplay_clear_bottom_of_window
|
|
2173
|
|
2174 Clear window from right below the last display line to right above
|
|
2175 the modeline. The calling function can limit the area actually
|
|
2176 erased by setting min_start and/or max_end to positive values.
|
|
2177 ****************************************************************************/
|
|
2178 void
|
|
2179 redisplay_clear_bottom_of_window (struct window *w, display_line_dynarr *ddla,
|
|
2180 int min_start, int max_end)
|
|
2181 {
|
|
2182 struct frame *f = XFRAME (w->frame);
|
|
2183 int ypos1, ypos2;
|
|
2184 int ddla_len = Dynarr_length (ddla);
|
|
2185
|
|
2186 ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
2187 #ifdef HAVE_SCROLLBARS
|
|
2188 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2189 if (f->windows_structure_changed && NILP (w->scrollbar_on_top_p))
|
|
2190 ypos2 += window_scrollbar_height (w);
|
|
2191 #endif
|
|
2192
|
|
2193 if (ddla_len)
|
|
2194 {
|
|
2195 if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline)
|
|
2196 {
|
|
2197 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2198 #ifdef HAVE_SCROLLBARS
|
|
2199 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2200 if (f->windows_structure_changed && !NILP (w->scrollbar_on_top_p))
|
|
2201 ypos1 -= window_scrollbar_height (w);
|
|
2202 #endif
|
|
2203 }
|
|
2204 else
|
|
2205 {
|
|
2206 struct display_line *dl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2207 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
2208 }
|
|
2209 }
|
|
2210 else
|
|
2211 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2212
|
|
2213 /* #### See if this can be made conditional on the frame
|
|
2214 changing size. */
|
|
2215 if (MINI_WINDOW_P (w))
|
|
2216 ypos2 += FRAME_BORDER_HEIGHT (f);
|
|
2217
|
|
2218 if (min_start >= 0 && ypos1 < min_start)
|
|
2219 ypos1 = min_start;
|
|
2220 if (max_end >= 0 && ypos2 > max_end)
|
|
2221 ypos2 = max_end;
|
|
2222
|
|
2223 if (ypos2 <= ypos1)
|
|
2224 return;
|
|
2225
|
|
2226 redisplay_clear_to_window_end (w, ypos1, ypos2);
|
|
2227 }
|
|
2228
|
|
2229 /*****************************************************************************
|
|
2230 redisplay_update_line
|
|
2231
|
|
2232 This is used during incremental updates to update a single line and
|
|
2233 correct the offsets on all lines below it. At the moment
|
|
2234 update_values is false if we are only updating the modeline.
|
|
2235 ****************************************************************************/
|
|
2236 void
|
|
2237 redisplay_update_line (struct window *w, int first_line, int last_line,
|
|
2238 int update_values)
|
|
2239 {
|
|
2240 struct frame *f = XFRAME (w->frame);
|
|
2241 struct device *d = XDEVICE (f->device);
|
|
2242
|
|
2243 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2244 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2245
|
442
|
2246 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2247
|
|
2248 while (first_line <= last_line)
|
|
2249 {
|
826
|
2250 Charcount old_len = (Dynarr_atp (cdla, first_line)->end_charpos -
|
|
2251 Dynarr_atp (cdla, first_line)->charpos);
|
|
2252 Charcount new_len = (Dynarr_atp (ddla, first_line)->end_charpos -
|
|
2253 Dynarr_atp (ddla, first_line)->charpos);
|
428
|
2254
|
|
2255 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
2256
|
|
2257 /* Output the changes. */
|
|
2258 output_display_line (w, cdla, ddla, first_line, -1, -1);
|
|
2259
|
|
2260 /* Update the offsets. */
|
|
2261 if (update_values)
|
|
2262 {
|
|
2263 int cur_line = first_line + 1;
|
|
2264 while (cur_line < Dynarr_length (cdla))
|
|
2265 {
|
|
2266 Dynarr_atp (cdla, cur_line)->offset += (new_len - old_len);
|
|
2267 Dynarr_atp (ddla, cur_line)->offset += (new_len - old_len);
|
|
2268 cur_line++;
|
|
2269 }
|
|
2270 }
|
|
2271
|
|
2272 /* Update the window_end_pos and other settings. */
|
|
2273 if (update_values)
|
|
2274 {
|
|
2275 w->window_end_pos[CURRENT_DISP] -= (new_len - old_len);
|
|
2276
|
|
2277 if (Dynarr_atp (ddla, first_line)->cursor_elt != -1)
|
|
2278 {
|
|
2279 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2280 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2281 }
|
|
2282 }
|
|
2283
|
|
2284 first_line++;
|
|
2285 }
|
|
2286
|
|
2287 /* Update the window max line length. We have to scan the entire
|
|
2288 set of display lines otherwise we might not detect if the max is
|
|
2289 supposed to shrink. */
|
|
2290 if (update_values)
|
|
2291 {
|
|
2292 int line = 0;
|
|
2293
|
|
2294 w->max_line_len = 0;
|
|
2295 while (line < Dynarr_length (ddla))
|
|
2296 {
|
|
2297 struct display_line *dl = Dynarr_atp (ddla, line);
|
|
2298
|
|
2299 if (!dl->modeline)
|
|
2300 w->max_line_len = max (dl->num_chars, w->max_line_len);
|
|
2301
|
|
2302 line++;
|
|
2303 }
|
|
2304 }
|
|
2305
|
|
2306 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2307 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2308 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2309 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2310 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2311 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2312
|
|
2313 /* We don't bother updating the vertical scrollbars here. This
|
|
2314 gives us a performance increase while having minimal loss of
|
|
2315 quality to the scrollbar slider size and position since when this
|
|
2316 function is called we know that the changes to the buffer were
|
|
2317 very localized. We have to update the horizontal scrollbars,
|
|
2318 though, because this routine could cause a change which has a
|
|
2319 larger impact on their sizing. */
|
|
2320 /* #### See if we can get away with only calling this if
|
|
2321 max_line_len is greater than the window_char_width. */
|
462
|
2322 /* #### BILL!!! Should we do this for GTK as well? */
|
428
|
2323 #if defined(HAVE_SCROLLBARS) && defined(HAVE_X_WINDOWS)
|
|
2324 {
|
|
2325 extern int stupid_vertical_scrollbar_drag_hack;
|
|
2326
|
|
2327 update_window_scrollbars (w, NULL, 1, stupid_vertical_scrollbar_drag_hack);
|
|
2328 stupid_vertical_scrollbar_drag_hack = 1;
|
|
2329 }
|
|
2330 #endif
|
|
2331
|
442
|
2332 redisplay_redraw_cursor (f, 0);
|
|
2333 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2334 }
|
|
2335
|
|
2336 /*****************************************************************************
|
|
2337 redisplay_output_window
|
|
2338
|
|
2339 For the given window W, ensure that the current display lines are
|
|
2340 equal to the desired display lines, outputing changes as necessary.
|
|
2341
|
|
2342 #### Fuck me. This just isn't going to cut it for tty's. The output
|
|
2343 decisions for them must be based on the contents of the entire frame
|
|
2344 because that is how the available output capabilities think. The
|
|
2345 solution is relatively simple. Create redisplay_output_frame. This
|
|
2346 will basically merge all of the separate window display structs into
|
|
2347 a single one for the frame. This combination structure will be able
|
|
2348 to be passed to the same output_display_line which works for windows
|
|
2349 on X frames and the right things will happen. It just takes time to
|
|
2350 do.
|
|
2351 ****************************************************************************/
|
|
2352 void
|
|
2353 redisplay_output_window (struct window *w)
|
|
2354 {
|
|
2355 struct frame *f = XFRAME (w->frame);
|
|
2356 struct device *d = XDEVICE (f->device);
|
|
2357
|
|
2358 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2359 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2360
|
|
2361 int cdla_len = Dynarr_length (cdla);
|
|
2362 int ddla_len = Dynarr_length (ddla);
|
|
2363
|
|
2364 int line;
|
|
2365 int need_to_clear_bottom = 0;
|
|
2366 int need_to_clear_start = -1;
|
|
2367 int need_to_clear_end = -1;
|
|
2368
|
|
2369 /* Backgrounds may have changed or windows may have gone away
|
|
2370 leaving dividers lying around. */
|
|
2371 if (f->faces_changed
|
|
2372 || f->windows_structure_changed
|
|
2373 || w->shadow_thickness_changed)
|
|
2374 need_to_clear_bottom = 1;
|
|
2375
|
|
2376 /* The first thing we do is determine if we are going to need to
|
|
2377 clear the bottom of the window. We only need to do this if the
|
|
2378 bottom of the current display lines is below the bottom of the
|
|
2379 desired display lines. Note that the number of lines is
|
|
2380 irrelevant. Only the position matters. We also clear to the
|
|
2381 bottom of the window if the modeline has shifted position. */
|
|
2382 /* #### We can't blindly not clear the bottom if f->clear is true
|
|
2383 since there might be a window-local background. However, for
|
|
2384 those cases where there isn't, clearing the end of the window in
|
|
2385 this case sucks. */
|
|
2386 if (!need_to_clear_bottom)
|
|
2387 {
|
|
2388 struct display_line *cdl, *ddl;
|
|
2389
|
|
2390 /* If the modeline has changed position or size, clear the bottom
|
|
2391 of the window. */
|
|
2392 if (!need_to_clear_bottom)
|
|
2393 {
|
|
2394 cdl = ddl = 0;
|
|
2395
|
|
2396 if (cdla_len)
|
|
2397 cdl = Dynarr_atp (cdla, 0);
|
|
2398 if (ddla_len)
|
|
2399 ddl = Dynarr_atp (ddla, 0);
|
|
2400
|
|
2401 if (!cdl || !ddl)
|
|
2402 need_to_clear_bottom = 1;
|
|
2403 else if ((!cdl->modeline && ddl->modeline)
|
|
2404 || (cdl->modeline && !ddl->modeline))
|
|
2405 need_to_clear_bottom = 1;
|
|
2406 else if (cdl->ypos != ddl->ypos ||
|
|
2407 cdl->ascent != ddl->ascent ||
|
|
2408 cdl->descent != ddl->descent ||
|
|
2409 cdl->clip != ddl->clip)
|
|
2410 need_to_clear_bottom = 1;
|
|
2411
|
|
2412 /* #### This kludge is to make sure the modeline shadows get
|
|
2413 redrawn if the modeline position shifts. */
|
|
2414 if (need_to_clear_bottom)
|
|
2415 w->shadow_thickness_changed = 1;
|
|
2416 }
|
|
2417
|
|
2418 if (!need_to_clear_bottom)
|
|
2419 {
|
|
2420 cdl = ddl = 0;
|
|
2421
|
|
2422 if (cdla_len)
|
|
2423 cdl = Dynarr_atp (cdla, cdla_len - 1);
|
|
2424 if (ddla_len)
|
|
2425 ddl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2426
|
|
2427 if (!cdl || !ddl)
|
|
2428 need_to_clear_bottom = 1;
|
|
2429 else
|
|
2430 {
|
|
2431 int cdl_bottom, ddl_bottom;
|
|
2432
|
|
2433 cdl_bottom = cdl->ypos + cdl->descent;
|
|
2434 ddl_bottom = ddl->ypos + ddl->descent;
|
|
2435
|
|
2436 if (cdl_bottom > ddl_bottom)
|
|
2437 {
|
|
2438 need_to_clear_bottom = 1;
|
|
2439 need_to_clear_start = ddl_bottom;
|
|
2440 need_to_clear_end = cdl_bottom;
|
|
2441 }
|
|
2442 }
|
|
2443 }
|
|
2444 }
|
|
2445
|
|
2446 /* Perform any output initialization. */
|
442
|
2447 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2448
|
|
2449 /* If the window's structure has changed clear the internal border
|
|
2450 above it if it is topmost (the function will check). */
|
448
|
2451 if (f->windows_structure_changed || f->faces_changed)
|
428
|
2452 redisplay_clear_top_of_window (w);
|
|
2453
|
|
2454 /* Output each line. */
|
|
2455 for (line = 0; line < Dynarr_length (ddla); line++)
|
|
2456 {
|
|
2457 output_display_line (w, cdla, ddla, line, -1, -1);
|
|
2458 }
|
|
2459
|
|
2460 /* If the number of display lines has shrunk, adjust. */
|
|
2461 if (cdla_len > ddla_len)
|
|
2462 {
|
|
2463 Dynarr_length (cdla) = ddla_len;
|
|
2464 }
|
|
2465
|
|
2466 /* Output a vertical divider between windows, if necessary. */
|
|
2467 if (window_needs_vertical_divider (w)
|
|
2468 && (f->windows_structure_changed || f->clear))
|
|
2469 {
|
442
|
2470 MAYBE_DEVMETH (d, output_vertical_divider, (w, f->windows_structure_changed));
|
428
|
2471 }
|
|
2472
|
|
2473 /* Clear the rest of the window, if necessary. */
|
|
2474 if (need_to_clear_bottom)
|
|
2475 {
|
|
2476 redisplay_clear_bottom_of_window (w, ddla, need_to_clear_start,
|
|
2477 need_to_clear_end);
|
|
2478 }
|
|
2479
|
|
2480 w->window_end_pos[CURRENT_DISP] = w->window_end_pos[DESIRED_DISP];
|
|
2481 Fset_marker (w->start[CURRENT_DISP],
|
|
2482 make_int (marker_position (w->start[DESIRED_DISP])),
|
|
2483 w->buffer);
|
|
2484 Fset_marker (w->pointm[CURRENT_DISP],
|
|
2485 make_int (marker_position (w->pointm[DESIRED_DISP])),
|
|
2486 w->buffer);
|
|
2487 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2488 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2489 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2490 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2491 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2492 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2493 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2494 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2495 w->shadow_thickness_changed = 0;
|
|
2496
|
|
2497 set_window_display_buffer (w, XBUFFER (w->buffer));
|
|
2498 find_window_mirror (w)->truncate_win = window_truncation_on (w);
|
|
2499
|
|
2500 /* Overkill on invalidating the cache. It is very bad for it to not
|
|
2501 get invalidated when it should be. */
|
|
2502 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (d);
|
|
2503
|
442
|
2504 redisplay_redraw_cursor (f, 0);
|
|
2505 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2506
|
|
2507 #ifdef HAVE_SCROLLBARS
|
|
2508 update_window_scrollbars (w, NULL, !MINI_WINDOW_P (w), 0);
|
|
2509 #endif
|
|
2510 }
|
|
2511
|
|
2512 /*****************************************************************************
|
1318
|
2513 redisplay_redraw_exposed_window
|
|
2514
|
|
2515 Given a bounding box for an area that needs to be redrawn, determine
|
|
2516 what parts of what lines are contained within and re-output their
|
|
2517 contents.
|
|
2518 ****************************************************************************/
|
|
2519 static void
|
|
2520 redisplay_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
2521 int height)
|
|
2522 {
|
|
2523 struct frame *f = XFRAME (w->frame);
|
|
2524 int line;
|
|
2525 int start_x, start_y, end_x, end_y;
|
|
2526 int orig_windows_structure_changed;
|
|
2527
|
|
2528 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2529
|
|
2530 if (!NILP (w->vchild))
|
|
2531 {
|
|
2532 redisplay_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
2533 return;
|
|
2534 }
|
|
2535 else if (!NILP (w->hchild))
|
|
2536 {
|
|
2537 redisplay_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
2538 return;
|
|
2539 }
|
|
2540
|
|
2541 /* If the window doesn't intersect the exposed region, we're done here. */
|
|
2542 if (x >= WINDOW_RIGHT (w) || (x + width) <= WINDOW_LEFT (w)
|
|
2543 || y >= WINDOW_BOTTOM (w) || (y + height) <= WINDOW_TOP (w))
|
|
2544 {
|
|
2545 return;
|
|
2546 }
|
|
2547 else
|
|
2548 {
|
|
2549 start_x = max (WINDOW_LEFT (w), x);
|
|
2550 end_x = min (WINDOW_RIGHT (w), (x + width));
|
|
2551 start_y = max (WINDOW_TOP (w), y);
|
|
2552 end_y = min (WINDOW_BOTTOM (w), y + height);
|
|
2553
|
|
2554 /* We do this to make sure that the 3D modelines get redrawn if
|
4187
|
2555 they are in the exposed region. */
|
1318
|
2556 orig_windows_structure_changed = f->windows_structure_changed;
|
|
2557 f->windows_structure_changed = 1;
|
|
2558 }
|
|
2559
|
|
2560 /* #### Not in GTK or MS Windows. I think is because of toolbars, which
|
|
2561 are handled as widgets in GTK and MS Windows, but drawn ourselves in
|
|
2562 X. For the moment I'm leaving this in, if it causes problems we have
|
|
2563 some device method indicating whether we're drawing our own
|
|
2564 toolbars. */
|
|
2565 redisplay_clear_top_of_window (w);
|
|
2566 if (window_needs_vertical_divider (w))
|
|
2567 {
|
|
2568 FRAMEMETH (f, output_vertical_divider, (w, 0));
|
|
2569 }
|
|
2570
|
|
2571 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
2572 {
|
|
2573 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
2574 int top_y = DISPLAY_LINE_YPOS (cdl);
|
|
2575 int bottom_y = DISPLAY_LINE_YPOS (cdl) + DISPLAY_LINE_HEIGHT (cdl);
|
|
2576
|
|
2577 if (bottom_y >= start_y)
|
|
2578 {
|
|
2579 if (top_y > end_y)
|
|
2580 {
|
|
2581 if (line == 0)
|
|
2582 continue;
|
|
2583 else
|
|
2584 break;
|
|
2585 }
|
|
2586 else
|
|
2587 {
|
|
2588 output_display_line (w, 0, cdla, line, start_x, end_x);
|
|
2589 }
|
|
2590 }
|
|
2591 }
|
|
2592
|
|
2593 f->windows_structure_changed = orig_windows_structure_changed;
|
|
2594
|
|
2595 /* If there have never been any face cache_elements created, then this
|
|
2596 expose event doesn't actually have anything to do. */
|
|
2597 if (Dynarr_largest (w->face_cachels))
|
|
2598 redisplay_clear_bottom_of_window (w, cdla, start_y, end_y);
|
|
2599
|
|
2600 #ifdef HAVE_SCROLLBARS
|
|
2601 MAYBE_FRAMEMETH (f, redisplay_deadbox, (w, x, y, width, height));
|
|
2602 #endif
|
|
2603 }
|
|
2604
|
|
2605
|
|
2606 /*****************************************************************************
|
|
2607 redisplay_redraw_exposed_windows
|
|
2608
|
|
2609 For each window beneath the given window in the window hierarchy,
|
|
2610 ensure that it is redrawn if necessary after an Expose event.
|
|
2611 ****************************************************************************/
|
|
2612 static void
|
|
2613 redisplay_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
2614 int height)
|
|
2615 {
|
|
2616 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
2617 redisplay_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
2618 }
|
|
2619
|
|
2620 static void
|
|
2621 redisplay_redraw_exposed_area_1 (Lisp_Object arg)
|
|
2622 {
|
|
2623 assert (!in_display);
|
|
2624 redisplay_redraw_exposed_area (XFRAME (X1ST (arg)),
|
|
2625 XINT (X2ND (arg)),
|
|
2626 XINT (X3RD (arg)),
|
|
2627 XINT (X4TH (arg)),
|
|
2628 XINT (X5TH (arg)));
|
|
2629 free_list (arg);
|
|
2630 }
|
|
2631
|
|
2632 /*****************************************************************************
|
|
2633 redisplay_redraw_exposed_area
|
|
2634
|
|
2635 For each window on the given frame, ensure that any area in the
|
|
2636 Exposed area is redrawn.
|
|
2637 ****************************************************************************/
|
|
2638 void
|
|
2639 redisplay_redraw_exposed_area (struct frame *f, int x, int y, int width,
|
|
2640 int height)
|
|
2641 {
|
|
2642 int depth;
|
|
2643
|
|
2644 if (in_display)
|
|
2645 {
|
|
2646 /* Not safe to do it now, so delay it */
|
|
2647 register_post_redisplay_action (redisplay_redraw_exposed_area_1,
|
|
2648 list5 (wrap_frame (f), make_int (x),
|
|
2649 make_int (y), make_int (width),
|
|
2650 make_int (height)));
|
|
2651 return;
|
|
2652 }
|
|
2653
|
|
2654 depth = enter_redisplay_critical_section ();
|
|
2655
|
|
2656 MAYBE_FRAMEMETH (f, frame_output_begin, (f));
|
|
2657
|
|
2658 /* If any window on the frame has had its face cache reset then the
|
|
2659 redisplay structures are effectively invalid. If we attempt to
|
|
2660 use them we'll blow up. We mark the frame as changed to ensure
|
|
2661 that redisplay will do a full update. This probably isn't
|
|
2662 necessary but it can't hurt. */
|
|
2663 #ifdef HAVE_TOOLBARS
|
|
2664 /* #### We would rather put these off as well but there is currently
|
|
2665 no combination of flags which will force an unchanged toolbar to
|
|
2666 redraw anyhow. */
|
|
2667 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
2668 #endif
|
|
2669 redraw_exposed_gutters (f, x, y, width, height);
|
|
2670
|
|
2671 if (!f->window_face_cache_reset)
|
|
2672 {
|
|
2673 redisplay_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
2674 /* #### Why not call this always? */
|
|
2675 MAYBE_FRAMEMETH (f, frame_output_end, (f));
|
|
2676 }
|
|
2677 else
|
|
2678 MARK_FRAME_CHANGED (f);
|
|
2679
|
|
2680 exit_redisplay_critical_section (depth);
|
|
2681 }
|
|
2682
|
|
2683 /*****************************************************************************
|
428
|
2684 bevel_modeline
|
|
2685
|
|
2686 Draw a 3d border around the modeline on window W.
|
|
2687 ****************************************************************************/
|
|
2688 void
|
|
2689 bevel_modeline (struct window *w, struct display_line *dl)
|
|
2690 {
|
|
2691 struct frame *f = XFRAME (w->frame);
|
|
2692 struct device *d = XDEVICE (f->device);
|
|
2693 int x, y, width, height;
|
|
2694 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
2695 enum edge_style style;
|
|
2696
|
|
2697 x = WINDOW_MODELINE_LEFT (w);
|
|
2698 width = WINDOW_MODELINE_RIGHT (w) - x;
|
|
2699 y = dl->ypos - dl->ascent - shadow_thickness;
|
|
2700 height = dl->ascent + dl->descent + 2 * shadow_thickness;
|
|
2701
|
|
2702 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
2703 {
|
|
2704 style = EDGE_BEVEL_IN;
|
|
2705 }
|
|
2706 else
|
|
2707 {
|
|
2708 style = EDGE_BEVEL_OUT;
|
|
2709 }
|
|
2710
|
434
|
2711 MAYBE_DEVMETH (d, bevel_area,
|
428
|
2712 (w, MODELINE_INDEX, x, y, width, height, shadow_thickness,
|
|
2713 EDGE_ALL, style));
|
|
2714 }
|