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