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