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"
|
872
|
38 #include "frame-impl.h"
|
|
39 #include "device-impl.h"
|
428
|
40 #include "glyphs.h"
|
|
41 #include "redisplay.h"
|
|
42 #include "faces.h"
|
446
|
43 #include "gutter.h"
|
428
|
44
|
|
45 static int compare_runes (struct window *w, struct rune *crb,
|
|
46 struct rune *drb);
|
|
47 static void redraw_cursor_in_window (struct window *w,
|
|
48 int run_end_begin_glyphs);
|
|
49 static void redisplay_output_display_block (struct window *w, struct display_line *dl,
|
|
50 int block, int start, int end, int start_pixpos,
|
434
|
51 int cursor_start, int cursor_width,
|
428
|
52 int cursor_height);
|
434
|
53 static void redisplay_normalize_display_box (struct display_box* dest,
|
428
|
54 struct display_glyph_area* src);
|
|
55 static int redisplay_display_boxes_in_window_p (struct window* w,
|
|
56 struct display_box* db,
|
|
57 struct display_glyph_area* dga);
|
434
|
58 static void redisplay_clear_clipped_region (Lisp_Object locale, face_index findex,
|
|
59 struct display_box* dest,
|
|
60 struct display_glyph_area* glyphsrc,
|
428
|
61 int fullheight_p, Lisp_Object);
|
|
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 ****************************************************************************/
|
1279
|
1281 void
|
|
1282 redisplay_unmap_subwindows_maybe (struct frame *f, int x, int y, int width,
|
|
1283 int height)
|
428
|
1284 {
|
442
|
1285 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1286 {
|
|
1287 redisplay_unmap_subwindows (f, x, y, width, height, Qnil);
|
|
1288 }
|
|
1289 }
|
|
1290
|
1279
|
1291 static void
|
|
1292 redisplay_unmap_subwindows_except_us (struct frame *f, int x, int y, int width,
|
|
1293 int height, Lisp_Object subwindow)
|
428
|
1294 {
|
442
|
1295 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1296 {
|
|
1297 redisplay_unmap_subwindows (f, x, y, width, height, subwindow);
|
|
1298 }
|
|
1299 }
|
|
1300
|
|
1301 /****************************************************************************
|
|
1302 redisplay_output_subwindow
|
|
1303
|
|
1304 output a subwindow. This code borrows heavily from the pixmap stuff,
|
|
1305 although is much simpler not needing to account for partial
|
|
1306 pixmaps, backgrounds etc.
|
|
1307 ****************************************************************************/
|
|
1308 void
|
434
|
1309 redisplay_output_subwindow (struct window *w,
|
428
|
1310 Lisp_Object image_instance,
|
|
1311 struct display_box* db, struct display_glyph_area* dga,
|
|
1312 face_index findex, int cursor_start, int cursor_width,
|
|
1313 int cursor_height)
|
|
1314 {
|
440
|
1315 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
428
|
1316 Lisp_Object window;
|
|
1317 struct display_glyph_area sdga;
|
|
1318
|
442
|
1319 dga->height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1320 dga->width = IMAGE_INSTANCE_WIDTH (p);
|
|
1321
|
|
1322 /* The first thing we are going to do is update the display
|
|
1323 characteristics of the subwindow. This also clears the dirty
|
|
1324 flags as a side effect. */
|
|
1325 redisplay_subwindow (image_instance);
|
428
|
1326
|
|
1327 /* This makes the glyph area fit into the display area. */
|
|
1328 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1329 return;
|
|
1330
|
793
|
1331 window = wrap_window (w);
|
428
|
1332
|
|
1333 /* Clear the area the subwindow is going into. */
|
|
1334 redisplay_clear_clipped_region (window, findex,
|
|
1335 db, dga, 0, image_instance);
|
|
1336
|
|
1337 /* This shrinks the display box to exactly enclose the glyph
|
|
1338 area. */
|
|
1339 redisplay_normalize_display_box (db, dga);
|
|
1340
|
|
1341 /* if we can't view the whole window we can't view any of it. We
|
|
1342 have to be careful here since we may be being asked to display
|
|
1343 part of a subwindow, the rest of which is on-screen as well. We
|
|
1344 need to allow this case and map the entire subwindow. We also
|
|
1345 need to be careful since the subwindow could be outside the
|
|
1346 window in the gutter or modeline - we also need to allow these
|
|
1347 cases.*/
|
|
1348 sdga.xoffset = -dga->xoffset;
|
|
1349 sdga.yoffset = -dga->yoffset;
|
442
|
1350 sdga.height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1351 sdga.width = IMAGE_INSTANCE_WIDTH (p);
|
434
|
1352
|
446
|
1353 if (redisplay_display_boxes_in_window_p (w, db, &sdga) == 0
|
|
1354 ||
|
|
1355 /* We only want to do full subwindow display for windows that
|
|
1356 are completely in the gutter, otherwise we must clip to be
|
|
1357 safe. */
|
|
1358 display_boxes_in_gutter_p (XFRAME (w->frame), db, &sdga) <= 0)
|
428
|
1359 {
|
|
1360 map_subwindow (image_instance, db->xpos, db->ypos, dga);
|
|
1361 }
|
|
1362 else
|
|
1363 {
|
|
1364 sdga.xoffset = sdga.yoffset = 0;
|
434
|
1365 map_subwindow (image_instance, db->xpos - dga->xoffset,
|
428
|
1366 db->ypos - dga->yoffset, &sdga);
|
|
1367 }
|
|
1368 }
|
|
1369
|
|
1370 /****************************************************************************
|
|
1371 redisplay_output_layout
|
|
1372
|
|
1373 Output a widget hierarchy. This can safely call itself recursively.
|
442
|
1374
|
|
1375 The complexity of outputting layouts is deciding whether to do it or
|
|
1376 not. Consider a layout enclosing some text, the text changes and is
|
|
1377 marked as dirty, but the enclosing layout has not been marked as
|
|
1378 dirty so no updates occur and the text will potentially be truncated.
|
|
1379 Alternatively we hold a back pointer in the image instance to the
|
|
1380 parent and mark the parent as dirty. But the layout code assumes that
|
|
1381 if the layout is dirty then the whole layout should be redisplayed,
|
|
1382 so we then get lots of flashing even though only the text has changed
|
|
1383 size. Of course if the text shrinks in size then we do actually need
|
|
1384 to redisplay the layout to repaint the exposed area. So what happens
|
|
1385 if we make a non-structural change like changing color? Either we
|
|
1386 redisplay everything, or we redisplay nothing. These are exactly the
|
|
1387 issues lwlib has to grapple with. We really need to know what has
|
|
1388 actually changed and make a layout decision based on that. We also
|
|
1389 really need to know what has changed so that we can only make the
|
|
1390 necessary changes in update_subwindow. This has all now been
|
|
1391 implemented, Viva la revolution!
|
428
|
1392 ****************************************************************************/
|
|
1393 void
|
442
|
1394 redisplay_output_layout (Lisp_Object domain,
|
428
|
1395 Lisp_Object image_instance,
|
|
1396 struct display_box* db, struct display_glyph_area* dga,
|
|
1397 face_index findex, int cursor_start, int cursor_width,
|
|
1398 int cursor_height)
|
|
1399 {
|
440
|
1400 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
442
|
1401 Lisp_Object rest, window = DOMAIN_WINDOW (domain);
|
867
|
1402 Ichar_dynarr *buf = Dynarr_new (Ichar);
|
442
|
1403 struct window *w = XWINDOW (window);
|
|
1404 struct device *d = DOMAIN_XDEVICE (domain);
|
428
|
1405 int layout_height, layout_width;
|
|
1406
|
442
|
1407 layout_height = glyph_height (image_instance, domain);
|
|
1408 layout_width = glyph_width (image_instance, domain);
|
428
|
1409
|
|
1410 dga->height = layout_height;
|
|
1411 dga->width = layout_width;
|
442
|
1412 #ifdef DEBUG_WIDGET_OUTPUT
|
|
1413 printf ("outputing layout glyph %p\n", p);
|
|
1414 #endif
|
428
|
1415 /* This makes the glyph area fit into the display area. */
|
|
1416 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1417 return;
|
|
1418
|
|
1419 /* Highly dodgy optimization. We want to only output the whole
|
|
1420 layout if we really have to. */
|
442
|
1421 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p)
|
|
1422 || IMAGE_INSTANCE_LAYOUT_CHANGED (p)
|
|
1423 || IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
|
|
1424 || IMAGE_INSTANCE_SIZE_CHANGED (p)
|
|
1425 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
|
428
|
1426 {
|
|
1427 /* First clear the area we are drawing into. This is the easiest
|
|
1428 thing to do since we have many gaps that we have to make sure are
|
|
1429 filled in. */
|
|
1430 redisplay_clear_clipped_region (window, findex, db, dga, 1, Qnil);
|
434
|
1431
|
428
|
1432 /* Output a border if required */
|
|
1433 if (!NILP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1434 {
|
|
1435 int edges = 0;
|
|
1436 enum edge_style style;
|
|
1437 int ypos = db->ypos;
|
863
|
1438 int xpos = db->xpos;
|
428
|
1439 int height = dga->height;
|
863
|
1440 int width = dga->width;
|
434
|
1441
|
863
|
1442 /* The bevel_area routines always draw in from the specified
|
|
1443 area so there is no need to adjust the displayed area to
|
|
1444 make sure that the lines are visible. */
|
|
1445 if (dga->xoffset >= 0)
|
428
|
1446 edges |= EDGE_LEFT;
|
863
|
1447 if (dga->width - dga->xoffset == layout_width)
|
428
|
1448 edges |= EDGE_RIGHT;
|
863
|
1449 if (dga->yoffset >= 0)
|
428
|
1450 edges |= EDGE_TOP;
|
|
1451 if (dga->height - dga->yoffset == layout_height)
|
|
1452 edges |= EDGE_BOTTOM;
|
863
|
1453
|
428
|
1454 if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_in))
|
|
1455 style = EDGE_ETCHED_IN;
|
|
1456 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_out))
|
|
1457 style = EDGE_ETCHED_OUT;
|
|
1458 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qbevel_in))
|
|
1459 style = EDGE_BEVEL_IN;
|
|
1460 else if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1461 {
|
|
1462 style = EDGE_ETCHED_IN;
|
|
1463 if (edges & EDGE_TOP)
|
|
1464 {
|
|
1465 ypos += XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1466 height -= XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1467 }
|
|
1468 }
|
|
1469 else
|
|
1470 style = EDGE_BEVEL_OUT;
|
|
1471
|
434
|
1472 MAYBE_DEVMETH (d, bevel_area,
|
863
|
1473 (w, findex, xpos, ypos, width, height,
|
|
1474 DEFAULT_WIDGET_SHADOW_WIDTH, edges, style));
|
428
|
1475 }
|
|
1476 }
|
434
|
1477
|
428
|
1478 /* This shrinks the display box to exactly enclose the glyph
|
|
1479 area. */
|
|
1480 redisplay_normalize_display_box (db, dga);
|
|
1481
|
|
1482 /* Flip through the widgets in the layout displaying as necessary */
|
|
1483 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (p))
|
|
1484 {
|
442
|
1485 Lisp_Object child = glyph_image_instance (XCAR (rest), image_instance,
|
793
|
1486 ERROR_ME_DEBUG_WARN, 1);
|
428
|
1487
|
|
1488 struct display_box cdb;
|
|
1489 /* For losing HP-UX */
|
|
1490 cdb.xpos = db->xpos;
|
|
1491 cdb.ypos = db->ypos;
|
|
1492 cdb.width = db->width;
|
|
1493 cdb.height = db->height;
|
|
1494
|
|
1495 /* First determine if the image is visible at all */
|
|
1496 if (IMAGE_INSTANCEP (child))
|
|
1497 {
|
440
|
1498 Lisp_Image_Instance* childii = XIMAGE_INSTANCE (child);
|
442
|
1499
|
428
|
1500 /* The enclosing layout offsets are +ve at this point */
|
|
1501 struct display_glyph_area cdga;
|
|
1502 cdga.xoffset = IMAGE_INSTANCE_XOFFSET (childii) - dga->xoffset;
|
|
1503 cdga.yoffset = IMAGE_INSTANCE_YOFFSET (childii) - dga->yoffset;
|
442
|
1504 cdga.width = glyph_width (child, image_instance);
|
|
1505 cdga.height = glyph_height (child, image_instance);
|
|
1506
|
|
1507 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) =
|
|
1508 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p);
|
428
|
1509
|
|
1510 /* Although normalization is done by the output routines
|
|
1511 we have to do it here so that they don't try and
|
|
1512 clear all of db. This is true below also. */
|
|
1513 if (redisplay_normalize_glyph_area (&cdb, &cdga))
|
|
1514 {
|
|
1515 redisplay_normalize_display_box (&cdb, &cdga);
|
|
1516 /* Since the display boxes will now be totally in the
|
|
1517 window if they are visible at all we can now check this easily. */
|
|
1518 if (cdb.xpos < db->xpos || cdb.ypos < db->ypos
|
|
1519 || cdb.xpos + cdb.width > db->xpos + db->width
|
|
1520 || cdb.ypos + cdb.height > db->ypos + db->height)
|
|
1521 continue;
|
|
1522 /* We have to invert the offset here as normalization
|
|
1523 will have made them positive which the output
|
442
|
1524 routines will treat as a truly +ve offset. */
|
428
|
1525 cdga.xoffset = -cdga.xoffset;
|
|
1526 cdga.yoffset = -cdga.yoffset;
|
|
1527
|
|
1528 switch (IMAGE_INSTANCE_TYPE (childii))
|
|
1529 {
|
|
1530 case IMAGE_TEXT:
|
|
1531 {
|
|
1532 /* #### This is well hacked and could use some
|
|
1533 generalisation.*/
|
434
|
1534 if (redisplay_normalize_glyph_area (&cdb, &cdga)
|
|
1535 &&
|
442
|
1536 (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1537 IMAGE_INSTANCE_DIRTYP (childii)))
|
428
|
1538 {
|
|
1539 struct display_line dl; /* this is fake */
|
|
1540 Lisp_Object string =
|
|
1541 IMAGE_INSTANCE_TEXT_STRING (childii);
|
442
|
1542 unsigned char charsets[NUM_LEADING_BYTES];
|
|
1543 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
1544
|
867
|
1545 find_charsets_in_ibyte_string (charsets,
|
442
|
1546 XSTRING_DATA (string),
|
|
1547 XSTRING_LENGTH (string));
|
|
1548 ensure_face_cachel_complete (cachel, window, charsets);
|
|
1549
|
867
|
1550 convert_ibyte_string_into_ichar_dynarr
|
428
|
1551 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
434
|
1552
|
428
|
1553 redisplay_normalize_display_box (&cdb, &cdga);
|
|
1554 /* Offsets are now +ve again so be careful
|
|
1555 when fixing up the display line. */
|
|
1556 xzero (dl);
|
|
1557 /* Munge boxes into display lines. */
|
|
1558 dl.ypos = (cdb.ypos - cdga.yoffset)
|
442
|
1559 + glyph_ascent (child, image_instance);
|
|
1560 dl.ascent = glyph_ascent (child, image_instance);
|
|
1561 dl.descent = glyph_descent (child, image_instance);
|
428
|
1562 dl.top_clip = cdga.yoffset;
|
|
1563 dl.clip = (dl.ypos + dl.descent) - (cdb.ypos + cdb.height);
|
|
1564 /* output_string doesn't understand offsets in
|
|
1565 the same way as other routines - we have to
|
|
1566 add the offset to the width so that we
|
|
1567 output the full string. */
|
|
1568 MAYBE_DEVMETH (d, output_string, (w, &dl, buf, cdb.xpos,
|
|
1569 cdga.xoffset, cdb.xpos,
|
|
1570 cdga.width + cdga.xoffset,
|
|
1571 findex, 0, 0, 0, 0));
|
|
1572 Dynarr_reset (buf);
|
|
1573 }
|
|
1574 }
|
|
1575 break;
|
434
|
1576
|
428
|
1577 case IMAGE_MONO_PIXMAP:
|
|
1578 case IMAGE_COLOR_PIXMAP:
|
442
|
1579 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii)
|
|
1580 || IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1581 redisplay_output_pixmap (w, child, &cdb, &cdga, findex,
|
|
1582 0, 0, 0, 0);
|
|
1583 break;
|
434
|
1584
|
428
|
1585 case IMAGE_WIDGET:
|
442
|
1586 if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (childii), Qlayout))
|
|
1587 {
|
|
1588 redisplay_output_layout (image_instance, child, &cdb, &cdga, findex,
|
|
1589 0, 0, 0);
|
|
1590 break;
|
|
1591 }
|
428
|
1592 case IMAGE_SUBWINDOW:
|
442
|
1593 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1594 IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1595 redisplay_output_subwindow (w, child, &cdb, &cdga, findex,
|
|
1596 0, 0, 0);
|
|
1597 break;
|
434
|
1598
|
428
|
1599 case IMAGE_NOTHING:
|
|
1600 /* nothing is as nothing does */
|
|
1601 break;
|
434
|
1602
|
428
|
1603 case IMAGE_POINTER:
|
|
1604 default:
|
|
1605 abort ();
|
|
1606 }
|
|
1607 }
|
442
|
1608 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) = 0;
|
428
|
1609 }
|
|
1610 }
|
442
|
1611
|
|
1612 /* Update any display properties. I'm not sure whether this actually
|
|
1613 does anything for layouts except clear the changed flags. */
|
|
1614 redisplay_subwindow (image_instance);
|
|
1615
|
428
|
1616 Dynarr_free (buf);
|
|
1617 }
|
|
1618
|
|
1619 /****************************************************************************
|
|
1620 redisplay_output_pixmap
|
|
1621
|
|
1622
|
|
1623 output a pixmap.
|
|
1624 ****************************************************************************/
|
|
1625 void
|
434
|
1626 redisplay_output_pixmap (struct window *w,
|
428
|
1627 Lisp_Object image_instance,
|
|
1628 struct display_box* db, struct display_glyph_area* dga,
|
|
1629 face_index findex, int cursor_start, int cursor_width,
|
|
1630 int cursor_height, int offset_bitmap)
|
|
1631 {
|
|
1632 struct frame *f = XFRAME (w->frame);
|
|
1633 struct device *d = XDEVICE (f->device);
|
440
|
1634 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
793
|
1635 Lisp_Object window = wrap_window (w);
|
|
1636
|
428
|
1637
|
|
1638 dga->height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
1639 dga->width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
1640
|
819
|
1641 #ifdef DEBUG_REDISPLAY
|
|
1642 printf ("redisplay_output_pixmap(request) \
|
|
1643 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
|
1644 db->width, db->height, db->xpos, db->ypos,
|
|
1645 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1646 #endif
|
|
1647
|
428
|
1648 /* This makes the glyph area fit into the display area. */
|
|
1649 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1650 return;
|
|
1651
|
819
|
1652 #ifdef DEBUG_REDISPLAY
|
|
1653 printf ("redisplay_output_pixmap(normalized) \
|
|
1654 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
|
1655 db->width, db->height, db->xpos, db->ypos,
|
|
1656 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1657 #endif
|
|
1658
|
428
|
1659 /* Clear the area the pixmap is going into. The pixmap itself will
|
|
1660 always take care of the full width. We don't want to clear where
|
|
1661 it is going to go in order to avoid flicker. So, all we have to
|
|
1662 take care of is any area above or below the pixmap. If the pixmap
|
|
1663 has a mask in which case we have to clear the whole damn thing
|
|
1664 since we can't yet clear just the area not included in the
|
|
1665 mask. */
|
|
1666 if (!offset_bitmap)
|
|
1667 {
|
|
1668 redisplay_clear_clipped_region (window, findex,
|
434
|
1669 db, dga,
|
442
|
1670 (IMAGE_INSTANCE_PIXMAP_MASK (p) != 0),
|
428
|
1671 Qnil);
|
|
1672
|
|
1673 /* This shrinks the display box to exactly enclose the glyph
|
|
1674 area. */
|
|
1675 redisplay_normalize_display_box (db, dga);
|
|
1676 }
|
|
1677 assert (db->xpos >= 0 && db->ypos >= 0);
|
|
1678
|
|
1679 MAYBE_DEVMETH (d, output_pixmap, (w, image_instance,
|
|
1680 db, dga,
|
|
1681 findex, cursor_start,
|
|
1682 cursor_width, cursor_height,
|
|
1683 offset_bitmap));
|
|
1684 }
|
|
1685
|
|
1686 /****************************************************************************
|
|
1687 redisplay_clear_region
|
|
1688
|
|
1689 Clear the area in the box defined by the given parameters using the
|
|
1690 given face. This has been generalised so that subwindows can be
|
|
1691 coped with effectively.
|
|
1692 ****************************************************************************/
|
|
1693 void
|
|
1694 redisplay_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1695 int width, int height)
|
|
1696 {
|
|
1697 struct window *w = NULL;
|
|
1698 struct frame *f = NULL;
|
|
1699 struct device *d;
|
|
1700 Lisp_Object background_pixmap = Qunbound;
|
|
1701 Lisp_Object fcolor = Qnil, bcolor = Qnil;
|
|
1702
|
|
1703 if (!width || !height)
|
|
1704 return;
|
|
1705
|
|
1706 if (WINDOWP (locale))
|
|
1707 {
|
|
1708 w = XWINDOW (locale);
|
|
1709 f = XFRAME (w->frame);
|
|
1710 }
|
|
1711 else if (FRAMEP (locale))
|
|
1712 {
|
|
1713 w = NULL;
|
|
1714 f = XFRAME (locale);
|
|
1715 }
|
|
1716 else
|
|
1717 abort ();
|
|
1718
|
|
1719 d = XDEVICE (f->device);
|
|
1720
|
|
1721 /* if we have subwindows in the region we have to unmap them */
|
|
1722 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
|
|
1723
|
|
1724 /* #### This isn't quite right for when this function is called
|
|
1725 from the toolbar code. */
|
434
|
1726
|
428
|
1727 /* Don't use a backing pixmap in the border area */
|
|
1728 if (x >= FRAME_LEFT_BORDER_END (f)
|
|
1729 && x < FRAME_RIGHT_BORDER_START (f)
|
|
1730 && y >= FRAME_TOP_BORDER_END (f)
|
|
1731 && y < FRAME_BOTTOM_BORDER_START (f))
|
|
1732 {
|
|
1733 Lisp_Object temp;
|
434
|
1734
|
428
|
1735 if (w)
|
|
1736 {
|
|
1737 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
434
|
1738
|
428
|
1739 if (IMAGE_INSTANCEP (temp)
|
|
1740 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1741 {
|
|
1742 /* #### maybe we could implement such that a string
|
|
1743 can be a background pixmap? */
|
|
1744 background_pixmap = temp;
|
|
1745 }
|
|
1746 }
|
|
1747 else
|
|
1748 {
|
|
1749 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
434
|
1750
|
428
|
1751 if (IMAGE_INSTANCEP (temp)
|
|
1752 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1753 {
|
|
1754 background_pixmap = temp;
|
|
1755 }
|
|
1756 }
|
434
|
1757 }
|
428
|
1758
|
|
1759 if (!UNBOUNDP (background_pixmap) &&
|
|
1760 XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1761 {
|
|
1762 if (w)
|
|
1763 {
|
|
1764 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1765 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1766 }
|
|
1767 else
|
|
1768 {
|
|
1769 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1770 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1771 }
|
|
1772 }
|
|
1773 else
|
|
1774 {
|
|
1775 fcolor = (w ?
|
|
1776 WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1777 FACE_BACKGROUND (Vdefault_face, locale));
|
434
|
1778
|
428
|
1779 }
|
434
|
1780
|
428
|
1781 if (UNBOUNDP (background_pixmap))
|
|
1782 background_pixmap = Qnil;
|
434
|
1783
|
|
1784 DEVMETH (d, clear_region,
|
428
|
1785 (locale, d, f, findex, x, y, width, height, fcolor, bcolor, background_pixmap));
|
|
1786 }
|
|
1787
|
|
1788 /****************************************************************************
|
|
1789 redisplay_clear_clipped_region
|
|
1790
|
|
1791 Clear the area in the dest display_box not covered by the src
|
442
|
1792 display_glyph_area using the given face. This is a common occurrence
|
428
|
1793 for images shorter than the display line. Clipping can be played
|
|
1794 around with by altering these. glyphsrc should be normalized.
|
|
1795 ****************************************************************************/
|
|
1796 static void
|
434
|
1797 redisplay_clear_clipped_region (Lisp_Object window, face_index findex,
|
|
1798 struct display_box* dest, struct display_glyph_area* glyphsrc,
|
428
|
1799 int fullheight_p, Lisp_Object ignored_subwindow)
|
|
1800 {
|
|
1801 /* assume dest->xpos >= 0 */
|
|
1802 int clear_x;
|
|
1803 struct frame* f = XFRAME (XWINDOW (window)->frame);
|
|
1804
|
|
1805 if (glyphsrc->xoffset > 0)
|
|
1806 {
|
|
1807 clear_x = dest->xpos + glyphsrc->xoffset;
|
|
1808 }
|
|
1809 else
|
|
1810 {
|
|
1811 clear_x = dest->xpos;
|
|
1812 }
|
|
1813
|
|
1814 /* If we need the whole height cleared then just do it. */
|
|
1815 if (fullheight_p)
|
|
1816 {
|
|
1817 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1818 glyphsrc->width, dest->height);
|
|
1819 }
|
|
1820 else
|
|
1821 {
|
434
|
1822 int yoffset = (glyphsrc->yoffset > 0 ? glyphsrc->yoffset : 0);
|
|
1823
|
428
|
1824 /* We need to make sure that subwindows are unmapped from the
|
|
1825 whole area. */
|
|
1826 redisplay_unmap_subwindows_except_us (f, clear_x, dest->ypos,
|
|
1827 glyphsrc->width, dest->height,
|
|
1828 ignored_subwindow);
|
|
1829 /* first the top box */
|
|
1830 if (yoffset > 0)
|
|
1831 {
|
|
1832 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1833 glyphsrc->width, yoffset);
|
434
|
1834
|
428
|
1835 }
|
|
1836 /* Then the bottom box */
|
|
1837 if (yoffset + glyphsrc->height < dest->height)
|
|
1838 {
|
|
1839 redisplay_clear_region (window, findex, clear_x,
|
|
1840 dest->ypos + yoffset + glyphsrc->height,
|
434
|
1841 glyphsrc->width,
|
428
|
1842 dest->height - (yoffset + glyphsrc->height));
|
|
1843
|
|
1844 }
|
|
1845 }
|
|
1846 }
|
|
1847
|
|
1848 /*****************************************************************************
|
|
1849 redisplay_normalize_glyph_area
|
|
1850 redisplay_normalize_display_box
|
|
1851
|
819
|
1852 Calculate the visible box for displaying glyphsrc in dest.
|
|
1853
|
|
1854 display_box and display_glyph_area are used to represent an area to
|
|
1855 displayed and where to display it. Using these two structures all
|
|
1856 combinations of clipping and position can be accommodated.
|
|
1857
|
|
1858 dest - display_box
|
|
1859
|
|
1860 xpos - absolute horizontal position of area.
|
|
1861
|
|
1862 ypos - absolute vertical position of area.
|
|
1863
|
|
1864 glyphsrc - display_glyph_area
|
|
1865
|
|
1866 xoffset - horizontal offset of the glyph, +ve means display
|
|
1867 the glyph with the x position offset by xoffset, -ve means
|
|
1868 display starting xoffset into the glyph.
|
|
1869
|
|
1870 yoffset - vertical offset of the glyph, +ve means display the
|
|
1871 glyph with y position offset by yoffset, -ve means display
|
|
1872 starting xoffset into the glyph.
|
|
1873
|
428
|
1874 ****************************************************************************/
|
|
1875 int
|
434
|
1876 redisplay_normalize_glyph_area (struct display_box* dest,
|
428
|
1877 struct display_glyph_area* glyphsrc)
|
|
1878 {
|
|
1879 if (dest->xpos + glyphsrc->xoffset > dest->xpos + dest->width
|
|
1880 ||
|
|
1881 dest->ypos + glyphsrc->yoffset > dest->ypos + dest->height
|
|
1882 ||
|
|
1883 -glyphsrc->xoffset >= glyphsrc->width
|
|
1884 ||
|
448
|
1885 -glyphsrc->yoffset >= glyphsrc->height
|
|
1886 ||
|
|
1887 /* #### Not sure why this wasn't coped with before but normalizing
|
|
1888 to zero width or height is definitely wrong. */
|
|
1889 (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width
|
|
1890 &&
|
|
1891 dest->width - glyphsrc->xoffset <= 0)
|
|
1892 ||
|
|
1893 (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height
|
|
1894 &&
|
|
1895 dest->height - glyphsrc->yoffset <= 0))
|
428
|
1896 {
|
|
1897 /* It's all clipped out */
|
|
1898 return 0;
|
|
1899 }
|
|
1900
|
819
|
1901 /* Horizontal offsets. This works because xoffset can be -ve as well
|
|
1902 as +ve. When we enter this function the glyphsrc width and
|
|
1903 height are set to the actual glyph width and height irrespective
|
|
1904 of how much can be displayed. We are trying to clip both the
|
|
1905 offset into the image and the rightmost bounding box. Its
|
|
1906 possible for the glyph width to be much larger than the area we
|
|
1907 are displaying into (e.g. a large glyph in a small frame). */
|
428
|
1908 if (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width)
|
|
1909 {
|
819
|
1910 /* glyphsrc offset is +ve we are trying to display offset from the
|
|
1911 origin (the bounding box contains some space and then the
|
|
1912 glyph). At most the width we want to display is dest->width -
|
|
1913 glyphsrc->xoffset. */
|
428
|
1914 if (glyphsrc->xoffset > 0)
|
|
1915 glyphsrc->width = dest->width - glyphsrc->xoffset;
|
819
|
1916 /* glyphsrc offset is -ve we are trying to display hard up
|
|
1917 against the dest corner inset into the glyphsrc by
|
|
1918 xoffset.*/
|
|
1919 else if (glyphsrc->xoffset < 0)
|
|
1920 {
|
|
1921 glyphsrc->width += glyphsrc->xoffset;
|
|
1922 glyphsrc->width = min (glyphsrc->width, dest->width);
|
|
1923 }
|
428
|
1924 else
|
|
1925 glyphsrc->width = dest->width;
|
|
1926 }
|
|
1927
|
819
|
1928 else if (glyphsrc->xoffset < 0)
|
428
|
1929 glyphsrc->width += glyphsrc->xoffset;
|
|
1930
|
|
1931 /* Vertical offsets. This works because yoffset can be -ve as well as +ve */
|
|
1932 if (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height)
|
|
1933 {
|
819
|
1934 if ((glyphsrc->yoffset > 0) && (dest->height > glyphsrc->yoffset))
|
428
|
1935 glyphsrc->height = dest->height - glyphsrc->yoffset;
|
819
|
1936 else if (glyphsrc->yoffset < 0)
|
|
1937 {
|
|
1938 glyphsrc->height += glyphsrc->yoffset;
|
|
1939 glyphsrc->height = min (glyphsrc->height, dest->height);
|
|
1940 }
|
428
|
1941 else
|
|
1942 glyphsrc->height = dest->height;
|
|
1943 }
|
|
1944
|
819
|
1945 else if (glyphsrc->yoffset < 0)
|
428
|
1946 glyphsrc->height += glyphsrc->yoffset;
|
|
1947
|
|
1948 return 1;
|
|
1949 }
|
|
1950
|
|
1951 static void
|
434
|
1952 redisplay_normalize_display_box (struct display_box* dest,
|
428
|
1953 struct display_glyph_area* glyphsrc)
|
|
1954 {
|
|
1955 /* Adjust the destination area. At the end of this the destination
|
|
1956 area will exactly enclose the glyph area. The only remaining
|
|
1957 adjustment will be offsets into the glyph area. */
|
|
1958
|
|
1959 /* Horizontal adjustment. */
|
|
1960 if (glyphsrc->xoffset > 0)
|
|
1961 {
|
|
1962 dest->xpos += glyphsrc->xoffset;
|
|
1963 dest->width -= glyphsrc->xoffset;
|
|
1964 glyphsrc->xoffset = 0;
|
|
1965 }
|
|
1966 else
|
|
1967 glyphsrc->xoffset = -glyphsrc->xoffset;
|
|
1968
|
|
1969 if (glyphsrc->width < dest->width)
|
|
1970 dest->width = glyphsrc->width;
|
|
1971
|
|
1972 /* Vertical adjustment. */
|
|
1973 if (glyphsrc->yoffset > 0)
|
|
1974 {
|
|
1975 dest->ypos += glyphsrc->yoffset;
|
|
1976 dest->height -= glyphsrc->yoffset;
|
|
1977 glyphsrc->yoffset = 0;
|
|
1978 }
|
|
1979 else
|
|
1980 glyphsrc->yoffset = -glyphsrc->yoffset;
|
|
1981
|
|
1982 if (glyphsrc->height < dest->height)
|
|
1983 dest->height = glyphsrc->height;
|
|
1984 }
|
|
1985
|
|
1986 /*****************************************************************************
|
|
1987 redisplay_display_boxes_in_window_p
|
|
1988
|
446
|
1989 Determine whether the required display_glyph_area is completely inside
|
|
1990 the window. -1 means the display_box is not in the window. 1 means the
|
|
1991 display_box and the display_glyph_area are in the window. 0 means
|
428
|
1992 the display_box is in the window but the display_glyph_area is not.
|
|
1993 ****************************************************************************/
|
|
1994 static int
|
|
1995 redisplay_display_boxes_in_window_p (struct window* w,
|
|
1996 struct display_box* db,
|
|
1997 struct display_glyph_area* dga)
|
|
1998 {
|
|
1999 int left = WINDOW_TEXT_LEFT (w);
|
|
2000 int right = WINDOW_TEXT_RIGHT (w);
|
|
2001 int top = WINDOW_TEXT_TOP (w);
|
|
2002 int bottom = WINDOW_TEXT_BOTTOM (w);
|
|
2003
|
|
2004 if (db->xpos < left || db->ypos < top
|
|
2005 || db->xpos + db->width > right
|
|
2006 || db->ypos + db->height > bottom)
|
446
|
2007 /* We are not displaying in a window at all */
|
|
2008 return -1;
|
434
|
2009
|
428
|
2010 if (db->xpos + dga->xoffset >= left
|
|
2011 &&
|
|
2012 db->ypos + dga->yoffset >= top
|
|
2013 &&
|
|
2014 db->xpos + dga->xoffset + dga->width <= right
|
|
2015 &&
|
|
2016 db->ypos + dga->yoffset + dga->height <= bottom)
|
|
2017 return 1;
|
|
2018
|
446
|
2019 return 0;
|
428
|
2020 }
|
|
2021
|
|
2022 /*****************************************************************************
|
|
2023 redisplay_calculate_display_boxes
|
|
2024
|
|
2025 Convert from rune/display_line co-ordinates to display_box
|
|
2026 co-ordinates.
|
|
2027 ****************************************************************************/
|
|
2028 int
|
|
2029 redisplay_calculate_display_boxes (struct display_line *dl, int xpos,
|
819
|
2030 int xoffset, int yoffset, int start_pixpos,
|
|
2031 int width, struct display_box* dest,
|
428
|
2032 struct display_glyph_area* src)
|
|
2033 {
|
|
2034 dest->xpos = xpos;
|
|
2035 dest->ypos = DISPLAY_LINE_YPOS (dl);
|
|
2036 dest->width = width;
|
|
2037 dest->height = DISPLAY_LINE_HEIGHT (dl);
|
|
2038
|
|
2039 src->xoffset = -xoffset;
|
|
2040 src->width = 0;
|
|
2041 src->height = 0;
|
|
2042
|
819
|
2043 src->yoffset = -dl->top_clip + yoffset;
|
|
2044
|
428
|
2045 if (start_pixpos >=0 && start_pixpos > xpos)
|
|
2046 {
|
|
2047 /* Oops, we're asking for a start outside of the displayable
|
|
2048 area. */
|
|
2049 if (start_pixpos > xpos + width)
|
|
2050 return 0;
|
|
2051 dest->xpos = start_pixpos;
|
|
2052 dest->width -= (start_pixpos - xpos);
|
|
2053 /* Offsets are -ve when we want to clip pixels off the displayed
|
|
2054 glyph. */
|
|
2055 src->xoffset -= (start_pixpos - xpos);
|
|
2056 }
|
|
2057
|
|
2058 return 1;
|
|
2059 }
|
|
2060
|
|
2061 /*****************************************************************************
|
|
2062 redisplay_clear_top_of_window
|
|
2063
|
|
2064 If window is topmost, clear the internal border above it.
|
|
2065 ****************************************************************************/
|
448
|
2066 void
|
428
|
2067 redisplay_clear_top_of_window (struct window *w)
|
|
2068 {
|
793
|
2069 Lisp_Object window = wrap_window (w);
|
|
2070
|
428
|
2071
|
|
2072 if (!NILP (Fwindow_highest_p (window)))
|
|
2073 {
|
|
2074 struct frame *f = XFRAME (w->frame);
|
|
2075 int x, y, width, height;
|
|
2076
|
|
2077 x = w->pixel_left;
|
|
2078 width = w->pixel_width;
|
|
2079
|
|
2080 if (window_is_leftmost (w))
|
|
2081 {
|
|
2082 x -= FRAME_BORDER_WIDTH (f);
|
|
2083 width += FRAME_BORDER_WIDTH (f);
|
|
2084 }
|
|
2085 if (window_is_rightmost (w))
|
|
2086 width += FRAME_BORDER_WIDTH (f);
|
|
2087
|
|
2088 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
2089 height = FRAME_BORDER_HEIGHT (f) + 1;
|
|
2090
|
|
2091 redisplay_clear_region (window, DEFAULT_INDEX, x, y, width, height);
|
|
2092 }
|
|
2093 }
|
|
2094
|
|
2095 /*****************************************************************************
|
|
2096 redisplay_clear_to_window_end
|
|
2097
|
|
2098 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
2099 text area is handled separately since they may each have their own
|
|
2100 background color.
|
|
2101 ****************************************************************************/
|
|
2102 void
|
|
2103 redisplay_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
2104 {
|
|
2105 struct frame *f = XFRAME (w->frame);
|
|
2106 struct device *d = XDEVICE (f->device);
|
|
2107
|
|
2108 if (HAS_DEVMETH_P (d, clear_to_window_end))
|
|
2109 DEVMETH (d, clear_to_window_end, (w, ypos1, ypos2));
|
|
2110 else
|
|
2111 {
|
|
2112 int height = ypos2 - ypos1;
|
434
|
2113
|
428
|
2114 if (height)
|
|
2115 {
|
|
2116 Lisp_Object window;
|
|
2117 int bflag = 0 ; /* (window_needs_vertical_divider (w) ? 0 : 1);*/
|
|
2118 layout_bounds bounds;
|
434
|
2119
|
428
|
2120 bounds = calculate_display_line_boundaries (w, bflag);
|
793
|
2121 window = wrap_window (w);
|
428
|
2122
|
|
2123 if (window_is_leftmost (w))
|
|
2124 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
2125 ypos1, FRAME_BORDER_WIDTH (f), height);
|
434
|
2126
|
428
|
2127 if (bounds.left_in - bounds.left_out > 0)
|
|
2128 redisplay_clear_region (window,
|
|
2129 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
2130 bounds.left_out, ypos1,
|
|
2131 bounds.left_in - bounds.left_out, height);
|
434
|
2132
|
428
|
2133 if (bounds.right_in - bounds.left_in > 0)
|
434
|
2134 redisplay_clear_region (window,
|
428
|
2135 DEFAULT_INDEX,
|
|
2136 bounds.left_in, ypos1,
|
|
2137 bounds.right_in - bounds.left_in, height);
|
434
|
2138
|
428
|
2139 if (bounds.right_out - bounds.right_in > 0)
|
|
2140 redisplay_clear_region (window,
|
|
2141 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
2142 bounds.right_in, ypos1,
|
|
2143 bounds.right_out - bounds.right_in, height);
|
434
|
2144
|
428
|
2145 if (window_is_rightmost (w))
|
|
2146 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
2147 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
2148 }
|
|
2149 }
|
|
2150 }
|
|
2151
|
|
2152 /*****************************************************************************
|
|
2153 redisplay_clear_bottom_of_window
|
|
2154
|
|
2155 Clear window from right below the last display line to right above
|
|
2156 the modeline. The calling function can limit the area actually
|
|
2157 erased by setting min_start and/or max_end to positive values.
|
|
2158 ****************************************************************************/
|
|
2159 void
|
|
2160 redisplay_clear_bottom_of_window (struct window *w, display_line_dynarr *ddla,
|
|
2161 int min_start, int max_end)
|
|
2162 {
|
|
2163 struct frame *f = XFRAME (w->frame);
|
|
2164 int ypos1, ypos2;
|
|
2165 int ddla_len = Dynarr_length (ddla);
|
|
2166
|
|
2167 ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
2168 #ifdef HAVE_SCROLLBARS
|
|
2169 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2170 if (f->windows_structure_changed && NILP (w->scrollbar_on_top_p))
|
|
2171 ypos2 += window_scrollbar_height (w);
|
|
2172 #endif
|
|
2173
|
|
2174 if (ddla_len)
|
|
2175 {
|
|
2176 if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline)
|
|
2177 {
|
|
2178 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2179 #ifdef HAVE_SCROLLBARS
|
|
2180 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2181 if (f->windows_structure_changed && !NILP (w->scrollbar_on_top_p))
|
|
2182 ypos1 -= window_scrollbar_height (w);
|
|
2183 #endif
|
|
2184 }
|
|
2185 else
|
|
2186 {
|
|
2187 struct display_line *dl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2188 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
2189 }
|
|
2190 }
|
|
2191 else
|
|
2192 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2193
|
|
2194 /* #### See if this can be made conditional on the frame
|
|
2195 changing size. */
|
|
2196 if (MINI_WINDOW_P (w))
|
|
2197 ypos2 += FRAME_BORDER_HEIGHT (f);
|
|
2198
|
|
2199 if (min_start >= 0 && ypos1 < min_start)
|
|
2200 ypos1 = min_start;
|
|
2201 if (max_end >= 0 && ypos2 > max_end)
|
|
2202 ypos2 = max_end;
|
|
2203
|
|
2204 if (ypos2 <= ypos1)
|
|
2205 return;
|
|
2206
|
|
2207 redisplay_clear_to_window_end (w, ypos1, ypos2);
|
|
2208 }
|
|
2209
|
|
2210 /*****************************************************************************
|
|
2211 redisplay_update_line
|
|
2212
|
|
2213 This is used during incremental updates to update a single line and
|
|
2214 correct the offsets on all lines below it. At the moment
|
|
2215 update_values is false if we are only updating the modeline.
|
|
2216 ****************************************************************************/
|
|
2217 void
|
|
2218 redisplay_update_line (struct window *w, int first_line, int last_line,
|
|
2219 int update_values)
|
|
2220 {
|
|
2221 struct frame *f = XFRAME (w->frame);
|
|
2222 struct device *d = XDEVICE (f->device);
|
|
2223
|
|
2224 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2225 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2226
|
442
|
2227 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2228
|
|
2229 while (first_line <= last_line)
|
|
2230 {
|
826
|
2231 Charcount old_len = (Dynarr_atp (cdla, first_line)->end_charpos -
|
|
2232 Dynarr_atp (cdla, first_line)->charpos);
|
|
2233 Charcount new_len = (Dynarr_atp (ddla, first_line)->end_charpos -
|
|
2234 Dynarr_atp (ddla, first_line)->charpos);
|
428
|
2235
|
|
2236 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
2237
|
|
2238 /* Output the changes. */
|
|
2239 output_display_line (w, cdla, ddla, first_line, -1, -1);
|
|
2240
|
|
2241 /* Update the offsets. */
|
|
2242 if (update_values)
|
|
2243 {
|
|
2244 int cur_line = first_line + 1;
|
|
2245 while (cur_line < Dynarr_length (cdla))
|
|
2246 {
|
|
2247 Dynarr_atp (cdla, cur_line)->offset += (new_len - old_len);
|
|
2248 Dynarr_atp (ddla, cur_line)->offset += (new_len - old_len);
|
|
2249 cur_line++;
|
|
2250 }
|
|
2251 }
|
|
2252
|
|
2253 /* Update the window_end_pos and other settings. */
|
|
2254 if (update_values)
|
|
2255 {
|
|
2256 w->window_end_pos[CURRENT_DISP] -= (new_len - old_len);
|
|
2257
|
|
2258 if (Dynarr_atp (ddla, first_line)->cursor_elt != -1)
|
|
2259 {
|
|
2260 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2261 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2262 }
|
|
2263 }
|
|
2264
|
|
2265 first_line++;
|
|
2266 }
|
|
2267
|
|
2268 /* Update the window max line length. We have to scan the entire
|
|
2269 set of display lines otherwise we might not detect if the max is
|
|
2270 supposed to shrink. */
|
|
2271 if (update_values)
|
|
2272 {
|
|
2273 int line = 0;
|
|
2274
|
|
2275 w->max_line_len = 0;
|
|
2276 while (line < Dynarr_length (ddla))
|
|
2277 {
|
|
2278 struct display_line *dl = Dynarr_atp (ddla, line);
|
|
2279
|
|
2280 if (!dl->modeline)
|
|
2281 w->max_line_len = max (dl->num_chars, w->max_line_len);
|
|
2282
|
|
2283 line++;
|
|
2284 }
|
|
2285 }
|
|
2286
|
|
2287 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2288 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2289 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2290 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2291 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2292 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2293
|
|
2294 /* We don't bother updating the vertical scrollbars here. This
|
|
2295 gives us a performance increase while having minimal loss of
|
|
2296 quality to the scrollbar slider size and position since when this
|
|
2297 function is called we know that the changes to the buffer were
|
|
2298 very localized. We have to update the horizontal scrollbars,
|
|
2299 though, because this routine could cause a change which has a
|
|
2300 larger impact on their sizing. */
|
|
2301 /* #### See if we can get away with only calling this if
|
|
2302 max_line_len is greater than the window_char_width. */
|
462
|
2303 /* #### BILL!!! Should we do this for GTK as well? */
|
428
|
2304 #if defined(HAVE_SCROLLBARS) && defined(HAVE_X_WINDOWS)
|
|
2305 {
|
|
2306 extern int stupid_vertical_scrollbar_drag_hack;
|
|
2307
|
|
2308 update_window_scrollbars (w, NULL, 1, stupid_vertical_scrollbar_drag_hack);
|
|
2309 stupid_vertical_scrollbar_drag_hack = 1;
|
|
2310 }
|
|
2311 #endif
|
|
2312
|
442
|
2313 redisplay_redraw_cursor (f, 0);
|
|
2314 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2315 }
|
|
2316
|
|
2317 /*****************************************************************************
|
|
2318 redisplay_output_window
|
|
2319
|
|
2320 For the given window W, ensure that the current display lines are
|
|
2321 equal to the desired display lines, outputing changes as necessary.
|
|
2322
|
|
2323 #### Fuck me. This just isn't going to cut it for tty's. The output
|
|
2324 decisions for them must be based on the contents of the entire frame
|
|
2325 because that is how the available output capabilities think. The
|
|
2326 solution is relatively simple. Create redisplay_output_frame. This
|
|
2327 will basically merge all of the separate window display structs into
|
|
2328 a single one for the frame. This combination structure will be able
|
|
2329 to be passed to the same output_display_line which works for windows
|
|
2330 on X frames and the right things will happen. It just takes time to
|
|
2331 do.
|
|
2332 ****************************************************************************/
|
|
2333 void
|
|
2334 redisplay_output_window (struct window *w)
|
|
2335 {
|
|
2336 struct frame *f = XFRAME (w->frame);
|
|
2337 struct device *d = XDEVICE (f->device);
|
|
2338
|
|
2339 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2340 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2341
|
|
2342 int cdla_len = Dynarr_length (cdla);
|
|
2343 int ddla_len = Dynarr_length (ddla);
|
|
2344
|
|
2345 int line;
|
|
2346 int need_to_clear_bottom = 0;
|
|
2347 int need_to_clear_start = -1;
|
|
2348 int need_to_clear_end = -1;
|
|
2349
|
|
2350 /* Backgrounds may have changed or windows may have gone away
|
|
2351 leaving dividers lying around. */
|
|
2352 if (f->faces_changed
|
|
2353 || f->windows_structure_changed
|
|
2354 || w->shadow_thickness_changed)
|
|
2355 need_to_clear_bottom = 1;
|
|
2356
|
|
2357 /* The first thing we do is determine if we are going to need to
|
|
2358 clear the bottom of the window. We only need to do this if the
|
|
2359 bottom of the current display lines is below the bottom of the
|
|
2360 desired display lines. Note that the number of lines is
|
|
2361 irrelevant. Only the position matters. We also clear to the
|
|
2362 bottom of the window if the modeline has shifted position. */
|
|
2363 /* #### We can't blindly not clear the bottom if f->clear is true
|
|
2364 since there might be a window-local background. However, for
|
|
2365 those cases where there isn't, clearing the end of the window in
|
|
2366 this case sucks. */
|
|
2367 if (!need_to_clear_bottom)
|
|
2368 {
|
|
2369 struct display_line *cdl, *ddl;
|
|
2370
|
|
2371 /* If the modeline has changed position or size, clear the bottom
|
|
2372 of the window. */
|
|
2373 if (!need_to_clear_bottom)
|
|
2374 {
|
|
2375 cdl = ddl = 0;
|
|
2376
|
|
2377 if (cdla_len)
|
|
2378 cdl = Dynarr_atp (cdla, 0);
|
|
2379 if (ddla_len)
|
|
2380 ddl = Dynarr_atp (ddla, 0);
|
|
2381
|
|
2382 if (!cdl || !ddl)
|
|
2383 need_to_clear_bottom = 1;
|
|
2384 else if ((!cdl->modeline && ddl->modeline)
|
|
2385 || (cdl->modeline && !ddl->modeline))
|
|
2386 need_to_clear_bottom = 1;
|
|
2387 else if (cdl->ypos != ddl->ypos ||
|
|
2388 cdl->ascent != ddl->ascent ||
|
|
2389 cdl->descent != ddl->descent ||
|
|
2390 cdl->clip != ddl->clip)
|
|
2391 need_to_clear_bottom = 1;
|
|
2392
|
|
2393 /* #### This kludge is to make sure the modeline shadows get
|
|
2394 redrawn if the modeline position shifts. */
|
|
2395 if (need_to_clear_bottom)
|
|
2396 w->shadow_thickness_changed = 1;
|
|
2397 }
|
|
2398
|
|
2399 if (!need_to_clear_bottom)
|
|
2400 {
|
|
2401 cdl = ddl = 0;
|
|
2402
|
|
2403 if (cdla_len)
|
|
2404 cdl = Dynarr_atp (cdla, cdla_len - 1);
|
|
2405 if (ddla_len)
|
|
2406 ddl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2407
|
|
2408 if (!cdl || !ddl)
|
|
2409 need_to_clear_bottom = 1;
|
|
2410 else
|
|
2411 {
|
|
2412 int cdl_bottom, ddl_bottom;
|
|
2413
|
|
2414 cdl_bottom = cdl->ypos + cdl->descent;
|
|
2415 ddl_bottom = ddl->ypos + ddl->descent;
|
|
2416
|
|
2417 if (cdl_bottom > ddl_bottom)
|
|
2418 {
|
|
2419 need_to_clear_bottom = 1;
|
|
2420 need_to_clear_start = ddl_bottom;
|
|
2421 need_to_clear_end = cdl_bottom;
|
|
2422 }
|
|
2423 }
|
|
2424 }
|
|
2425 }
|
|
2426
|
|
2427 /* Perform any output initialization. */
|
442
|
2428 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2429
|
|
2430 /* If the window's structure has changed clear the internal border
|
|
2431 above it if it is topmost (the function will check). */
|
448
|
2432 if (f->windows_structure_changed || f->faces_changed)
|
428
|
2433 redisplay_clear_top_of_window (w);
|
|
2434
|
|
2435 /* Output each line. */
|
|
2436 for (line = 0; line < Dynarr_length (ddla); line++)
|
|
2437 {
|
|
2438 output_display_line (w, cdla, ddla, line, -1, -1);
|
|
2439 }
|
|
2440
|
|
2441 /* If the number of display lines has shrunk, adjust. */
|
|
2442 if (cdla_len > ddla_len)
|
|
2443 {
|
|
2444 Dynarr_length (cdla) = ddla_len;
|
|
2445 }
|
|
2446
|
|
2447 /* Output a vertical divider between windows, if necessary. */
|
|
2448 if (window_needs_vertical_divider (w)
|
|
2449 && (f->windows_structure_changed || f->clear))
|
|
2450 {
|
442
|
2451 MAYBE_DEVMETH (d, output_vertical_divider, (w, f->windows_structure_changed));
|
428
|
2452 }
|
|
2453
|
|
2454 /* Clear the rest of the window, if necessary. */
|
|
2455 if (need_to_clear_bottom)
|
|
2456 {
|
|
2457 redisplay_clear_bottom_of_window (w, ddla, need_to_clear_start,
|
|
2458 need_to_clear_end);
|
|
2459 }
|
|
2460
|
|
2461 w->window_end_pos[CURRENT_DISP] = w->window_end_pos[DESIRED_DISP];
|
|
2462 Fset_marker (w->start[CURRENT_DISP],
|
|
2463 make_int (marker_position (w->start[DESIRED_DISP])),
|
|
2464 w->buffer);
|
|
2465 Fset_marker (w->pointm[CURRENT_DISP],
|
|
2466 make_int (marker_position (w->pointm[DESIRED_DISP])),
|
|
2467 w->buffer);
|
|
2468 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2469 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2470 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2471 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2472 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2473 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2474 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2475 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2476 w->shadow_thickness_changed = 0;
|
|
2477
|
|
2478 set_window_display_buffer (w, XBUFFER (w->buffer));
|
|
2479 find_window_mirror (w)->truncate_win = window_truncation_on (w);
|
|
2480
|
|
2481 /* Overkill on invalidating the cache. It is very bad for it to not
|
|
2482 get invalidated when it should be. */
|
|
2483 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (d);
|
|
2484
|
442
|
2485 redisplay_redraw_cursor (f, 0);
|
|
2486 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2487
|
|
2488 #ifdef HAVE_SCROLLBARS
|
|
2489 update_window_scrollbars (w, NULL, !MINI_WINDOW_P (w), 0);
|
|
2490 #endif
|
|
2491 }
|
|
2492
|
|
2493 /*****************************************************************************
|
|
2494 bevel_modeline
|
|
2495
|
|
2496 Draw a 3d border around the modeline on window W.
|
|
2497 ****************************************************************************/
|
|
2498 void
|
|
2499 bevel_modeline (struct window *w, struct display_line *dl)
|
|
2500 {
|
|
2501 struct frame *f = XFRAME (w->frame);
|
|
2502 struct device *d = XDEVICE (f->device);
|
|
2503 int x, y, width, height;
|
|
2504 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
2505 enum edge_style style;
|
|
2506
|
|
2507 x = WINDOW_MODELINE_LEFT (w);
|
|
2508 width = WINDOW_MODELINE_RIGHT (w) - x;
|
|
2509 y = dl->ypos - dl->ascent - shadow_thickness;
|
|
2510 height = dl->ascent + dl->descent + 2 * shadow_thickness;
|
|
2511
|
|
2512 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
2513 {
|
|
2514 style = EDGE_BEVEL_IN;
|
|
2515 }
|
|
2516 else
|
|
2517 {
|
|
2518 style = EDGE_BEVEL_OUT;
|
|
2519 }
|
|
2520
|
434
|
2521 MAYBE_DEVMETH (d, bevel_area,
|
428
|
2522 (w, MODELINE_INDEX, x, y, width, height, shadow_thickness,
|
|
2523 EDGE_ALL, style));
|
|
2524 }
|