comparison src/redisplay-x.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 6240c7796c7a
children bbff43aa5eb7
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
927 cursor_cachel->background, Qnil, Qnil); 927 cursor_cachel->background, Qnil, Qnil);
928 else if (cachel->dim) 928 else if (cachel->dim)
929 { 929 {
930 /* Ensure the gray bitmap exists */ 930 /* Ensure the gray bitmap exists */
931 if (DEVICE_X_GRAY_PIXMAP (d) == None) 931 if (DEVICE_X_GRAY_PIXMAP (d) == None)
932 DEVICE_X_GRAY_PIXMAP (d) = 932 DEVICE_X_GRAY_PIXMAP (d) =
933 XCreateBitmapFromData (dpy, x_win, (char *)gray_bits, 933 XCreateBitmapFromData (dpy, x_win, (char *)gray_bits,
934 gray_width, gray_height); 934 gray_width, gray_height);
935 935
936 /* Request a GC with the gray stipple pixmap to draw dimmed text */ 936 /* Request a GC with the gray stipple pixmap to draw dimmed text */
937 gc = x_get_gc (d, font, cachel->foreground, cachel->background, 937 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
1408 int use_pixmap = 0; 1408 int use_pixmap = 0;
1409 int flip_gcs = 0; 1409 int flip_gcs = 0;
1410 unsigned long mask; 1410 unsigned long mask;
1411 int x, y1, y2, width, shadow_thickness, spacing, line_width; 1411 int x, y1, y2, width, shadow_thickness, spacing, line_width;
1412 face_index div_face = get_builtin_face_cache_index (w, Vvertical_divider_face); 1412 face_index div_face = get_builtin_face_cache_index (w, Vvertical_divider_face);
1413 1413
1414 width = window_divider_width (w); 1414 width = window_divider_width (w);
1415 shadow_thickness = XINT (w->vertical_divider_shadow_thickness); 1415 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
1416 spacing = XINT (w->vertical_divider_spacing); 1416 spacing = XINT (w->vertical_divider_spacing);
1417 line_width = XINT (w->vertical_divider_line_width); 1417 line_width = XINT (w->vertical_divider_line_width);
1418 x = WINDOW_RIGHT (w) - width; 1418 x = WINDOW_RIGHT (w) - width;
1419 y1 = WINDOW_TOP (w); 1419 y1 = WINDOW_TOP (w);
1420 y2 = WINDOW_BOTTOM (w); 1420 y2 = WINDOW_BOTTOM (w);
1421 1421
1422 memset (&gcv, ~0, sizeof (XGCValues)); 1422 memset (&gcv, ~0, sizeof (XGCValues));
1423 1423
1424 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face); 1424 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
1425 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); 1425 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
1426 1426
1427 /* First, get the GC's. */ 1427 /* First, get the GC's. */
1428 top_shadow_pixel = tmp_color.pixel; 1428 top_shadow_pixel = tmp_color.pixel;
1429 bottom_shadow_pixel = tmp_color.pixel; 1429 bottom_shadow_pixel = tmp_color.pixel;
1430 background_pixel = tmp_color.pixel; 1430 background_pixel = tmp_color.pixel;
1431 1431
1432 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel, 1432 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
1433 background_pixel, ef->core.background_pixel); 1433 background_pixel, ef->core.background_pixel);
1434 1434
1435 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face); 1435 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face);
1436 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); 1436 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
1437 gcv.background = tmp_color.pixel; 1437 gcv.background = tmp_color.pixel;
1438 gcv.graphics_exposures = False; 1438 gcv.graphics_exposures = False;
1439 mask = GCForeground | GCBackground | GCGraphicsExposures; 1439 mask = GCForeground | GCBackground | GCGraphicsExposures;
1440 1440
1441 /* If we can't distinguish one of the shadows (the color is the same as the 1441 /* If we can't distinguish one of the shadows (the color is the same as the
1442 background), it's better to use a pixmap to generate a dithrered gray. */ 1442 background), it's better to use a pixmap to generate a dithered gray. */
1443 if (top_shadow_pixel == background_pixel || 1443 if (top_shadow_pixel == background_pixel ||
1444 bottom_shadow_pixel == background_pixel) 1444 bottom_shadow_pixel == background_pixel)
1445 use_pixmap = 1; 1445 use_pixmap = 1;
1446 1446
1447 if (use_pixmap) 1447 if (use_pixmap)
1448 { 1448 {
1449 if (DEVICE_X_GRAY_PIXMAP (d) == None) 1449 if (DEVICE_X_GRAY_PIXMAP (d) == None)
1450 { 1450 {
1451 DEVICE_X_GRAY_PIXMAP (d) = 1451 DEVICE_X_GRAY_PIXMAP (d) =
1452 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits, 1452 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
1453 gray_width, gray_height, 1, 0, 1); 1453 gray_width, gray_height, 1, 0, 1);
1454 } 1454 }
1455 1455
1456 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face); 1456 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
1457 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); 1457 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
1458 gcv.foreground = tmp_color.pixel; 1458 gcv.foreground = tmp_color.pixel;
1459 /* this is needed because the GC draws with a pixmap here */ 1459 /* this is needed because the GC draws with a pixmap here */
1460 gcv.fill_style = FillOpaqueStippled; 1460 gcv.fill_style = FillOpaqueStippled;
1461 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d); 1461 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
1462 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, 1462 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
1463 (mask | GCStipple | GCFillStyle)); 1463 (mask | GCStipple | GCFillStyle));
1464 1464
1465 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face); 1465 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face);
1466 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); 1466 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
1467 bottom_shadow_pixel = tmp_color.pixel; 1467 bottom_shadow_pixel = tmp_color.pixel;
1468 1468
1469 flip_gcs = (bottom_shadow_pixel == 1469 flip_gcs = (bottom_shadow_pixel ==
1470 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy))); 1470 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
1471 } 1471 }
1472 else 1472 else
1473 { 1473 {
1474 gcv.foreground = top_shadow_pixel; 1474 gcv.foreground = top_shadow_pixel;
1475 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); 1475 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
1476 } 1476 }
1477 1477
1478 gcv.foreground = bottom_shadow_pixel; 1478 gcv.foreground = bottom_shadow_pixel;
1479 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); 1479 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
1480 1480
1481 if (use_pixmap && flip_gcs) 1481 if (use_pixmap && flip_gcs)
1482 { 1482 {
1483 GC tmp_gc = bottom_shadow_gc; 1483 GC tmp_gc = bottom_shadow_gc;
1484 bottom_shadow_gc = top_shadow_gc; 1484 bottom_shadow_gc = top_shadow_gc;
1485 top_shadow_gc = tmp_gc; 1485 top_shadow_gc = tmp_gc;
1486 } 1486 }
1487 1487
1488 gcv.foreground = background_pixel; 1488 gcv.foreground = background_pixel;
1489 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask); 1489 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
1490 1490
1491 /* possibly revert the GC's in case the shadow thickness is < 0. 1491 /* possibly revert the GC's in case the shadow thickness is < 0.
1492 This will give a depressed look to the divider */ 1492 This will give a depressed look to the divider */
1493 if (shadow_thickness < 0) 1493 if (shadow_thickness < 0)
1494 { 1494 {
1495 GC temp; 1495 GC temp;
1496 1496
1497 temp = top_shadow_gc; 1497 temp = top_shadow_gc;
1498 top_shadow_gc = bottom_shadow_gc; 1498 top_shadow_gc = bottom_shadow_gc;
1499 bottom_shadow_gc = temp; 1499 bottom_shadow_gc = temp;
1500 1500
1501 /* better avoid a Bad Adress XLib error ;-) */ 1501 /* better avoid a Bad Address XLib error ;-) */
1502 shadow_thickness = - shadow_thickness; 1502 shadow_thickness = - shadow_thickness;
1503 } 1503 }
1504 1504
1505 /* Clear the divider area first. This needs to be done when a 1505 /* Clear the divider area first. This needs to be done when a
1506 window split occurs. */ 1506 window split occurs. */
1507 if (clear) 1507 if (clear)
1508 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False); 1508 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
1509 1509
1510 /* Draw the divider line. */ 1510 /* Draw the divider line. */
1511 XFillRectangle (dpy, x_win, background_gc, 1511 XFillRectangle (dpy, x_win, background_gc,
1512 x + spacing + shadow_thickness, y1, 1512 x + spacing + shadow_thickness, y1,
1513 line_width, y2 - y1); 1513 line_width, y2 - y1);
1514 1514
1515 /* Draw the shadows around the divider line */ 1515 /* Draw the shadows around the divider line */
1516 x_output_shadows (f, x + spacing, y1, 1516 x_output_shadows (f, x + spacing, y1,
1517 width - 2 * spacing, y2 - y1, 1517 width - 2 * spacing, y2 - y1,
1518 top_shadow_gc, bottom_shadow_gc, 1518 top_shadow_gc, bottom_shadow_gc,
1519 background_gc, shadow_thickness); 1519 background_gc, shadow_thickness);
1520 } 1520 }
1521 1521
1676 1676
1677 /***************************************************************************** 1677 /*****************************************************************************
1678 x_output_shadows 1678 x_output_shadows
1679 1679
1680 Draw a shadow around the given area using the given GC's. It is the 1680 Draw a shadow around the given area using the given GC's. It is the
1681 callers responsibility to ste the GC's appropriately. 1681 callers responsibility to set the GC's appropriately.
1682 ****************************************************************************/ 1682 ****************************************************************************/
1683 void 1683 void
1684 x_output_shadows (struct frame *f, int x, int y, int width, int height, 1684 x_output_shadows (struct frame *f, int x, int y, int width, int height,
1685 GC top_shadow_gc, GC bottom_shadow_gc, GC background_gc, 1685 GC top_shadow_gc, GC bottom_shadow_gc, GC background_gc,
1686 int shadow_thickness) 1686 int shadow_thickness)