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