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