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