comparison src/redisplay-xlike-inc.c @ 5627:37fb945697f5

text_width_single_run cleanup. -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2011-12-28 Didier Verna <didier@xemacs.org> * redisplay-xlike-inc.c (XLIKE_text_width_single_run): Get only what's needed as argument: an XLIKE_DISPLAY instead of a frame pointer. * redisplay-xlike-inc.c (XLIKE_text_width): * redisplay-xlike-inc.c (XLIKE_output_string): Update accordingly. Use the generic XLIKE_ name instead of the specific x_ one.
author Didier Verna <didier@xemacs.org>
date Wed, 28 Dec 2011 10:53:38 +0100
parents c39052c921b5
children 81fee4aee9b6
comparison
equal deleted inserted replaced
5626:eb41da9b4469 5627:37fb945697f5
457 /* Xlike output routines */ 457 /* Xlike output routines */
458 /* */ 458 /* */
459 /****************************************************************************/ 459 /****************************************************************************/
460 460
461 static int 461 static int
462 XLIKE_text_width_single_run (struct frame * USED_IF_XFT (f), 462 XLIKE_text_width_single_run (XLIKE_DISPLAY USED_IF_XFT (dpy),
463 struct face_cachel *cachel, 463 struct face_cachel *cachel,
464 struct textual_run *run) 464 struct textual_run *run)
465 { 465 {
466 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset); 466 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
467 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst); 467 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
470 return fi->width * run->len; 470 return fi->width * run->len;
471 #ifdef USE_XFT 471 #ifdef USE_XFT
472 else if (FONT_INSTANCE_X_XFTFONT (fi)) 472 else if (FONT_INSTANCE_X_XFTFONT (fi))
473 { 473 {
474 static XGlyphInfo glyphinfo; 474 static XGlyphInfo glyphinfo;
475 struct device *d = XDEVICE (f->device);
476 Display *dpy = DEVICE_X_DISPLAY (d);
477 475
478 if (run->dimension == 2) 476 if (run->dimension == 2)
479 { 477 {
480 XftTextExtents16 (dpy, 478 XftTextExtents16 (dpy,
481 FONT_INSTANCE_X_XFTFONT (fi), 479 FONT_INSTANCE_X_XFTFONT (fi),
524 { 522 {
525 /* !!#### Needs review */ 523 /* !!#### Needs review */
526 int width_so_far = 0; 524 int width_so_far = 0;
527 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len); 525 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
528 struct textual_run *runs = alloca_array (struct textual_run, len); 526 struct textual_run *runs = alloca_array (struct textual_run, len);
529 struct frame *f = WINDOW_XFRAME (w); 527 struct frame *f = XFRAME (w->frame);
528 struct device *d = XDEVICE (f->device);
529 XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
530 int nruns; 530 int nruns;
531 int i; 531 int i;
532 532
533 nruns = separate_textual_runs (text_storage, runs, str, len, 533 nruns = separate_textual_runs (text_storage, runs, str, len,
534 cachel); 534 cachel);
535 535
536 for (i = 0; i < nruns; i++) 536 for (i = 0; i < nruns; i++)
537 width_so_far += XLIKE_text_width_single_run (f, cachel, runs + i); 537 width_so_far += XLIKE_text_width_single_run (dpy, cachel, runs + i);
538 538
539 return width_so_far; 539 return width_so_far;
540 } 540 }
541 541
542 /***************************************************************************** 542 /*****************************************************************************
1116 int need_clipping; 1116 int need_clipping;
1117 1117
1118 if (EQ (font, Vthe_null_font_instance)) 1118 if (EQ (font, Vthe_null_font_instance))
1119 continue; 1119 continue;
1120 1120
1121 this_width = XLIKE_text_width_single_run (f, cachel, runs + i); 1121 this_width = XLIKE_text_width_single_run (dpy, cachel, runs + i);
1122 need_clipping = (dl->clip || clip_start > xpos || 1122 need_clipping = (dl->clip || clip_start > xpos ||
1123 clip_end < xpos + this_width); 1123 clip_end < xpos + this_width);
1124 1124
1125 /* XDrawImageString only clears the area equal to the height of 1125 /* XDrawImageString only clears the area equal to the height of
1126 the given font. It is possible that a font is being displayed 1126 the given font. It is possible that a font is being displayed
1243 this, it trashes aggressively laid-out elements like the 1243 this, it trashes aggressively laid-out elements like the
1244 modeline (overwriting part of the bevel). 1244 modeline (overwriting part of the bevel).
1245 OK, unconditionally redraw the bevel, and increment 1245 OK, unconditionally redraw the bevel, and increment
1246 rect_height by 1. See x_output_display_block. -- sjt */ 1246 rect_height by 1. See x_output_display_block. -- sjt */
1247 struct textual_run *run = &runs[i]; 1247 struct textual_run *run = &runs[i];
1248 int rect_width = x_text_width_single_run (f, cachel, run); 1248 int rect_width
1249 = XLIKE_text_width_single_run (dpy, cachel, run);
1249 #ifndef USE_XFTTEXTENTS_TO_AVOID_FONT_DROPPINGS 1250 #ifndef USE_XFTTEXTENTS_TO_AVOID_FONT_DROPPINGS
1250 int rect_height = FONT_INSTANCE_ASCENT (fi) 1251 int rect_height = FONT_INSTANCE_ASCENT (fi)
1251 + FONT_INSTANCE_DESCENT (fi) + 1; 1252 + FONT_INSTANCE_DESCENT (fi) + 1;
1252 #else 1253 #else
1253 int rect_height = FONT_INSTANCE_ASCENT (fi) 1254 int rect_height = FONT_INSTANCE_ASCENT (fi)
1456 XDestroyRegion (clip_reg); 1457 XDestroyRegion (clip_reg);
1457 } 1458 }
1458 { /* draw background rectangle & draw text */ 1459 { /* draw background rectangle & draw text */
1459 int rect_height = FONT_INSTANCE_ASCENT (fi) 1460 int rect_height = FONT_INSTANCE_ASCENT (fi)
1460 + FONT_INSTANCE_DESCENT (fi); 1461 + FONT_INSTANCE_DESCENT (fi);
1461 int rect_width = x_text_width_single_run (f, cachel, &runs[i]); 1462 int rect_width
1463 = XLIKE_text_width_single_run (dpy, cachel, &runs[i]);
1462 XftColor xft_color; 1464 XftColor xft_color;
1463 1465
1464 xft_color = XFT_FROB_LISP_COLOR (cursor_cachel->background, 0); 1466 xft_color = XFT_FROB_LISP_COLOR (cursor_cachel->background, 0);
1465 XftDrawRect (xftDraw, &xft_color, 1467 XftDrawRect (xftDraw, &xft_color,
1466 xpos, ypos, rect_width, rect_height); 1468 xpos, ypos, rect_width, rect_height);