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
|
|
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? */
|
|
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 ||
|
|
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
|
|
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 (). */
|
|
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);
|
|
343
|
|
344 if (!IMAGE_INSTANCEP (image))
|
|
345 return 0;
|
|
346 ii = XIMAGE_INSTANCE (image);
|
|
347
|
|
348 if (TEXT_IMAGE_INSTANCEP (image) &&
|
|
349 (crb->findex != drb->findex ||
|
|
350 WINDOW_FACE_CACHEL_DIRTY (w, drb->findex)))
|
|
351 return 0;
|
|
352
|
|
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.
|
|
369
|
|
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
|
|
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. */
|
|
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
|
|
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. */
|
|
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
|
|
730 the size changed. */
|
|
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
|
|
756 between start_pos and next_start if necessary. */
|
|
757 if (block == NO_BLOCK)
|
|
758 {
|
|
759 /* We only erase those areas which were actually previously
|
|
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. */
|
|
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 {
|
|
798 findex = ddl->left_margin_findex ?
|
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 {
|
|
804 /* no check here because DEFAULT_INDEX == 0 anyway */
|
|
805 findex = ddl->default_findex;
|
|
806 }
|
|
807 else if (x < ddl->bounds.right_out)
|
|
808 {
|
|
809 findex = ddl->right_margin_findex ?
|
434
|
810 ddl->right_margin_findex
|
428
|
811 : get_builtin_face_cache_index (w, Vright_margin_face);
|
|
812 }
|
|
813 else
|
|
814 findex = (face_index) -1;
|
|
815
|
|
816 if (findex != (face_index) -1)
|
|
817 {
|
793
|
818 Lisp_Object window = wrap_window (w);
|
428
|
819
|
|
820
|
|
821 /* Clear the empty area. */
|
|
822 redisplay_clear_region (window, findex, x, y, width, height);
|
|
823
|
|
824 /* Mark that we should clear the border. This is
|
|
825 necessary because italic fonts may leave
|
|
826 droppings in the border. */
|
|
827 clear_border = 1;
|
|
828 }
|
|
829 }
|
|
830
|
|
831 start_pixpos = min (next_start_pixpos, block_end);
|
|
832 }
|
|
833 }
|
|
834 else
|
|
835 {
|
|
836 struct display_block *cdb, *ddb;
|
|
837 int block_end;
|
|
838 int old_block;
|
|
839
|
|
840 if (cdba)
|
|
841 old_block = get_next_display_block (ddl->bounds, cdba,
|
|
842 start_pixpos, &block_end);
|
|
843 else
|
|
844 old_block = NO_BLOCK;
|
|
845
|
|
846 ddb = Dynarr_atp (ddba, block);
|
|
847 cdb = (old_block != NO_BLOCK ? Dynarr_atp (cdba, old_block) : 0);
|
|
848
|
|
849 /* If there was formerly no block over the current
|
|
850 region or if it was a block of a different type, then
|
|
851 output the entire ddb. Otherwise, compare cdb and
|
|
852 ddb and output only the changed region. */
|
434
|
853 if (!force && cdb && ddb->type == cdb->type
|
428
|
854 /* If there was no buffer being display before the
|
|
855 compare anyway as we might be outputting a gutter. */
|
434
|
856 &&
|
428
|
857 (b == old_b || !old_b))
|
|
858 {
|
|
859 must_sync |= compare_display_blocks (w, cdl, ddl, old_block,
|
|
860 block, start_pixpos,
|
|
861 cursor_start, cursor_width,
|
|
862 cursor_height);
|
|
863 }
|
|
864 else
|
|
865 {
|
|
866 int elt;
|
|
867 int first_elt = 0;
|
|
868 int last_elt = -1;
|
|
869
|
|
870 for (elt = 0; elt < Dynarr_length (ddb->runes); elt++)
|
|
871 {
|
|
872 struct rune *rb = Dynarr_atp (ddb->runes, elt);
|
|
873
|
|
874 if (start_pixpos >= rb->xpos
|
|
875 && start_pixpos < rb->xpos + rb->width)
|
|
876 first_elt = elt;
|
|
877
|
|
878 if (end_pixpos > rb->xpos
|
|
879 && end_pixpos <= rb->xpos + rb->width)
|
|
880 {
|
|
881 last_elt = elt + 1;
|
|
882 if (last_elt > Dynarr_length (ddb->runes))
|
|
883 last_elt = Dynarr_length (ddb->runes);
|
|
884 break;
|
|
885 }
|
|
886 }
|
|
887
|
|
888 must_sync = 1;
|
|
889 redisplay_output_display_block (w, ddl, block, first_elt,
|
|
890 last_elt,
|
|
891 start_pixpos,
|
|
892 cursor_start, cursor_width,
|
|
893 cursor_height);
|
|
894 }
|
434
|
895
|
428
|
896 start_pixpos = next_start_pixpos;
|
|
897 }
|
|
898 }
|
|
899
|
|
900 /* Clear the internal border if we are next to it and the window
|
|
901 structure or frame size has changed or if something caused
|
|
902 clear_border to be tripped. */
|
|
903 /* #### Doing this on f->clear sucks but is necessary because of
|
|
904 window-local background values. */
|
|
905 if (f->windows_structure_changed || f->faces_changed || clear_border
|
|
906 || f->clear)
|
|
907 {
|
|
908 int y = DISPLAY_LINE_YPOS (ddl);
|
|
909 int height = DISPLAY_LINE_HEIGHT (ddl);
|
|
910
|
|
911 /* If we are in the gutter then we musn't clear the borders. */
|
|
912 if (y >= WINDOW_TEXT_TOP (w) && (y + height) <= WINDOW_TEXT_BOTTOM (w))
|
|
913 {
|
|
914 if (ddl->modeline)
|
|
915 {
|
|
916 y -= MODELINE_SHADOW_THICKNESS (w);
|
|
917 height += (2 * MODELINE_SHADOW_THICKNESS (w));
|
|
918 }
|
434
|
919
|
428
|
920 if (window_is_leftmost (w))
|
|
921 clear_left_border (w, y, height);
|
|
922 if (window_is_rightmost (w))
|
|
923 clear_right_border (w, y, height);
|
|
924 }
|
|
925 }
|
|
926
|
|
927 if (cdla)
|
|
928 sync_display_line_structs (w, line, must_sync, cdla, ddla);
|
|
929 }
|
|
930
|
|
931 /*****************************************************************************
|
|
932 redisplay_move_cursor
|
|
933
|
|
934 For the given window W, move the cursor to NEW_POINT. Returns a
|
|
935 boolean indicating success or failure.
|
|
936 ****************************************************************************/
|
|
937
|
826
|
938 #define ADJ_CHARPOS (rb->charpos + dl->offset)
|
428
|
939 #define ADJ_ENDPOS (rb->endpos + dl->offset)
|
|
940
|
|
941 int
|
665
|
942 redisplay_move_cursor (struct window *w, Charbpos new_point, int no_output_end)
|
428
|
943 {
|
|
944 struct frame *f = XFRAME (w->frame);
|
|
945 struct device *d = XDEVICE (f->device);
|
|
946
|
|
947 display_line_dynarr *cla = window_display_lines (w, CURRENT_DISP);
|
|
948 struct display_line *dl;
|
|
949 struct display_block *db;
|
|
950 struct rune *rb;
|
|
951 int x = w->last_point_x[CURRENT_DISP];
|
|
952 int y = w->last_point_y[CURRENT_DISP];
|
|
953
|
|
954 /*
|
|
955 * Bail if cursor_in_echo_area is non-zero and we're fiddling with
|
|
956 * the cursor in a non-active minibuffer window, since that is a
|
|
957 * special case that is handled elsewhere and this function need
|
|
958 * not handle it. Return 1 so the caller will assume we
|
|
959 * succeeded.
|
|
960 */
|
|
961 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
962 w != XWINDOW (FRAME_SELECTED_WINDOW (f)))
|
|
963 return 1;
|
|
964
|
|
965 if (y < 0 || y >= Dynarr_length (cla))
|
|
966 return 0;
|
|
967
|
|
968 dl = Dynarr_atp (cla, y);
|
|
969 db = get_display_block_from_line (dl, TEXT);
|
|
970
|
|
971 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
972 return 0;
|
|
973
|
|
974 rb = Dynarr_atp (db->runes, x);
|
|
975
|
|
976 if (rb->cursor_type == CURSOR_OFF)
|
|
977 return 0;
|
826
|
978 else if (ADJ_CHARPOS == new_point
|
|
979 || (ADJ_ENDPOS && (new_point >= ADJ_CHARPOS)
|
428
|
980 && (new_point <= ADJ_ENDPOS)))
|
|
981 {
|
|
982 w->last_point_x[CURRENT_DISP] = x;
|
|
983 w->last_point_y[CURRENT_DISP] = y;
|
826
|
984 Fset_marker (w->last_point[CURRENT_DISP], make_int (ADJ_CHARPOS),
|
428
|
985 w->buffer);
|
|
986 dl->cursor_elt = x;
|
|
987 return 1;
|
|
988 }
|
|
989 else
|
|
990 {
|
442
|
991 {
|
|
992 MAYBE_DEVMETH (d, frame_output_begin, (f));
|
|
993 MAYBE_DEVMETH (d, window_output_begin, (w));
|
|
994 }
|
|
995 rb->cursor_type = CURSOR_OFF;
|
428
|
996 dl->cursor_elt = -1;
|
|
997 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
998 }
|
|
999
|
|
1000 w->last_point_x[CURRENT_DISP] = -1;
|
|
1001 w->last_point_y[CURRENT_DISP] = -1;
|
|
1002 Fset_marker (w->last_point[CURRENT_DISP], Qnil, w->buffer);
|
|
1003
|
|
1004 /* If this isn't the selected frame, then erasing the old cursor is
|
|
1005 all we actually had to do. */
|
|
1006 if (w != XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d))))
|
|
1007 {
|
|
1008 if (!no_output_end)
|
442
|
1009 {
|
|
1010 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1011 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1012 }
|
428
|
1013
|
|
1014 return 1;
|
|
1015 }
|
|
1016
|
|
1017 /* This should only occur in the minibuffer. */
|
|
1018 if (new_point == 0)
|
|
1019 {
|
|
1020 w->last_point_x[CURRENT_DISP] = 0;
|
|
1021 w->last_point_y[CURRENT_DISP] = y;
|
|
1022 Fset_marker (w->last_point[CURRENT_DISP], Qzero, w->buffer);
|
|
1023
|
|
1024 rb = Dynarr_atp (db->runes, 0);
|
|
1025 rb->cursor_type = CURSOR_ON;
|
|
1026 dl->cursor_elt = 0;
|
|
1027
|
|
1028 output_display_line (w, 0, cla, y, rb->xpos, rb->xpos + rb->width);
|
|
1029
|
|
1030 if (!no_output_end)
|
442
|
1031 {
|
|
1032 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1033 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1034 }
|
428
|
1035 return 1;
|
|
1036 }
|
|
1037 else
|
|
1038 {
|
|
1039 int cur_rb = 0;
|
|
1040 int first = 0;
|
|
1041 int cur_dl, up;
|
|
1042
|
826
|
1043 if (ADJ_CHARPOS < new_point)
|
428
|
1044 {
|
|
1045 up = 1;
|
|
1046 cur_rb = x + 1;
|
|
1047 cur_dl = y;
|
|
1048 }
|
665
|
1049 else /* (rb->charbpos + dl->offset) > new_point */
|
428
|
1050 {
|
|
1051 up = 0;
|
|
1052
|
|
1053 if (!x)
|
|
1054 {
|
|
1055 cur_dl = y - 1;
|
|
1056 first = 0;
|
|
1057 }
|
|
1058 else
|
|
1059 {
|
|
1060 cur_rb = x - 1;
|
|
1061 cur_dl = y;
|
|
1062 first = 1;
|
|
1063 }
|
|
1064 }
|
|
1065
|
434
|
1066 while (up ? (cur_dl < Dynarr_length (cla)) : (cur_dl >= 0))
|
428
|
1067 {
|
|
1068 dl = Dynarr_atp (cla, cur_dl);
|
|
1069 db = get_display_block_from_line (dl, TEXT);
|
|
1070
|
|
1071 if (!up && !first)
|
|
1072 cur_rb = Dynarr_length (db->runes) - 1;
|
|
1073
|
|
1074 while ((!scroll_on_clipped_lines || !dl->clip) &&
|
|
1075 (up ? (cur_rb < Dynarr_length (db->runes)) : (cur_rb >= 0)))
|
|
1076 {
|
|
1077 rb = Dynarr_atp (db->runes, cur_rb);
|
|
1078
|
|
1079 if (rb->cursor_type != IGNORE_CURSOR
|
|
1080 && rb->cursor_type != NO_CURSOR &&
|
826
|
1081 (ADJ_CHARPOS == new_point
|
|
1082 || (ADJ_ENDPOS && (new_point >= ADJ_CHARPOS)
|
|
1083 && (new_point <= ADJ_CHARPOS))))
|
428
|
1084 {
|
|
1085 rb->cursor_type = CURSOR_ON;
|
|
1086 dl->cursor_elt = cur_rb;
|
|
1087
|
|
1088
|
|
1089 output_display_line (w, 0, cla, cur_dl, rb->xpos,
|
|
1090 rb->xpos + rb->width);
|
|
1091
|
|
1092 w->last_point_x[CURRENT_DISP] = cur_rb;
|
|
1093 w->last_point_y[CURRENT_DISP] = cur_dl;
|
|
1094 Fset_marker (w->last_point[CURRENT_DISP],
|
826
|
1095 make_int (ADJ_CHARPOS), w->buffer);
|
428
|
1096
|
|
1097 if (!no_output_end)
|
442
|
1098 {
|
|
1099 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1100 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1101 }
|
428
|
1102 return 1;
|
|
1103 }
|
|
1104
|
|
1105 (up ? cur_rb++ : cur_rb--);
|
|
1106 }
|
|
1107
|
|
1108 (up ? (cur_rb = 0) : (first = 0));
|
|
1109 (up ? cur_dl++ : cur_dl--);
|
|
1110 }
|
|
1111 }
|
|
1112
|
|
1113 if (!no_output_end)
|
442
|
1114 {
|
|
1115 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1116 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1117 }
|
428
|
1118 return 0;
|
|
1119 }
|
826
|
1120 #undef ADJ_CHARPOS
|
428
|
1121 #undef ADJ_ENDPOS
|
|
1122
|
|
1123 /*****************************************************************************
|
|
1124 redraw_cursor_in_window
|
|
1125
|
|
1126 For the given window W, redraw the cursor if it is contained within
|
|
1127 the window.
|
|
1128 ****************************************************************************/
|
|
1129 static void
|
|
1130 redraw_cursor_in_window (struct window *w, int run_end_begin_meths)
|
|
1131 {
|
|
1132 struct frame *f = XFRAME (w->frame);
|
|
1133 struct device *d = XDEVICE (f->device);
|
|
1134
|
|
1135 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
|
|
1136 struct display_line *dl;
|
|
1137 struct display_block *db;
|
|
1138 struct rune *rb;
|
|
1139
|
|
1140 int x = w->last_point_x[CURRENT_DISP];
|
|
1141 int y = w->last_point_y[CURRENT_DISP];
|
|
1142
|
|
1143 if (cursor_in_echo_area && MINI_WINDOW_P (w) &&
|
|
1144 !echo_area_active (f) && minibuf_level == 0)
|
|
1145 {
|
|
1146 MAYBE_DEVMETH (d, set_final_cursor_coords, (f, w->pixel_top, 0));
|
|
1147 }
|
|
1148
|
|
1149 if (y < 0 || y >= Dynarr_length (dla))
|
|
1150 return;
|
|
1151
|
|
1152 if (MINI_WINDOW_P (w) && f != device_selected_frame (d) &&
|
|
1153 !is_surrogate_for_selected_frame (f))
|
|
1154 return;
|
|
1155
|
|
1156 dl = Dynarr_atp (dla, y);
|
|
1157 db = get_display_block_from_line (dl, TEXT);
|
|
1158
|
|
1159 if (x < 0 || x >= Dynarr_length (db->runes))
|
|
1160 return;
|
|
1161
|
|
1162 rb = Dynarr_atp (db->runes, x);
|
|
1163
|
|
1164 /* Don't call the output routine if the block isn't actually the
|
|
1165 cursor. */
|
|
1166 if (rb->cursor_type == CURSOR_ON)
|
|
1167 {
|
|
1168 MAYBE_DEVMETH (d, set_final_cursor_coords,
|
|
1169 (f, dl->ypos - 1, rb->xpos));
|
|
1170
|
|
1171 if (run_end_begin_meths)
|
442
|
1172 {
|
|
1173 MAYBE_DEVMETH (d, frame_output_begin, (f));
|
|
1174 MAYBE_DEVMETH (d, window_output_begin, (w));
|
|
1175 }
|
428
|
1176
|
|
1177 output_display_line (w, 0, dla, y, rb->xpos, rb->xpos + rb->width);
|
|
1178
|
|
1179 if (run_end_begin_meths)
|
442
|
1180 {
|
|
1181 MAYBE_DEVMETH (d, window_output_end, (w));
|
|
1182 MAYBE_DEVMETH (d, frame_output_end, (f));
|
|
1183 }
|
428
|
1184 }
|
|
1185 }
|
|
1186
|
|
1187 /*****************************************************************************
|
|
1188 redisplay_redraw_cursor
|
|
1189
|
|
1190 For the given frame F, redraw the cursor on the selected window.
|
|
1191 This is used to update the cursor after focus changes.
|
|
1192 ****************************************************************************/
|
|
1193 void
|
|
1194 redisplay_redraw_cursor (struct frame *f, int run_end_begin_meths)
|
|
1195 {
|
|
1196 Lisp_Object window;
|
|
1197
|
|
1198 if (!cursor_in_echo_area)
|
|
1199 window = FRAME_SELECTED_WINDOW (f);
|
|
1200 else if (FRAME_HAS_MINIBUF_P (f))
|
|
1201 window = FRAME_MINIBUF_WINDOW (f);
|
|
1202 else
|
|
1203 return;
|
|
1204
|
|
1205 redraw_cursor_in_window (XWINDOW (window), run_end_begin_meths);
|
|
1206 }
|
|
1207
|
|
1208 /****************************************************************************
|
|
1209 redisplay_output_display_block
|
|
1210
|
|
1211 Given a display line, a block number for that start line, output all
|
|
1212 runes between start and end in the specified display block.
|
|
1213 ****************************************************************************/
|
|
1214 static void
|
|
1215 redisplay_output_display_block (struct window *w, struct display_line *dl, int block,
|
|
1216 int start, int end, int start_pixpos, int cursor_start,
|
|
1217 int cursor_width, int cursor_height)
|
|
1218 {
|
|
1219 struct frame *f = XFRAME (w->frame);
|
|
1220 struct device *d = XDEVICE (f->device);
|
442
|
1221 /* Temporarily disabled until generalization is done. */
|
|
1222 #if 0
|
428
|
1223 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
|
|
1224 rune_dynarr *rba = db->runes;
|
|
1225 struct rune *rb;
|
|
1226 int xpos, width;
|
|
1227 rb = Dynarr_atp (rba, start);
|
|
1228
|
|
1229 if (!rb)
|
|
1230 /* Nothing to do so don't do anything. */
|
|
1231 return;
|
|
1232
|
|
1233 xpos = max (start_pixpos, rb->xpos);
|
|
1234
|
|
1235 if (end < 0)
|
|
1236 end = Dynarr_length (rba);
|
|
1237
|
|
1238 rb = Dynarr_atp (rba, end - 1);
|
|
1239 width = rb->xpos + rb->width - xpos;
|
442
|
1240 #endif
|
428
|
1241 /* now actually output the block. */
|
|
1242 DEVMETH (d, output_display_block, (w, dl, block, start,
|
|
1243 end, start_pixpos,
|
|
1244 cursor_start, cursor_width,
|
|
1245 cursor_height));
|
|
1246 }
|
|
1247
|
|
1248 /****************************************************************************
|
|
1249 redisplay_unmap_subwindows
|
|
1250
|
|
1251 Remove subwindows from the area in the box defined by the given
|
|
1252 parameters.
|
|
1253 ****************************************************************************/
|
448
|
1254 static void
|
|
1255 redisplay_unmap_subwindows (struct frame* f, int x, int y, int width, int height,
|
|
1256 Lisp_Object ignored_window)
|
428
|
1257 {
|
442
|
1258 Lisp_Object rest;
|
428
|
1259
|
442
|
1260 LIST_LOOP (rest, XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f)))
|
|
1261 {
|
|
1262 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (XCAR (rest));
|
|
1263 if (IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (ii)
|
428
|
1264 &&
|
442
|
1265 IMAGE_INSTANCE_DISPLAY_X (ii)
|
|
1266 + IMAGE_INSTANCE_DISPLAY_WIDTH (ii) > x
|
428
|
1267 &&
|
442
|
1268 IMAGE_INSTANCE_DISPLAY_X (ii) < x + width
|
|
1269 &&
|
|
1270 IMAGE_INSTANCE_DISPLAY_Y (ii)
|
|
1271 + IMAGE_INSTANCE_DISPLAY_HEIGHT (ii) > y
|
434
|
1272 &&
|
442
|
1273 IMAGE_INSTANCE_DISPLAY_Y (ii) < y + height
|
|
1274 &&
|
|
1275 !EQ (XCAR (rest), ignored_window))
|
428
|
1276 {
|
442
|
1277 unmap_subwindow (XCAR (rest));
|
428
|
1278 }
|
|
1279 }
|
|
1280 }
|
|
1281
|
|
1282 /****************************************************************************
|
|
1283 redisplay_unmap_subwindows_maybe
|
|
1284
|
|
1285 Potentially subwindows from the area in the box defined by the given
|
|
1286 parameters.
|
|
1287 ****************************************************************************/
|
1279
|
1288 void
|
|
1289 redisplay_unmap_subwindows_maybe (struct frame *f, int x, int y, int width,
|
|
1290 int height)
|
428
|
1291 {
|
442
|
1292 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1293 {
|
|
1294 redisplay_unmap_subwindows (f, x, y, width, height, Qnil);
|
|
1295 }
|
|
1296 }
|
|
1297
|
1279
|
1298 static void
|
|
1299 redisplay_unmap_subwindows_except_us (struct frame *f, int x, int y, int width,
|
|
1300 int height, Lisp_Object subwindow)
|
428
|
1301 {
|
442
|
1302 if (!NILP (XWEAK_LIST_LIST (FRAME_SUBWINDOW_CACHE (f))))
|
428
|
1303 {
|
|
1304 redisplay_unmap_subwindows (f, x, y, width, height, subwindow);
|
|
1305 }
|
|
1306 }
|
|
1307
|
|
1308 /****************************************************************************
|
|
1309 redisplay_output_subwindow
|
|
1310
|
|
1311 output a subwindow. This code borrows heavily from the pixmap stuff,
|
|
1312 although is much simpler not needing to account for partial
|
|
1313 pixmaps, backgrounds etc.
|
|
1314 ****************************************************************************/
|
|
1315 void
|
434
|
1316 redisplay_output_subwindow (struct window *w,
|
428
|
1317 Lisp_Object image_instance,
|
|
1318 struct display_box* db, struct display_glyph_area* dga,
|
2286
|
1319 face_index findex, int UNUSED (cursor_start),
|
|
1320 int UNUSED (cursor_width),
|
|
1321 int UNUSED (cursor_height))
|
428
|
1322 {
|
440
|
1323 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
428
|
1324 Lisp_Object window;
|
|
1325 struct display_glyph_area sdga;
|
|
1326
|
442
|
1327 dga->height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1328 dga->width = IMAGE_INSTANCE_WIDTH (p);
|
|
1329
|
|
1330 /* The first thing we are going to do is update the display
|
|
1331 characteristics of the subwindow. This also clears the dirty
|
|
1332 flags as a side effect. */
|
|
1333 redisplay_subwindow (image_instance);
|
428
|
1334
|
|
1335 /* This makes the glyph area fit into the display area. */
|
|
1336 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1337 return;
|
|
1338
|
793
|
1339 window = wrap_window (w);
|
428
|
1340
|
|
1341 /* Clear the area the subwindow is going into. */
|
|
1342 redisplay_clear_clipped_region (window, findex,
|
|
1343 db, dga, 0, image_instance);
|
|
1344
|
|
1345 /* This shrinks the display box to exactly enclose the glyph
|
|
1346 area. */
|
|
1347 redisplay_normalize_display_box (db, dga);
|
|
1348
|
|
1349 /* if we can't view the whole window we can't view any of it. We
|
|
1350 have to be careful here since we may be being asked to display
|
|
1351 part of a subwindow, the rest of which is on-screen as well. We
|
|
1352 need to allow this case and map the entire subwindow. We also
|
|
1353 need to be careful since the subwindow could be outside the
|
|
1354 window in the gutter or modeline - we also need to allow these
|
|
1355 cases.*/
|
|
1356 sdga.xoffset = -dga->xoffset;
|
|
1357 sdga.yoffset = -dga->yoffset;
|
442
|
1358 sdga.height = IMAGE_INSTANCE_HEIGHT (p);
|
|
1359 sdga.width = IMAGE_INSTANCE_WIDTH (p);
|
434
|
1360
|
446
|
1361 if (redisplay_display_boxes_in_window_p (w, db, &sdga) == 0
|
|
1362 ||
|
|
1363 /* We only want to do full subwindow display for windows that
|
|
1364 are completely in the gutter, otherwise we must clip to be
|
|
1365 safe. */
|
|
1366 display_boxes_in_gutter_p (XFRAME (w->frame), db, &sdga) <= 0)
|
428
|
1367 {
|
|
1368 map_subwindow (image_instance, db->xpos, db->ypos, dga);
|
|
1369 }
|
|
1370 else
|
|
1371 {
|
|
1372 sdga.xoffset = sdga.yoffset = 0;
|
434
|
1373 map_subwindow (image_instance, db->xpos - dga->xoffset,
|
428
|
1374 db->ypos - dga->yoffset, &sdga);
|
|
1375 }
|
|
1376 }
|
|
1377
|
|
1378 /****************************************************************************
|
|
1379 redisplay_output_layout
|
|
1380
|
|
1381 Output a widget hierarchy. This can safely call itself recursively.
|
442
|
1382
|
|
1383 The complexity of outputting layouts is deciding whether to do it or
|
|
1384 not. Consider a layout enclosing some text, the text changes and is
|
|
1385 marked as dirty, but the enclosing layout has not been marked as
|
|
1386 dirty so no updates occur and the text will potentially be truncated.
|
|
1387 Alternatively we hold a back pointer in the image instance to the
|
|
1388 parent and mark the parent as dirty. But the layout code assumes that
|
|
1389 if the layout is dirty then the whole layout should be redisplayed,
|
|
1390 so we then get lots of flashing even though only the text has changed
|
|
1391 size. Of course if the text shrinks in size then we do actually need
|
|
1392 to redisplay the layout to repaint the exposed area. So what happens
|
|
1393 if we make a non-structural change like changing color? Either we
|
|
1394 redisplay everything, or we redisplay nothing. These are exactly the
|
|
1395 issues lwlib has to grapple with. We really need to know what has
|
|
1396 actually changed and make a layout decision based on that. We also
|
|
1397 really need to know what has changed so that we can only make the
|
|
1398 necessary changes in update_subwindow. This has all now been
|
|
1399 implemented, Viva la revolution!
|
428
|
1400 ****************************************************************************/
|
|
1401 void
|
442
|
1402 redisplay_output_layout (Lisp_Object domain,
|
428
|
1403 Lisp_Object image_instance,
|
|
1404 struct display_box* db, struct display_glyph_area* dga,
|
2286
|
1405 face_index findex, int UNUSED (cursor_start),
|
|
1406 int UNUSED (cursor_width), int UNUSED (cursor_height))
|
428
|
1407 {
|
440
|
1408 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
442
|
1409 Lisp_Object rest, window = DOMAIN_WINDOW (domain);
|
3479
|
1410 Ichar_dynarr *buf;
|
442
|
1411 struct window *w = XWINDOW (window);
|
|
1412 struct device *d = DOMAIN_XDEVICE (domain);
|
428
|
1413 int layout_height, layout_width;
|
|
1414
|
442
|
1415 layout_height = glyph_height (image_instance, domain);
|
|
1416 layout_width = glyph_width (image_instance, domain);
|
428
|
1417
|
|
1418 dga->height = layout_height;
|
|
1419 dga->width = layout_width;
|
442
|
1420 #ifdef DEBUG_WIDGET_OUTPUT
|
|
1421 printf ("outputing layout glyph %p\n", p);
|
|
1422 #endif
|
428
|
1423 /* This makes the glyph area fit into the display area. */
|
|
1424 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1425 return;
|
|
1426
|
3479
|
1427 buf = Dynarr_new (Ichar);
|
|
1428
|
428
|
1429 /* Highly dodgy optimization. We want to only output the whole
|
|
1430 layout if we really have to. */
|
442
|
1431 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p)
|
|
1432 || IMAGE_INSTANCE_LAYOUT_CHANGED (p)
|
|
1433 || IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
|
|
1434 || IMAGE_INSTANCE_SIZE_CHANGED (p)
|
|
1435 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
|
428
|
1436 {
|
|
1437 /* First clear the area we are drawing into. This is the easiest
|
|
1438 thing to do since we have many gaps that we have to make sure are
|
|
1439 filled in. */
|
|
1440 redisplay_clear_clipped_region (window, findex, db, dga, 1, Qnil);
|
434
|
1441
|
428
|
1442 /* Output a border if required */
|
|
1443 if (!NILP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1444 {
|
|
1445 int edges = 0;
|
|
1446 enum edge_style style;
|
|
1447 int ypos = db->ypos;
|
863
|
1448 int xpos = db->xpos;
|
428
|
1449 int height = dga->height;
|
863
|
1450 int width = dga->width;
|
434
|
1451
|
863
|
1452 /* The bevel_area routines always draw in from the specified
|
|
1453 area so there is no need to adjust the displayed area to
|
|
1454 make sure that the lines are visible. */
|
|
1455 if (dga->xoffset >= 0)
|
428
|
1456 edges |= EDGE_LEFT;
|
863
|
1457 if (dga->width - dga->xoffset == layout_width)
|
428
|
1458 edges |= EDGE_RIGHT;
|
863
|
1459 if (dga->yoffset >= 0)
|
428
|
1460 edges |= EDGE_TOP;
|
|
1461 if (dga->height - dga->yoffset == layout_height)
|
|
1462 edges |= EDGE_BOTTOM;
|
863
|
1463
|
428
|
1464 if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_in))
|
|
1465 style = EDGE_ETCHED_IN;
|
|
1466 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qetched_out))
|
|
1467 style = EDGE_ETCHED_OUT;
|
|
1468 else if (EQ (IMAGE_INSTANCE_LAYOUT_BORDER (p), Qbevel_in))
|
|
1469 style = EDGE_BEVEL_IN;
|
|
1470 else if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (p)))
|
|
1471 {
|
|
1472 style = EDGE_ETCHED_IN;
|
|
1473 if (edges & EDGE_TOP)
|
|
1474 {
|
|
1475 ypos += XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1476 height -= XINT (IMAGE_INSTANCE_LAYOUT_BORDER (p));
|
|
1477 }
|
|
1478 }
|
|
1479 else
|
|
1480 style = EDGE_BEVEL_OUT;
|
|
1481
|
434
|
1482 MAYBE_DEVMETH (d, bevel_area,
|
863
|
1483 (w, findex, xpos, ypos, width, height,
|
|
1484 DEFAULT_WIDGET_SHADOW_WIDTH, edges, style));
|
428
|
1485 }
|
|
1486 }
|
434
|
1487
|
428
|
1488 /* This shrinks the display box to exactly enclose the glyph
|
|
1489 area. */
|
|
1490 redisplay_normalize_display_box (db, dga);
|
|
1491
|
|
1492 /* Flip through the widgets in the layout displaying as necessary */
|
|
1493 LIST_LOOP (rest, IMAGE_INSTANCE_LAYOUT_CHILDREN (p))
|
|
1494 {
|
442
|
1495 Lisp_Object child = glyph_image_instance (XCAR (rest), image_instance,
|
793
|
1496 ERROR_ME_DEBUG_WARN, 1);
|
428
|
1497
|
|
1498 struct display_box cdb;
|
|
1499 /* For losing HP-UX */
|
|
1500 cdb.xpos = db->xpos;
|
|
1501 cdb.ypos = db->ypos;
|
|
1502 cdb.width = db->width;
|
|
1503 cdb.height = db->height;
|
|
1504
|
|
1505 /* First determine if the image is visible at all */
|
|
1506 if (IMAGE_INSTANCEP (child))
|
|
1507 {
|
440
|
1508 Lisp_Image_Instance* childii = XIMAGE_INSTANCE (child);
|
442
|
1509
|
428
|
1510 /* The enclosing layout offsets are +ve at this point */
|
|
1511 struct display_glyph_area cdga;
|
|
1512 cdga.xoffset = IMAGE_INSTANCE_XOFFSET (childii) - dga->xoffset;
|
|
1513 cdga.yoffset = IMAGE_INSTANCE_YOFFSET (childii) - dga->yoffset;
|
442
|
1514 cdga.width = glyph_width (child, image_instance);
|
|
1515 cdga.height = glyph_height (child, image_instance);
|
|
1516
|
|
1517 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) =
|
|
1518 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (p);
|
428
|
1519
|
|
1520 /* Although normalization is done by the output routines
|
|
1521 we have to do it here so that they don't try and
|
|
1522 clear all of db. This is true below also. */
|
|
1523 if (redisplay_normalize_glyph_area (&cdb, &cdga))
|
|
1524 {
|
|
1525 redisplay_normalize_display_box (&cdb, &cdga);
|
|
1526 /* Since the display boxes will now be totally in the
|
|
1527 window if they are visible at all we can now check this easily. */
|
|
1528 if (cdb.xpos < db->xpos || cdb.ypos < db->ypos
|
|
1529 || cdb.xpos + cdb.width > db->xpos + db->width
|
|
1530 || cdb.ypos + cdb.height > db->ypos + db->height)
|
|
1531 continue;
|
|
1532 /* We have to invert the offset here as normalization
|
|
1533 will have made them positive which the output
|
442
|
1534 routines will treat as a truly +ve offset. */
|
428
|
1535 cdga.xoffset = -cdga.xoffset;
|
|
1536 cdga.yoffset = -cdga.yoffset;
|
|
1537
|
|
1538 switch (IMAGE_INSTANCE_TYPE (childii))
|
|
1539 {
|
|
1540 case IMAGE_TEXT:
|
|
1541 {
|
|
1542 /* #### This is well hacked and could use some
|
|
1543 generalisation.*/
|
434
|
1544 if (redisplay_normalize_glyph_area (&cdb, &cdga)
|
|
1545 &&
|
442
|
1546 (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1547 IMAGE_INSTANCE_DIRTYP (childii)))
|
428
|
1548 {
|
|
1549 struct display_line dl; /* this is fake */
|
|
1550 Lisp_Object string =
|
|
1551 IMAGE_INSTANCE_TEXT_STRING (childii);
|
442
|
1552 unsigned char charsets[NUM_LEADING_BYTES];
|
|
1553 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
|
|
1554
|
867
|
1555 find_charsets_in_ibyte_string (charsets,
|
442
|
1556 XSTRING_DATA (string),
|
|
1557 XSTRING_LENGTH (string));
|
|
1558 ensure_face_cachel_complete (cachel, window, charsets);
|
|
1559
|
867
|
1560 convert_ibyte_string_into_ichar_dynarr
|
428
|
1561 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
|
434
|
1562
|
428
|
1563 redisplay_normalize_display_box (&cdb, &cdga);
|
|
1564 /* Offsets are now +ve again so be careful
|
|
1565 when fixing up the display line. */
|
|
1566 xzero (dl);
|
|
1567 /* Munge boxes into display lines. */
|
|
1568 dl.ypos = (cdb.ypos - cdga.yoffset)
|
442
|
1569 + glyph_ascent (child, image_instance);
|
|
1570 dl.ascent = glyph_ascent (child, image_instance);
|
|
1571 dl.descent = glyph_descent (child, image_instance);
|
428
|
1572 dl.top_clip = cdga.yoffset;
|
|
1573 dl.clip = (dl.ypos + dl.descent) - (cdb.ypos + cdb.height);
|
|
1574 /* output_string doesn't understand offsets in
|
|
1575 the same way as other routines - we have to
|
|
1576 add the offset to the width so that we
|
|
1577 output the full string. */
|
|
1578 MAYBE_DEVMETH (d, output_string, (w, &dl, buf, cdb.xpos,
|
|
1579 cdga.xoffset, cdb.xpos,
|
|
1580 cdga.width + cdga.xoffset,
|
|
1581 findex, 0, 0, 0, 0));
|
|
1582 Dynarr_reset (buf);
|
|
1583 }
|
|
1584 }
|
|
1585 break;
|
434
|
1586
|
428
|
1587 case IMAGE_MONO_PIXMAP:
|
|
1588 case IMAGE_COLOR_PIXMAP:
|
442
|
1589 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii)
|
|
1590 || IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1591 redisplay_output_pixmap (w, child, &cdb, &cdga, findex,
|
|
1592 0, 0, 0, 0);
|
|
1593 break;
|
434
|
1594
|
428
|
1595 case IMAGE_WIDGET:
|
442
|
1596 if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (childii), Qlayout))
|
|
1597 {
|
|
1598 redisplay_output_layout (image_instance, child, &cdb, &cdga, findex,
|
|
1599 0, 0, 0);
|
|
1600 break;
|
|
1601 }
|
428
|
1602 case IMAGE_SUBWINDOW:
|
442
|
1603 if (!IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) ||
|
|
1604 IMAGE_INSTANCE_DIRTYP (childii))
|
428
|
1605 redisplay_output_subwindow (w, child, &cdb, &cdga, findex,
|
|
1606 0, 0, 0);
|
|
1607 break;
|
434
|
1608
|
428
|
1609 case IMAGE_NOTHING:
|
|
1610 /* nothing is as nothing does */
|
|
1611 break;
|
434
|
1612
|
428
|
1613 case IMAGE_POINTER:
|
|
1614 default:
|
2500
|
1615 ABORT ();
|
428
|
1616 }
|
|
1617 }
|
442
|
1618 IMAGE_INSTANCE_OPTIMIZE_OUTPUT (childii) = 0;
|
428
|
1619 }
|
|
1620 }
|
442
|
1621
|
|
1622 /* Update any display properties. I'm not sure whether this actually
|
|
1623 does anything for layouts except clear the changed flags. */
|
|
1624 redisplay_subwindow (image_instance);
|
|
1625
|
428
|
1626 Dynarr_free (buf);
|
|
1627 }
|
|
1628
|
|
1629 /****************************************************************************
|
|
1630 redisplay_output_pixmap
|
|
1631
|
|
1632
|
|
1633 output a pixmap.
|
|
1634 ****************************************************************************/
|
|
1635 void
|
434
|
1636 redisplay_output_pixmap (struct window *w,
|
428
|
1637 Lisp_Object image_instance,
|
|
1638 struct display_box* db, struct display_glyph_area* dga,
|
|
1639 face_index findex, int cursor_start, int cursor_width,
|
|
1640 int cursor_height, int offset_bitmap)
|
|
1641 {
|
|
1642 struct frame *f = XFRAME (w->frame);
|
|
1643 struct device *d = XDEVICE (f->device);
|
440
|
1644 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
|
793
|
1645 Lisp_Object window = wrap_window (w);
|
|
1646
|
428
|
1647
|
|
1648 dga->height = IMAGE_INSTANCE_PIXMAP_HEIGHT (p);
|
|
1649 dga->width = IMAGE_INSTANCE_PIXMAP_WIDTH (p);
|
|
1650
|
819
|
1651 #ifdef DEBUG_REDISPLAY
|
|
1652 printf ("redisplay_output_pixmap(request) \
|
|
1653 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
|
1654 db->width, db->height, db->xpos, db->ypos,
|
|
1655 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1656 #endif
|
|
1657
|
428
|
1658 /* This makes the glyph area fit into the display area. */
|
|
1659 if (!redisplay_normalize_glyph_area (db, dga))
|
|
1660 return;
|
|
1661
|
819
|
1662 #ifdef DEBUG_REDISPLAY
|
|
1663 printf ("redisplay_output_pixmap(normalized) \
|
|
1664 [%dx%d@%d+%d] in [%dx%d@%d+%d]\n",
|
|
1665 db->width, db->height, db->xpos, db->ypos,
|
|
1666 dga->width, dga->height, dga->xoffset, dga->yoffset);
|
|
1667 #endif
|
|
1668
|
428
|
1669 /* Clear the area the pixmap is going into. The pixmap itself will
|
|
1670 always take care of the full width. We don't want to clear where
|
|
1671 it is going to go in order to avoid flicker. So, all we have to
|
|
1672 take care of is any area above or below the pixmap. If the pixmap
|
|
1673 has a mask in which case we have to clear the whole damn thing
|
|
1674 since we can't yet clear just the area not included in the
|
|
1675 mask. */
|
|
1676 if (!offset_bitmap)
|
|
1677 {
|
|
1678 redisplay_clear_clipped_region (window, findex,
|
434
|
1679 db, dga,
|
442
|
1680 (IMAGE_INSTANCE_PIXMAP_MASK (p) != 0),
|
428
|
1681 Qnil);
|
|
1682
|
|
1683 /* This shrinks the display box to exactly enclose the glyph
|
|
1684 area. */
|
|
1685 redisplay_normalize_display_box (db, dga);
|
|
1686 }
|
|
1687 assert (db->xpos >= 0 && db->ypos >= 0);
|
|
1688
|
|
1689 MAYBE_DEVMETH (d, output_pixmap, (w, image_instance,
|
|
1690 db, dga,
|
|
1691 findex, cursor_start,
|
|
1692 cursor_width, cursor_height,
|
|
1693 offset_bitmap));
|
|
1694 }
|
|
1695
|
|
1696 /****************************************************************************
|
|
1697 redisplay_clear_region
|
|
1698
|
|
1699 Clear the area in the box defined by the given parameters using the
|
|
1700 given face. This has been generalised so that subwindows can be
|
|
1701 coped with effectively.
|
|
1702 ****************************************************************************/
|
|
1703 void
|
|
1704 redisplay_clear_region (Lisp_Object locale, face_index findex, int x, int y,
|
|
1705 int width, int height)
|
|
1706 {
|
|
1707 struct window *w = NULL;
|
|
1708 struct frame *f = NULL;
|
|
1709 struct device *d;
|
|
1710 Lisp_Object background_pixmap = Qunbound;
|
|
1711 Lisp_Object fcolor = Qnil, bcolor = Qnil;
|
|
1712
|
|
1713 if (!width || !height)
|
|
1714 return;
|
|
1715
|
|
1716 if (WINDOWP (locale))
|
|
1717 {
|
|
1718 w = XWINDOW (locale);
|
|
1719 f = XFRAME (w->frame);
|
|
1720 }
|
|
1721 else if (FRAMEP (locale))
|
|
1722 {
|
|
1723 w = NULL;
|
|
1724 f = XFRAME (locale);
|
|
1725 }
|
|
1726 else
|
2500
|
1727 ABORT ();
|
428
|
1728
|
|
1729 d = XDEVICE (f->device);
|
|
1730
|
|
1731 /* if we have subwindows in the region we have to unmap them */
|
|
1732 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
|
|
1733
|
|
1734 /* #### This isn't quite right for when this function is called
|
|
1735 from the toolbar code. */
|
434
|
1736
|
428
|
1737 /* Don't use a backing pixmap in the border area */
|
|
1738 if (x >= FRAME_LEFT_BORDER_END (f)
|
|
1739 && x < FRAME_RIGHT_BORDER_START (f)
|
|
1740 && y >= FRAME_TOP_BORDER_END (f)
|
|
1741 && y < FRAME_BOTTOM_BORDER_START (f))
|
|
1742 {
|
|
1743 Lisp_Object temp;
|
434
|
1744
|
428
|
1745 if (w)
|
|
1746 {
|
|
1747 temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
|
434
|
1748
|
428
|
1749 if (IMAGE_INSTANCEP (temp)
|
|
1750 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1751 {
|
|
1752 /* #### maybe we could implement such that a string
|
|
1753 can be a background pixmap? */
|
|
1754 background_pixmap = temp;
|
|
1755 }
|
|
1756 }
|
|
1757 else
|
|
1758 {
|
|
1759 temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
|
434
|
1760
|
428
|
1761 if (IMAGE_INSTANCEP (temp)
|
|
1762 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
|
|
1763 {
|
|
1764 background_pixmap = temp;
|
|
1765 }
|
|
1766 }
|
434
|
1767 }
|
428
|
1768
|
|
1769 if (!UNBOUNDP (background_pixmap) &&
|
|
1770 XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
|
|
1771 {
|
|
1772 if (w)
|
|
1773 {
|
|
1774 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
|
|
1775 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
|
|
1776 }
|
|
1777 else
|
|
1778 {
|
|
1779 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
|
|
1780 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
|
|
1781 }
|
|
1782 }
|
|
1783 else
|
|
1784 {
|
|
1785 fcolor = (w ?
|
|
1786 WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
|
|
1787 FACE_BACKGROUND (Vdefault_face, locale));
|
434
|
1788
|
428
|
1789 }
|
434
|
1790
|
428
|
1791 if (UNBOUNDP (background_pixmap))
|
|
1792 background_pixmap = Qnil;
|
434
|
1793
|
|
1794 DEVMETH (d, clear_region,
|
428
|
1795 (locale, d, f, findex, x, y, width, height, fcolor, bcolor, background_pixmap));
|
|
1796 }
|
|
1797
|
|
1798 /****************************************************************************
|
|
1799 redisplay_clear_clipped_region
|
|
1800
|
|
1801 Clear the area in the dest display_box not covered by the src
|
442
|
1802 display_glyph_area using the given face. This is a common occurrence
|
428
|
1803 for images shorter than the display line. Clipping can be played
|
|
1804 around with by altering these. glyphsrc should be normalized.
|
|
1805 ****************************************************************************/
|
|
1806 static void
|
434
|
1807 redisplay_clear_clipped_region (Lisp_Object window, face_index findex,
|
|
1808 struct display_box* dest, struct display_glyph_area* glyphsrc,
|
428
|
1809 int fullheight_p, Lisp_Object ignored_subwindow)
|
|
1810 {
|
|
1811 /* assume dest->xpos >= 0 */
|
|
1812 int clear_x;
|
|
1813 struct frame* f = XFRAME (XWINDOW (window)->frame);
|
|
1814
|
|
1815 if (glyphsrc->xoffset > 0)
|
|
1816 {
|
|
1817 clear_x = dest->xpos + glyphsrc->xoffset;
|
|
1818 }
|
|
1819 else
|
|
1820 {
|
|
1821 clear_x = dest->xpos;
|
|
1822 }
|
|
1823
|
|
1824 /* If we need the whole height cleared then just do it. */
|
|
1825 if (fullheight_p)
|
|
1826 {
|
|
1827 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1828 glyphsrc->width, dest->height);
|
|
1829 }
|
|
1830 else
|
|
1831 {
|
434
|
1832 int yoffset = (glyphsrc->yoffset > 0 ? glyphsrc->yoffset : 0);
|
|
1833
|
428
|
1834 /* We need to make sure that subwindows are unmapped from the
|
|
1835 whole area. */
|
|
1836 redisplay_unmap_subwindows_except_us (f, clear_x, dest->ypos,
|
|
1837 glyphsrc->width, dest->height,
|
|
1838 ignored_subwindow);
|
|
1839 /* first the top box */
|
|
1840 if (yoffset > 0)
|
|
1841 {
|
|
1842 redisplay_clear_region (window, findex, clear_x, dest->ypos,
|
|
1843 glyphsrc->width, yoffset);
|
434
|
1844
|
428
|
1845 }
|
|
1846 /* Then the bottom box */
|
|
1847 if (yoffset + glyphsrc->height < dest->height)
|
|
1848 {
|
|
1849 redisplay_clear_region (window, findex, clear_x,
|
|
1850 dest->ypos + yoffset + glyphsrc->height,
|
434
|
1851 glyphsrc->width,
|
428
|
1852 dest->height - (yoffset + glyphsrc->height));
|
|
1853
|
|
1854 }
|
|
1855 }
|
|
1856 }
|
|
1857
|
|
1858 /*****************************************************************************
|
|
1859 redisplay_normalize_glyph_area
|
|
1860 redisplay_normalize_display_box
|
|
1861
|
819
|
1862 Calculate the visible box for displaying glyphsrc in dest.
|
|
1863
|
|
1864 display_box and display_glyph_area are used to represent an area to
|
|
1865 displayed and where to display it. Using these two structures all
|
|
1866 combinations of clipping and position can be accommodated.
|
|
1867
|
|
1868 dest - display_box
|
|
1869
|
|
1870 xpos - absolute horizontal position of area.
|
|
1871
|
|
1872 ypos - absolute vertical position of area.
|
|
1873
|
|
1874 glyphsrc - display_glyph_area
|
|
1875
|
|
1876 xoffset - horizontal offset of the glyph, +ve means display
|
|
1877 the glyph with the x position offset by xoffset, -ve means
|
|
1878 display starting xoffset into the glyph.
|
|
1879
|
|
1880 yoffset - vertical offset of the glyph, +ve means display the
|
|
1881 glyph with y position offset by yoffset, -ve means display
|
|
1882 starting xoffset into the glyph.
|
|
1883
|
428
|
1884 ****************************************************************************/
|
|
1885 int
|
434
|
1886 redisplay_normalize_glyph_area (struct display_box* dest,
|
428
|
1887 struct display_glyph_area* glyphsrc)
|
|
1888 {
|
|
1889 if (dest->xpos + glyphsrc->xoffset > dest->xpos + dest->width
|
|
1890 ||
|
|
1891 dest->ypos + glyphsrc->yoffset > dest->ypos + dest->height
|
|
1892 ||
|
|
1893 -glyphsrc->xoffset >= glyphsrc->width
|
|
1894 ||
|
448
|
1895 -glyphsrc->yoffset >= glyphsrc->height
|
|
1896 ||
|
|
1897 /* #### Not sure why this wasn't coped with before but normalizing
|
|
1898 to zero width or height is definitely wrong. */
|
|
1899 (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width
|
|
1900 &&
|
|
1901 dest->width - glyphsrc->xoffset <= 0)
|
|
1902 ||
|
|
1903 (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height
|
|
1904 &&
|
|
1905 dest->height - glyphsrc->yoffset <= 0))
|
428
|
1906 {
|
|
1907 /* It's all clipped out */
|
|
1908 return 0;
|
|
1909 }
|
|
1910
|
819
|
1911 /* Horizontal offsets. This works because xoffset can be -ve as well
|
|
1912 as +ve. When we enter this function the glyphsrc width and
|
|
1913 height are set to the actual glyph width and height irrespective
|
|
1914 of how much can be displayed. We are trying to clip both the
|
|
1915 offset into the image and the rightmost bounding box. Its
|
|
1916 possible for the glyph width to be much larger than the area we
|
|
1917 are displaying into (e.g. a large glyph in a small frame). */
|
428
|
1918 if (dest->xpos + glyphsrc->xoffset + glyphsrc->width > dest->xpos + dest->width)
|
|
1919 {
|
819
|
1920 /* glyphsrc offset is +ve we are trying to display offset from the
|
|
1921 origin (the bounding box contains some space and then the
|
|
1922 glyph). At most the width we want to display is dest->width -
|
|
1923 glyphsrc->xoffset. */
|
428
|
1924 if (glyphsrc->xoffset > 0)
|
|
1925 glyphsrc->width = dest->width - glyphsrc->xoffset;
|
819
|
1926 /* glyphsrc offset is -ve we are trying to display hard up
|
|
1927 against the dest corner inset into the glyphsrc by
|
|
1928 xoffset.*/
|
|
1929 else if (glyphsrc->xoffset < 0)
|
|
1930 {
|
|
1931 glyphsrc->width += glyphsrc->xoffset;
|
|
1932 glyphsrc->width = min (glyphsrc->width, dest->width);
|
|
1933 }
|
428
|
1934 else
|
|
1935 glyphsrc->width = dest->width;
|
|
1936 }
|
|
1937
|
819
|
1938 else if (glyphsrc->xoffset < 0)
|
428
|
1939 glyphsrc->width += glyphsrc->xoffset;
|
|
1940
|
|
1941 /* Vertical offsets. This works because yoffset can be -ve as well as +ve */
|
|
1942 if (dest->ypos + glyphsrc->yoffset + glyphsrc->height > dest->ypos + dest->height)
|
|
1943 {
|
819
|
1944 if ((glyphsrc->yoffset > 0) && (dest->height > glyphsrc->yoffset))
|
428
|
1945 glyphsrc->height = dest->height - glyphsrc->yoffset;
|
819
|
1946 else if (glyphsrc->yoffset < 0)
|
|
1947 {
|
|
1948 glyphsrc->height += glyphsrc->yoffset;
|
|
1949 glyphsrc->height = min (glyphsrc->height, dest->height);
|
|
1950 }
|
428
|
1951 else
|
|
1952 glyphsrc->height = dest->height;
|
|
1953 }
|
|
1954
|
819
|
1955 else if (glyphsrc->yoffset < 0)
|
428
|
1956 glyphsrc->height += glyphsrc->yoffset;
|
|
1957
|
|
1958 return 1;
|
|
1959 }
|
|
1960
|
|
1961 static void
|
434
|
1962 redisplay_normalize_display_box (struct display_box* dest,
|
428
|
1963 struct display_glyph_area* glyphsrc)
|
|
1964 {
|
|
1965 /* Adjust the destination area. At the end of this the destination
|
|
1966 area will exactly enclose the glyph area. The only remaining
|
|
1967 adjustment will be offsets into the glyph area. */
|
|
1968
|
|
1969 /* Horizontal adjustment. */
|
|
1970 if (glyphsrc->xoffset > 0)
|
|
1971 {
|
|
1972 dest->xpos += glyphsrc->xoffset;
|
|
1973 dest->width -= glyphsrc->xoffset;
|
|
1974 glyphsrc->xoffset = 0;
|
|
1975 }
|
|
1976 else
|
|
1977 glyphsrc->xoffset = -glyphsrc->xoffset;
|
|
1978
|
|
1979 if (glyphsrc->width < dest->width)
|
|
1980 dest->width = glyphsrc->width;
|
|
1981
|
|
1982 /* Vertical adjustment. */
|
|
1983 if (glyphsrc->yoffset > 0)
|
|
1984 {
|
|
1985 dest->ypos += glyphsrc->yoffset;
|
|
1986 dest->height -= glyphsrc->yoffset;
|
|
1987 glyphsrc->yoffset = 0;
|
|
1988 }
|
|
1989 else
|
|
1990 glyphsrc->yoffset = -glyphsrc->yoffset;
|
|
1991
|
|
1992 if (glyphsrc->height < dest->height)
|
|
1993 dest->height = glyphsrc->height;
|
|
1994 }
|
|
1995
|
|
1996 /*****************************************************************************
|
|
1997 redisplay_display_boxes_in_window_p
|
|
1998
|
446
|
1999 Determine whether the required display_glyph_area is completely inside
|
|
2000 the window. -1 means the display_box is not in the window. 1 means the
|
|
2001 display_box and the display_glyph_area are in the window. 0 means
|
428
|
2002 the display_box is in the window but the display_glyph_area is not.
|
|
2003 ****************************************************************************/
|
|
2004 static int
|
|
2005 redisplay_display_boxes_in_window_p (struct window* w,
|
|
2006 struct display_box* db,
|
|
2007 struct display_glyph_area* dga)
|
|
2008 {
|
|
2009 int left = WINDOW_TEXT_LEFT (w);
|
|
2010 int right = WINDOW_TEXT_RIGHT (w);
|
|
2011 int top = WINDOW_TEXT_TOP (w);
|
|
2012 int bottom = WINDOW_TEXT_BOTTOM (w);
|
|
2013
|
|
2014 if (db->xpos < left || db->ypos < top
|
|
2015 || db->xpos + db->width > right
|
|
2016 || db->ypos + db->height > bottom)
|
446
|
2017 /* We are not displaying in a window at all */
|
|
2018 return -1;
|
434
|
2019
|
428
|
2020 if (db->xpos + dga->xoffset >= left
|
|
2021 &&
|
|
2022 db->ypos + dga->yoffset >= top
|
|
2023 &&
|
|
2024 db->xpos + dga->xoffset + dga->width <= right
|
|
2025 &&
|
|
2026 db->ypos + dga->yoffset + dga->height <= bottom)
|
|
2027 return 1;
|
|
2028
|
446
|
2029 return 0;
|
428
|
2030 }
|
|
2031
|
|
2032 /*****************************************************************************
|
|
2033 redisplay_calculate_display_boxes
|
|
2034
|
|
2035 Convert from rune/display_line co-ordinates to display_box
|
|
2036 co-ordinates.
|
|
2037 ****************************************************************************/
|
|
2038 int
|
|
2039 redisplay_calculate_display_boxes (struct display_line *dl, int xpos,
|
819
|
2040 int xoffset, int yoffset, int start_pixpos,
|
|
2041 int width, struct display_box* dest,
|
428
|
2042 struct display_glyph_area* src)
|
|
2043 {
|
|
2044 dest->xpos = xpos;
|
|
2045 dest->ypos = DISPLAY_LINE_YPOS (dl);
|
|
2046 dest->width = width;
|
|
2047 dest->height = DISPLAY_LINE_HEIGHT (dl);
|
|
2048
|
|
2049 src->xoffset = -xoffset;
|
|
2050 src->width = 0;
|
|
2051 src->height = 0;
|
|
2052
|
819
|
2053 src->yoffset = -dl->top_clip + yoffset;
|
|
2054
|
428
|
2055 if (start_pixpos >=0 && start_pixpos > xpos)
|
|
2056 {
|
|
2057 /* Oops, we're asking for a start outside of the displayable
|
|
2058 area. */
|
|
2059 if (start_pixpos > xpos + width)
|
|
2060 return 0;
|
|
2061 dest->xpos = start_pixpos;
|
|
2062 dest->width -= (start_pixpos - xpos);
|
|
2063 /* Offsets are -ve when we want to clip pixels off the displayed
|
|
2064 glyph. */
|
|
2065 src->xoffset -= (start_pixpos - xpos);
|
|
2066 }
|
|
2067
|
|
2068 return 1;
|
|
2069 }
|
|
2070
|
|
2071 /*****************************************************************************
|
|
2072 redisplay_clear_top_of_window
|
|
2073
|
|
2074 If window is topmost, clear the internal border above it.
|
|
2075 ****************************************************************************/
|
448
|
2076 void
|
428
|
2077 redisplay_clear_top_of_window (struct window *w)
|
|
2078 {
|
793
|
2079 Lisp_Object window = wrap_window (w);
|
|
2080
|
428
|
2081
|
|
2082 if (!NILP (Fwindow_highest_p (window)))
|
|
2083 {
|
|
2084 struct frame *f = XFRAME (w->frame);
|
|
2085 int x, y, width, height;
|
|
2086
|
|
2087 x = w->pixel_left;
|
|
2088 width = w->pixel_width;
|
|
2089
|
|
2090 if (window_is_leftmost (w))
|
|
2091 {
|
|
2092 x -= FRAME_BORDER_WIDTH (f);
|
|
2093 width += FRAME_BORDER_WIDTH (f);
|
|
2094 }
|
|
2095 if (window_is_rightmost (w))
|
|
2096 width += FRAME_BORDER_WIDTH (f);
|
|
2097
|
|
2098 y = FRAME_TOP_BORDER_START (f) - 1;
|
|
2099 height = FRAME_BORDER_HEIGHT (f) + 1;
|
|
2100
|
|
2101 redisplay_clear_region (window, DEFAULT_INDEX, x, y, width, height);
|
|
2102 }
|
|
2103 }
|
|
2104
|
|
2105 /*****************************************************************************
|
|
2106 redisplay_clear_to_window_end
|
|
2107
|
|
2108 Clear the area between ypos1 and ypos2. Each margin area and the
|
|
2109 text area is handled separately since they may each have their own
|
|
2110 background color.
|
|
2111 ****************************************************************************/
|
|
2112 void
|
|
2113 redisplay_clear_to_window_end (struct window *w, int ypos1, int ypos2)
|
|
2114 {
|
|
2115 struct frame *f = XFRAME (w->frame);
|
|
2116 struct device *d = XDEVICE (f->device);
|
|
2117
|
|
2118 if (HAS_DEVMETH_P (d, clear_to_window_end))
|
|
2119 DEVMETH (d, clear_to_window_end, (w, ypos1, ypos2));
|
|
2120 else
|
|
2121 {
|
|
2122 int height = ypos2 - ypos1;
|
434
|
2123
|
428
|
2124 if (height)
|
|
2125 {
|
|
2126 Lisp_Object window;
|
|
2127 int bflag = 0 ; /* (window_needs_vertical_divider (w) ? 0 : 1);*/
|
|
2128 layout_bounds bounds;
|
434
|
2129
|
428
|
2130 bounds = calculate_display_line_boundaries (w, bflag);
|
793
|
2131 window = wrap_window (w);
|
428
|
2132
|
|
2133 if (window_is_leftmost (w))
|
|
2134 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
|
|
2135 ypos1, FRAME_BORDER_WIDTH (f), height);
|
434
|
2136
|
428
|
2137 if (bounds.left_in - bounds.left_out > 0)
|
|
2138 redisplay_clear_region (window,
|
|
2139 get_builtin_face_cache_index (w, Vleft_margin_face),
|
|
2140 bounds.left_out, ypos1,
|
|
2141 bounds.left_in - bounds.left_out, height);
|
434
|
2142
|
428
|
2143 if (bounds.right_in - bounds.left_in > 0)
|
434
|
2144 redisplay_clear_region (window,
|
428
|
2145 DEFAULT_INDEX,
|
|
2146 bounds.left_in, ypos1,
|
|
2147 bounds.right_in - bounds.left_in, height);
|
434
|
2148
|
428
|
2149 if (bounds.right_out - bounds.right_in > 0)
|
|
2150 redisplay_clear_region (window,
|
|
2151 get_builtin_face_cache_index (w, Vright_margin_face),
|
|
2152 bounds.right_in, ypos1,
|
|
2153 bounds.right_out - bounds.right_in, height);
|
434
|
2154
|
428
|
2155 if (window_is_rightmost (w))
|
|
2156 redisplay_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
|
|
2157 ypos1, FRAME_BORDER_WIDTH (f), height);
|
|
2158 }
|
|
2159 }
|
|
2160 }
|
|
2161
|
|
2162 /*****************************************************************************
|
|
2163 redisplay_clear_bottom_of_window
|
|
2164
|
|
2165 Clear window from right below the last display line to right above
|
|
2166 the modeline. The calling function can limit the area actually
|
|
2167 erased by setting min_start and/or max_end to positive values.
|
|
2168 ****************************************************************************/
|
|
2169 void
|
|
2170 redisplay_clear_bottom_of_window (struct window *w, display_line_dynarr *ddla,
|
|
2171 int min_start, int max_end)
|
|
2172 {
|
|
2173 struct frame *f = XFRAME (w->frame);
|
|
2174 int ypos1, ypos2;
|
|
2175 int ddla_len = Dynarr_length (ddla);
|
|
2176
|
|
2177 ypos2 = WINDOW_TEXT_BOTTOM (w);
|
|
2178 #ifdef HAVE_SCROLLBARS
|
|
2179 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2180 if (f->windows_structure_changed && NILP (w->scrollbar_on_top_p))
|
|
2181 ypos2 += window_scrollbar_height (w);
|
|
2182 #endif
|
|
2183
|
|
2184 if (ddla_len)
|
|
2185 {
|
|
2186 if (ddla_len == 1 && Dynarr_atp (ddla, 0)->modeline)
|
|
2187 {
|
|
2188 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2189 #ifdef HAVE_SCROLLBARS
|
|
2190 /* This adjustment is to catch the intersection of any scrollbars. */
|
|
2191 if (f->windows_structure_changed && !NILP (w->scrollbar_on_top_p))
|
|
2192 ypos1 -= window_scrollbar_height (w);
|
|
2193 #endif
|
|
2194 }
|
|
2195 else
|
|
2196 {
|
|
2197 struct display_line *dl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2198 ypos1 = dl->ypos + dl->descent - dl->clip;
|
|
2199 }
|
|
2200 }
|
|
2201 else
|
|
2202 ypos1 = WINDOW_TEXT_TOP (w);
|
|
2203
|
|
2204 /* #### See if this can be made conditional on the frame
|
|
2205 changing size. */
|
|
2206 if (MINI_WINDOW_P (w))
|
|
2207 ypos2 += FRAME_BORDER_HEIGHT (f);
|
|
2208
|
|
2209 if (min_start >= 0 && ypos1 < min_start)
|
|
2210 ypos1 = min_start;
|
|
2211 if (max_end >= 0 && ypos2 > max_end)
|
|
2212 ypos2 = max_end;
|
|
2213
|
|
2214 if (ypos2 <= ypos1)
|
|
2215 return;
|
|
2216
|
|
2217 redisplay_clear_to_window_end (w, ypos1, ypos2);
|
|
2218 }
|
|
2219
|
|
2220 /*****************************************************************************
|
|
2221 redisplay_update_line
|
|
2222
|
|
2223 This is used during incremental updates to update a single line and
|
|
2224 correct the offsets on all lines below it. At the moment
|
|
2225 update_values is false if we are only updating the modeline.
|
|
2226 ****************************************************************************/
|
|
2227 void
|
|
2228 redisplay_update_line (struct window *w, int first_line, int last_line,
|
|
2229 int update_values)
|
|
2230 {
|
|
2231 struct frame *f = XFRAME (w->frame);
|
|
2232 struct device *d = XDEVICE (f->device);
|
|
2233
|
|
2234 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2235 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2236
|
442
|
2237 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2238
|
|
2239 while (first_line <= last_line)
|
|
2240 {
|
826
|
2241 Charcount old_len = (Dynarr_atp (cdla, first_line)->end_charpos -
|
|
2242 Dynarr_atp (cdla, first_line)->charpos);
|
|
2243 Charcount new_len = (Dynarr_atp (ddla, first_line)->end_charpos -
|
|
2244 Dynarr_atp (ddla, first_line)->charpos);
|
428
|
2245
|
|
2246 assert (Dynarr_length (cdla) == Dynarr_length (ddla));
|
|
2247
|
|
2248 /* Output the changes. */
|
|
2249 output_display_line (w, cdla, ddla, first_line, -1, -1);
|
|
2250
|
|
2251 /* Update the offsets. */
|
|
2252 if (update_values)
|
|
2253 {
|
|
2254 int cur_line = first_line + 1;
|
|
2255 while (cur_line < Dynarr_length (cdla))
|
|
2256 {
|
|
2257 Dynarr_atp (cdla, cur_line)->offset += (new_len - old_len);
|
|
2258 Dynarr_atp (ddla, cur_line)->offset += (new_len - old_len);
|
|
2259 cur_line++;
|
|
2260 }
|
|
2261 }
|
|
2262
|
|
2263 /* Update the window_end_pos and other settings. */
|
|
2264 if (update_values)
|
|
2265 {
|
|
2266 w->window_end_pos[CURRENT_DISP] -= (new_len - old_len);
|
|
2267
|
|
2268 if (Dynarr_atp (ddla, first_line)->cursor_elt != -1)
|
|
2269 {
|
|
2270 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2271 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2272 }
|
|
2273 }
|
|
2274
|
|
2275 first_line++;
|
|
2276 }
|
|
2277
|
|
2278 /* Update the window max line length. We have to scan the entire
|
|
2279 set of display lines otherwise we might not detect if the max is
|
|
2280 supposed to shrink. */
|
|
2281 if (update_values)
|
|
2282 {
|
|
2283 int line = 0;
|
|
2284
|
|
2285 w->max_line_len = 0;
|
|
2286 while (line < Dynarr_length (ddla))
|
|
2287 {
|
|
2288 struct display_line *dl = Dynarr_atp (ddla, line);
|
|
2289
|
|
2290 if (!dl->modeline)
|
|
2291 w->max_line_len = max (dl->num_chars, w->max_line_len);
|
|
2292
|
|
2293 line++;
|
|
2294 }
|
|
2295 }
|
|
2296
|
|
2297 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2298 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2299 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2300 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2301 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2302 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2303
|
|
2304 /* We don't bother updating the vertical scrollbars here. This
|
|
2305 gives us a performance increase while having minimal loss of
|
|
2306 quality to the scrollbar slider size and position since when this
|
|
2307 function is called we know that the changes to the buffer were
|
|
2308 very localized. We have to update the horizontal scrollbars,
|
|
2309 though, because this routine could cause a change which has a
|
|
2310 larger impact on their sizing. */
|
|
2311 /* #### See if we can get away with only calling this if
|
|
2312 max_line_len is greater than the window_char_width. */
|
462
|
2313 /* #### BILL!!! Should we do this for GTK as well? */
|
428
|
2314 #if defined(HAVE_SCROLLBARS) && defined(HAVE_X_WINDOWS)
|
|
2315 {
|
|
2316 extern int stupid_vertical_scrollbar_drag_hack;
|
|
2317
|
|
2318 update_window_scrollbars (w, NULL, 1, stupid_vertical_scrollbar_drag_hack);
|
|
2319 stupid_vertical_scrollbar_drag_hack = 1;
|
|
2320 }
|
|
2321 #endif
|
|
2322
|
442
|
2323 redisplay_redraw_cursor (f, 0);
|
|
2324 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2325 }
|
|
2326
|
|
2327 /*****************************************************************************
|
|
2328 redisplay_output_window
|
|
2329
|
|
2330 For the given window W, ensure that the current display lines are
|
|
2331 equal to the desired display lines, outputing changes as necessary.
|
|
2332
|
|
2333 #### Fuck me. This just isn't going to cut it for tty's. The output
|
|
2334 decisions for them must be based on the contents of the entire frame
|
|
2335 because that is how the available output capabilities think. The
|
|
2336 solution is relatively simple. Create redisplay_output_frame. This
|
|
2337 will basically merge all of the separate window display structs into
|
|
2338 a single one for the frame. This combination structure will be able
|
|
2339 to be passed to the same output_display_line which works for windows
|
|
2340 on X frames and the right things will happen. It just takes time to
|
|
2341 do.
|
|
2342 ****************************************************************************/
|
|
2343 void
|
|
2344 redisplay_output_window (struct window *w)
|
|
2345 {
|
|
2346 struct frame *f = XFRAME (w->frame);
|
|
2347 struct device *d = XDEVICE (f->device);
|
|
2348
|
|
2349 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2350 display_line_dynarr *ddla = window_display_lines (w, DESIRED_DISP);
|
|
2351
|
|
2352 int cdla_len = Dynarr_length (cdla);
|
|
2353 int ddla_len = Dynarr_length (ddla);
|
|
2354
|
|
2355 int line;
|
|
2356 int need_to_clear_bottom = 0;
|
|
2357 int need_to_clear_start = -1;
|
|
2358 int need_to_clear_end = -1;
|
|
2359
|
|
2360 /* Backgrounds may have changed or windows may have gone away
|
|
2361 leaving dividers lying around. */
|
|
2362 if (f->faces_changed
|
|
2363 || f->windows_structure_changed
|
|
2364 || w->shadow_thickness_changed)
|
|
2365 need_to_clear_bottom = 1;
|
|
2366
|
|
2367 /* The first thing we do is determine if we are going to need to
|
|
2368 clear the bottom of the window. We only need to do this if the
|
|
2369 bottom of the current display lines is below the bottom of the
|
|
2370 desired display lines. Note that the number of lines is
|
|
2371 irrelevant. Only the position matters. We also clear to the
|
|
2372 bottom of the window if the modeline has shifted position. */
|
|
2373 /* #### We can't blindly not clear the bottom if f->clear is true
|
|
2374 since there might be a window-local background. However, for
|
|
2375 those cases where there isn't, clearing the end of the window in
|
|
2376 this case sucks. */
|
|
2377 if (!need_to_clear_bottom)
|
|
2378 {
|
|
2379 struct display_line *cdl, *ddl;
|
|
2380
|
|
2381 /* If the modeline has changed position or size, clear the bottom
|
|
2382 of the window. */
|
|
2383 if (!need_to_clear_bottom)
|
|
2384 {
|
|
2385 cdl = ddl = 0;
|
|
2386
|
|
2387 if (cdla_len)
|
|
2388 cdl = Dynarr_atp (cdla, 0);
|
|
2389 if (ddla_len)
|
|
2390 ddl = Dynarr_atp (ddla, 0);
|
|
2391
|
|
2392 if (!cdl || !ddl)
|
|
2393 need_to_clear_bottom = 1;
|
|
2394 else if ((!cdl->modeline && ddl->modeline)
|
|
2395 || (cdl->modeline && !ddl->modeline))
|
|
2396 need_to_clear_bottom = 1;
|
|
2397 else if (cdl->ypos != ddl->ypos ||
|
|
2398 cdl->ascent != ddl->ascent ||
|
|
2399 cdl->descent != ddl->descent ||
|
|
2400 cdl->clip != ddl->clip)
|
|
2401 need_to_clear_bottom = 1;
|
|
2402
|
|
2403 /* #### This kludge is to make sure the modeline shadows get
|
|
2404 redrawn if the modeline position shifts. */
|
|
2405 if (need_to_clear_bottom)
|
|
2406 w->shadow_thickness_changed = 1;
|
|
2407 }
|
|
2408
|
|
2409 if (!need_to_clear_bottom)
|
|
2410 {
|
|
2411 cdl = ddl = 0;
|
|
2412
|
|
2413 if (cdla_len)
|
|
2414 cdl = Dynarr_atp (cdla, cdla_len - 1);
|
|
2415 if (ddla_len)
|
|
2416 ddl = Dynarr_atp (ddla, ddla_len - 1);
|
|
2417
|
|
2418 if (!cdl || !ddl)
|
|
2419 need_to_clear_bottom = 1;
|
|
2420 else
|
|
2421 {
|
|
2422 int cdl_bottom, ddl_bottom;
|
|
2423
|
|
2424 cdl_bottom = cdl->ypos + cdl->descent;
|
|
2425 ddl_bottom = ddl->ypos + ddl->descent;
|
|
2426
|
|
2427 if (cdl_bottom > ddl_bottom)
|
|
2428 {
|
|
2429 need_to_clear_bottom = 1;
|
|
2430 need_to_clear_start = ddl_bottom;
|
|
2431 need_to_clear_end = cdl_bottom;
|
|
2432 }
|
|
2433 }
|
|
2434 }
|
|
2435 }
|
|
2436
|
|
2437 /* Perform any output initialization. */
|
442
|
2438 MAYBE_DEVMETH (d, window_output_begin, (w));
|
428
|
2439
|
|
2440 /* If the window's structure has changed clear the internal border
|
|
2441 above it if it is topmost (the function will check). */
|
448
|
2442 if (f->windows_structure_changed || f->faces_changed)
|
428
|
2443 redisplay_clear_top_of_window (w);
|
|
2444
|
|
2445 /* Output each line. */
|
|
2446 for (line = 0; line < Dynarr_length (ddla); line++)
|
|
2447 {
|
|
2448 output_display_line (w, cdla, ddla, line, -1, -1);
|
|
2449 }
|
|
2450
|
|
2451 /* If the number of display lines has shrunk, adjust. */
|
|
2452 if (cdla_len > ddla_len)
|
|
2453 {
|
|
2454 Dynarr_length (cdla) = ddla_len;
|
|
2455 }
|
|
2456
|
|
2457 /* Output a vertical divider between windows, if necessary. */
|
|
2458 if (window_needs_vertical_divider (w)
|
|
2459 && (f->windows_structure_changed || f->clear))
|
|
2460 {
|
442
|
2461 MAYBE_DEVMETH (d, output_vertical_divider, (w, f->windows_structure_changed));
|
428
|
2462 }
|
|
2463
|
|
2464 /* Clear the rest of the window, if necessary. */
|
|
2465 if (need_to_clear_bottom)
|
|
2466 {
|
|
2467 redisplay_clear_bottom_of_window (w, ddla, need_to_clear_start,
|
|
2468 need_to_clear_end);
|
|
2469 }
|
|
2470
|
|
2471 w->window_end_pos[CURRENT_DISP] = w->window_end_pos[DESIRED_DISP];
|
|
2472 Fset_marker (w->start[CURRENT_DISP],
|
|
2473 make_int (marker_position (w->start[DESIRED_DISP])),
|
|
2474 w->buffer);
|
|
2475 Fset_marker (w->pointm[CURRENT_DISP],
|
|
2476 make_int (marker_position (w->pointm[DESIRED_DISP])),
|
|
2477 w->buffer);
|
|
2478 w->last_modified[CURRENT_DISP] = w->last_modified[DESIRED_DISP];
|
|
2479 w->last_facechange[CURRENT_DISP] = w->last_facechange[DESIRED_DISP];
|
|
2480 Fset_marker (w->last_start[CURRENT_DISP],
|
|
2481 Fmarker_position (w->last_start[DESIRED_DISP]), w->buffer);
|
|
2482 Fset_marker (w->last_point[CURRENT_DISP],
|
|
2483 Fmarker_position (w->last_point[DESIRED_DISP]), w->buffer);
|
|
2484 w->last_point_x[CURRENT_DISP] = w->last_point_x[DESIRED_DISP];
|
|
2485 w->last_point_y[CURRENT_DISP] = w->last_point_y[DESIRED_DISP];
|
|
2486 w->shadow_thickness_changed = 0;
|
|
2487
|
|
2488 set_window_display_buffer (w, XBUFFER (w->buffer));
|
|
2489 find_window_mirror (w)->truncate_win = window_truncation_on (w);
|
|
2490
|
|
2491 /* Overkill on invalidating the cache. It is very bad for it to not
|
|
2492 get invalidated when it should be. */
|
|
2493 INVALIDATE_DEVICE_PIXEL_TO_GLYPH_CACHE (d);
|
|
2494
|
442
|
2495 redisplay_redraw_cursor (f, 0);
|
|
2496 MAYBE_DEVMETH (d, window_output_end, (w));
|
428
|
2497
|
|
2498 #ifdef HAVE_SCROLLBARS
|
|
2499 update_window_scrollbars (w, NULL, !MINI_WINDOW_P (w), 0);
|
|
2500 #endif
|
|
2501 }
|
|
2502
|
|
2503 /*****************************************************************************
|
1318
|
2504 redisplay_redraw_exposed_window
|
|
2505
|
|
2506 Given a bounding box for an area that needs to be redrawn, determine
|
|
2507 what parts of what lines are contained within and re-output their
|
|
2508 contents.
|
|
2509 ****************************************************************************/
|
|
2510 static void
|
|
2511 redisplay_redraw_exposed_window (struct window *w, int x, int y, int width,
|
|
2512 int height)
|
|
2513 {
|
|
2514 struct frame *f = XFRAME (w->frame);
|
|
2515 int line;
|
|
2516 int start_x, start_y, end_x, end_y;
|
|
2517 int orig_windows_structure_changed;
|
|
2518
|
|
2519 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
|
|
2520
|
|
2521 if (!NILP (w->vchild))
|
|
2522 {
|
|
2523 redisplay_redraw_exposed_windows (w->vchild, x, y, width, height);
|
|
2524 return;
|
|
2525 }
|
|
2526 else if (!NILP (w->hchild))
|
|
2527 {
|
|
2528 redisplay_redraw_exposed_windows (w->hchild, x, y, width, height);
|
|
2529 return;
|
|
2530 }
|
|
2531
|
|
2532 /* If the window doesn't intersect the exposed region, we're done here. */
|
|
2533 if (x >= WINDOW_RIGHT (w) || (x + width) <= WINDOW_LEFT (w)
|
|
2534 || y >= WINDOW_BOTTOM (w) || (y + height) <= WINDOW_TOP (w))
|
|
2535 {
|
|
2536 return;
|
|
2537 }
|
|
2538 else
|
|
2539 {
|
|
2540 start_x = max (WINDOW_LEFT (w), x);
|
|
2541 end_x = min (WINDOW_RIGHT (w), (x + width));
|
|
2542 start_y = max (WINDOW_TOP (w), y);
|
|
2543 end_y = min (WINDOW_BOTTOM (w), y + height);
|
|
2544
|
|
2545 /* We do this to make sure that the 3D modelines get redrawn if
|
|
2546 they are in the exposed region. */
|
|
2547 orig_windows_structure_changed = f->windows_structure_changed;
|
|
2548 f->windows_structure_changed = 1;
|
|
2549 }
|
|
2550
|
|
2551 /* #### Not in GTK or MS Windows. I think is because of toolbars, which
|
|
2552 are handled as widgets in GTK and MS Windows, but drawn ourselves in
|
|
2553 X. For the moment I'm leaving this in, if it causes problems we have
|
|
2554 some device method indicating whether we're drawing our own
|
|
2555 toolbars. */
|
|
2556 redisplay_clear_top_of_window (w);
|
|
2557 if (window_needs_vertical_divider (w))
|
|
2558 {
|
|
2559 FRAMEMETH (f, output_vertical_divider, (w, 0));
|
|
2560 }
|
|
2561
|
|
2562 for (line = 0; line < Dynarr_length (cdla); line++)
|
|
2563 {
|
|
2564 struct display_line *cdl = Dynarr_atp (cdla, line);
|
|
2565 int top_y = DISPLAY_LINE_YPOS (cdl);
|
|
2566 int bottom_y = DISPLAY_LINE_YPOS (cdl) + DISPLAY_LINE_HEIGHT (cdl);
|
|
2567
|
|
2568 if (bottom_y >= start_y)
|
|
2569 {
|
|
2570 if (top_y > end_y)
|
|
2571 {
|
|
2572 if (line == 0)
|
|
2573 continue;
|
|
2574 else
|
|
2575 break;
|
|
2576 }
|
|
2577 else
|
|
2578 {
|
|
2579 output_display_line (w, 0, cdla, line, start_x, end_x);
|
|
2580 }
|
|
2581 }
|
|
2582 }
|
|
2583
|
|
2584 f->windows_structure_changed = orig_windows_structure_changed;
|
|
2585
|
|
2586 /* If there have never been any face cache_elements created, then this
|
|
2587 expose event doesn't actually have anything to do. */
|
|
2588 if (Dynarr_largest (w->face_cachels))
|
|
2589 redisplay_clear_bottom_of_window (w, cdla, start_y, end_y);
|
|
2590
|
|
2591 #ifdef HAVE_SCROLLBARS
|
|
2592 MAYBE_FRAMEMETH (f, redisplay_deadbox, (w, x, y, width, height));
|
|
2593 #endif
|
|
2594 }
|
|
2595
|
|
2596
|
|
2597 /*****************************************************************************
|
|
2598 redisplay_redraw_exposed_windows
|
|
2599
|
|
2600 For each window beneath the given window in the window hierarchy,
|
|
2601 ensure that it is redrawn if necessary after an Expose event.
|
|
2602 ****************************************************************************/
|
|
2603 static void
|
|
2604 redisplay_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
|
|
2605 int height)
|
|
2606 {
|
|
2607 for (; !NILP (window); window = XWINDOW (window)->next)
|
|
2608 redisplay_redraw_exposed_window (XWINDOW (window), x, y, width, height);
|
|
2609 }
|
|
2610
|
|
2611 static void
|
|
2612 redisplay_redraw_exposed_area_1 (Lisp_Object arg)
|
|
2613 {
|
|
2614 assert (!in_display);
|
|
2615 redisplay_redraw_exposed_area (XFRAME (X1ST (arg)),
|
|
2616 XINT (X2ND (arg)),
|
|
2617 XINT (X3RD (arg)),
|
|
2618 XINT (X4TH (arg)),
|
|
2619 XINT (X5TH (arg)));
|
|
2620 free_list (arg);
|
|
2621 }
|
|
2622
|
|
2623 /*****************************************************************************
|
|
2624 redisplay_redraw_exposed_area
|
|
2625
|
|
2626 For each window on the given frame, ensure that any area in the
|
|
2627 Exposed area is redrawn.
|
|
2628 ****************************************************************************/
|
|
2629 void
|
|
2630 redisplay_redraw_exposed_area (struct frame *f, int x, int y, int width,
|
|
2631 int height)
|
|
2632 {
|
|
2633 int depth;
|
|
2634
|
|
2635 if (in_display)
|
|
2636 {
|
|
2637 /* Not safe to do it now, so delay it */
|
|
2638 register_post_redisplay_action (redisplay_redraw_exposed_area_1,
|
|
2639 list5 (wrap_frame (f), make_int (x),
|
|
2640 make_int (y), make_int (width),
|
|
2641 make_int (height)));
|
|
2642 return;
|
|
2643 }
|
|
2644
|
|
2645 depth = enter_redisplay_critical_section ();
|
|
2646
|
|
2647 MAYBE_FRAMEMETH (f, frame_output_begin, (f));
|
|
2648
|
|
2649 /* If any window on the frame has had its face cache reset then the
|
|
2650 redisplay structures are effectively invalid. If we attempt to
|
|
2651 use them we'll blow up. We mark the frame as changed to ensure
|
|
2652 that redisplay will do a full update. This probably isn't
|
|
2653 necessary but it can't hurt. */
|
|
2654 #ifdef HAVE_TOOLBARS
|
|
2655 /* #### We would rather put these off as well but there is currently
|
|
2656 no combination of flags which will force an unchanged toolbar to
|
|
2657 redraw anyhow. */
|
|
2658 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
|
|
2659 #endif
|
|
2660 redraw_exposed_gutters (f, x, y, width, height);
|
|
2661
|
|
2662 if (!f->window_face_cache_reset)
|
|
2663 {
|
|
2664 redisplay_redraw_exposed_windows (f->root_window, x, y, width, height);
|
|
2665 /* #### Why not call this always? */
|
|
2666 MAYBE_FRAMEMETH (f, frame_output_end, (f));
|
|
2667 }
|
|
2668 else
|
|
2669 MARK_FRAME_CHANGED (f);
|
|
2670
|
|
2671 exit_redisplay_critical_section (depth);
|
|
2672 }
|
|
2673
|
|
2674 /*****************************************************************************
|
428
|
2675 bevel_modeline
|
|
2676
|
|
2677 Draw a 3d border around the modeline on window W.
|
|
2678 ****************************************************************************/
|
|
2679 void
|
|
2680 bevel_modeline (struct window *w, struct display_line *dl)
|
|
2681 {
|
|
2682 struct frame *f = XFRAME (w->frame);
|
|
2683 struct device *d = XDEVICE (f->device);
|
|
2684 int x, y, width, height;
|
|
2685 int shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
|
|
2686 enum edge_style style;
|
|
2687
|
|
2688 x = WINDOW_MODELINE_LEFT (w);
|
|
2689 width = WINDOW_MODELINE_RIGHT (w) - x;
|
|
2690 y = dl->ypos - dl->ascent - shadow_thickness;
|
|
2691 height = dl->ascent + dl->descent + 2 * shadow_thickness;
|
|
2692
|
|
2693 if (XINT (w->modeline_shadow_thickness) < 0)
|
|
2694 {
|
|
2695 style = EDGE_BEVEL_IN;
|
|
2696 }
|
|
2697 else
|
|
2698 {
|
|
2699 style = EDGE_BEVEL_OUT;
|
|
2700 }
|
|
2701
|
434
|
2702 MAYBE_DEVMETH (d, bevel_area,
|
428
|
2703 (w, MODELINE_INDEX, x, y, width, height, shadow_thickness,
|
|
2704 EDGE_ALL, style));
|
|
2705 }
|