ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.96 by sf-exg, Fri Oct 22 16:49:26 2010 UTC vs.
Revision 1.109 by sf-exg, Tue Nov 2 22:01:47 2010 UTC

23 *---------------------------------------------------------------------*/ 23 *---------------------------------------------------------------------*/
24 24
25#include <cmath> 25#include <cmath>
26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28
29#if XRENDER
30# include <X11/extensions/Xrender.h>
31#endif
28 32
29#define DO_TIMING_TEST 0 33#define DO_TIMING_TEST 0
30 34
31#if DO_TIMING_TEST 35#if DO_TIMING_TEST
32# include <sys/time.h> 36# include <sys/time.h>
729 return false; 733 return false;
730 734
731 if (!pixbuf) 735 if (!pixbuf)
732 return false; 736 return false;
733 737
734#if !XFT
735 if (background_flags) 738 if (background_flags
739 && !(flags & HAS_RENDER))
736 return false; 740 return false;
737#endif
738 741
739 GdkPixbuf *result; 742 GdkPixbuf *result;
740 743
741 int image_width = gdk_pixbuf_get_width (pixbuf); 744 int image_width = gdk_pixbuf_get_width (pixbuf);
742 int image_height = gdk_pixbuf_get_height (pixbuf); 745 int image_height = gdk_pixbuf_get_height (pixbuf);
856 dst_width, dst_height, 859 dst_width, dst_height,
857 XLIB_RGB_DITHER_NONE, 860 XLIB_RGB_DITHER_NONE,
858 0, 0); 861 0, 0);
859 } 862 }
860 863
861#if XFT 864#if XRENDER
862 if (background_flags) 865 if (background_flags)
863 { 866 {
864 Display *dpy = target->dpy; 867 Display *dpy = target->dpy;
865 XRenderPictureAttributes pa; 868 XRenderPictureAttributes pa;
866 869
867 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, target->display->screen)); 870 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, target->visual);
868 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 871 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
869 872
870 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); 873 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual);
871 Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); 874 Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa);
872 875
909# endif /* HAVE_PIXBUF */ 912# endif /* HAVE_PIXBUF */
910 913
911bool 914bool
912bgPixmap_t::set_file (const char *file) 915bgPixmap_t::set_file (const char *file)
913{ 916{
914 assert (file); 917 if (!file || !*file)
918 return false;
915 919
916 if (*file)
917 {
918 if (const char *p = strchr (file, ';')) 920 if (const char *p = strchr (file, ';'))
919 { 921 {
920 size_t len = p - file; 922 size_t len = p - file;
921 char *f = rxvt_temp_buf<char> (len + 1); 923 char *f = rxvt_temp_buf<char> (len + 1);
922 memcpy (f, file, len); 924 memcpy (f, file, len);
923 f[len] = '\0'; 925 f[len] = '\0';
924 file = f; 926 file = f;
925 } 927 }
926 928
927# ifdef HAVE_AFTERIMAGE 929# ifdef HAVE_AFTERIMAGE
928 if (!target->asimman) 930 if (!target->asimman)
929 target->asimman = create_generic_imageman (target->rs[Rs_path]); 931 target->asimman = create_generic_imageman (target->rs[Rs_path]);
930 ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); 932 ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
931 if (image) 933 if (image)
932 { 934 {
933 if (original_asim) 935 if (original_asim)
934 safe_asimage_destroy (original_asim); 936 safe_asimage_destroy (original_asim);
935 original_asim = image; 937 original_asim = image;
936 have_image = true; 938 have_image = true;
937 return true; 939 return true;
938 } 940 }
939# endif 941# endif
940 942
941# ifdef HAVE_PIXBUF 943# ifdef HAVE_PIXBUF
942 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); 944 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL);
943 if (image) 945 if (image)
944 { 946 {
945 if (pixbuf) 947 if (pixbuf)
946 g_object_unref (pixbuf); 948 g_object_unref (pixbuf);
947 pixbuf = image; 949 pixbuf = image;
948 have_image = true; 950 have_image = true;
949 return true; 951 return true;
950 } 952 }
951# endif 953# endif
952 }
953 954
954 return false; 955 return false;
955} 956}
956 957
957# endif /* BG_IMAGE_FROM_FILE */ 958# endif /* BG_IMAGE_FROM_FILE */
999 1000
1000 if (v_blurRadius == 0 && h_blurRadius == 0) 1001 if (v_blurRadius == 0 && h_blurRadius == 0)
1001 flags &= ~blurNeeded; 1002 flags &= ~blurNeeded;
1002 else 1003 else
1003 flags |= blurNeeded; 1004 flags |= blurNeeded;
1004
1005#if XFT
1006 XFilters *filters = XRenderQueryFilters (target->dpy, target->display->root);
1007 if (filters)
1008 {
1009 for (int i = 0; i < filters->nfilter; i++)
1010 if (!strcmp (filters->filter[i], FilterConvolution))
1011 flags |= bgPixmap_t::blurServerSide;
1012
1013 XFree (filters);
1014 }
1015#endif
1016 1005
1017 return (changed > 0); 1006 return (changed > 0);
1018} 1007}
1019 1008
1020static inline unsigned long 1009static inline unsigned long
1044 { 1033 {
1045 flags |= bgPixmap_t::tintNeeded; 1034 flags |= bgPixmap_t::tintNeeded;
1046 } 1035 }
1047 } 1036 }
1048 1037
1049 if (flags & bgPixmap_t::tintNeeded)
1050 {
1051 if (flags & bgPixmap_t::tintWholesome)
1052 flags |= bgPixmap_t::tintServerSide;
1053 else
1054 {
1055#if XFT
1056 flags |= bgPixmap_t::tintServerSide;
1057#endif
1058 }
1059 }
1060
1061 return flags; 1038 return flags;
1062} 1039}
1063 1040
1064bool 1041bool
1065bgPixmap_t::set_tint (rxvt_color &new_tint) 1042bgPixmap_t::set_tint (rxvt_color &new_tint)
1107 } 1084 }
1108 1085
1109 return false; 1086 return false;
1110} 1087}
1111 1088
1112#if XFT 1089#if XRENDER
1113static void 1090static void
1114get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) 1091get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params)
1115{ 1092{
1116 double sigma = radius / 2.0; 1093 double sigma = radius / 2.0;
1117 double scale = sqrt (2.0 * M_PI) * sigma; 1094 double scale = sqrt (2.0 * M_PI) * sigma;
1134 1111
1135bool 1112bool
1136bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1113bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1137{ 1114{
1138 bool ret = false; 1115 bool ret = false;
1139#if XFT 1116#if XRENDER
1140 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 1117 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
1141 double *kernel = (double *)malloc (size * sizeof (double)); 1118 double *kernel = (double *)malloc (size * sizeof (double));
1142 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1119 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1143 1120
1144 Display *dpy = target->dpy; 1121 Display *dpy = target->dpy;
1221 XFreeGC (dpy, gc); 1198 XFreeGC (dpy, gc);
1222 } 1199 }
1223 } 1200 }
1224 else 1201 else
1225 { 1202 {
1226# if XFT 1203# if XRENDER
1227 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1204 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1228 1205
1229 if (flags & tintSet) 1206 if (flags & tintSet)
1230 tint.get (c); 1207 tint.get (c);
1231 1208
1284 1261
1285 return ret; 1262 return ret;
1286} 1263}
1287 1264
1288/* make_transparency_pixmap() 1265/* make_transparency_pixmap()
1289 * Builds a pixmap sized the same as terminal window, with depth same as the root window 1266 * Builds a pixmap of the same size as the terminal window that contains
1290 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by 1267 * the tiled portion of the root pixmap that is supposed to be covered by
1291 * our window. 1268 * our window.
1292 */ 1269 */
1293unsigned long 1270unsigned long
1294bgPixmap_t::make_transparency_pixmap () 1271bgPixmap_t::make_transparency_pixmap ()
1295{ 1272{
1299 return 0; 1276 return 0;
1300 1277
1301 /* root dimensions may change from call to call - but Display structure should 1278 /* root dimensions may change from call to call - but Display structure should
1302 * be always up-to-date, so let's use it : 1279 * be always up-to-date, so let's use it :
1303 */ 1280 */
1304 Window root = target->display->root;
1305 int screen = target->display->screen; 1281 int screen = target->display->screen;
1306 Display *dpy = target->dpy; 1282 Display *dpy = target->dpy;
1283 int root_depth = DefaultDepth (dpy, screen);
1307 int root_width = DisplayWidth (dpy, screen); 1284 int root_width = DisplayWidth (dpy, screen);
1308 int root_height = DisplayHeight (dpy, screen); 1285 int root_height = DisplayHeight (dpy, screen);
1309 unsigned int root_pmap_width, root_pmap_height; 1286 unsigned int root_pmap_width, root_pmap_height;
1310 int window_width = target->szHint.width; 1287 int window_width = target->szHint.width;
1311 int window_height = target->szHint.height; 1288 int window_height = target->szHint.height;
1318 /* check if we are outside of the visible part of the virtual screen : */ 1295 /* check if we are outside of the visible part of the virtual screen : */
1319 if (sx + window_width <= 0 || sy + window_height <= 0 1296 if (sx + window_width <= 0 || sy + window_height <= 0
1320 || sx >= root_width || sy >= root_height) 1297 || sx >= root_width || sy >= root_height)
1321 return 0; 1298 return 0;
1322 1299
1300 // validate root pixmap and get its size
1323 if (root_pixmap != None) 1301 if (root_pixmap != None)
1324 { 1302 {
1325 /* we want to validate the pixmap and get its size at the same time : */ 1303 Window wdummy;
1326 int junk; 1304 int idummy;
1327 unsigned int ujunk; 1305 unsigned int udummy;
1328 /* root pixmap may be bad - allow a error */ 1306
1329 target->allowedxerror = -1; 1307 target->allowedxerror = -1;
1330 1308
1331 if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) 1309 if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy))
1332 root_pixmap = None; 1310 root_pixmap = None;
1333 1311
1334 target->allowedxerror = 0; 1312 target->allowedxerror = 0;
1313 }
1314
1315 Pixmap recoded_root_pmap = root_pixmap;
1316
1317 if (root_pixmap != None && root_depth != target->depth)
1318 {
1319#if XRENDER
1320 if (flags & HAS_RENDER)
1321 {
1322 XRenderPictureAttributes pa;
1323
1324 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1325 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1326
1327 recoded_root_pmap = XCreatePixmap (dpy, target->vt, root_pmap_width, root_pmap_height, target->depth);
1328 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual);
1329 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1330
1331 if (src && dst)
1332 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1333 else
1334 {
1335 XFreePixmap (dpy, recoded_root_pmap);
1336 root_pixmap = None;
1337 }
1338
1339 XRenderFreePicture (dpy, src);
1340 XRenderFreePicture (dpy, dst);
1341 }
1342 else
1343#endif
1344 root_pixmap = None;
1335 } 1345 }
1336 1346
1337 if (root_pixmap == None) 1347 if (root_pixmap == None)
1338 return 0; 1348 return 0;
1339 1349
1340 Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); 1350 Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth);
1341 1351
1342 if (tiled_root_pmap == None) /* something really bad happened - abort */ 1352 if (tiled_root_pmap == None) /* something really bad happened - abort */
1343 return 0; 1353 return 0;
1344 1354
1345 /* straightforward pixmap copy */ 1355 /* straightforward pixmap copy */
1346 gcv.tile = root_pixmap; 1356 gcv.tile = recoded_root_pmap;
1347 gcv.fill_style = FillTiled; 1357 gcv.fill_style = FillTiled;
1348 1358
1349 while (sx < 0) sx += (int)root_width; 1359 while (sx < 0) sx += (int)root_width;
1350 while (sy < 0) sy += (int)root_height; 1360 while (sy < 0) sy += (int)root_height;
1351 1361
1352 gcv.ts_x_origin = -sx; 1362 gcv.ts_x_origin = -sx;
1353 gcv.ts_y_origin = -sy; 1363 gcv.ts_y_origin = -sy;
1354 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1364 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1355 1365
1356 if (gc) 1366 if (gc)
1357 { 1367 {
1358 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1368 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1359 result |= transpPmapTiled; 1369 result |= transpPmapTiled;
1362 1372
1363 if (tiled_root_pmap != None) 1373 if (tiled_root_pmap != None)
1364 { 1374 {
1365 if (!need_client_side_rendering ()) 1375 if (!need_client_side_rendering ())
1366 { 1376 {
1367 if (flags & (blurNeeded | blurServerSide)) 1377 if ((flags & blurNeeded)
1378 && (flags & HAS_RENDER_CONV))
1368 { 1379 {
1369 if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) 1380 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1370 result |= transpPmapBlurred; 1381 result |= transpPmapBlurred;
1371 } 1382 }
1372 if (flags & (tintNeeded | tintServerSide)) 1383 if ((flags & tintNeeded)
1384 && (flags & (tintWholesome | HAS_RENDER)))
1373 { 1385 {
1374 if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) 1386 if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1375 result |= transpPmapTinted; 1387 result |= transpPmapTinted;
1376 } 1388 }
1377 } /* server side rendering completed */ 1389 } /* server side rendering completed */
1378 1390
1379 if (pixmap) 1391 if (pixmap)
1380 XFreePixmap (dpy, pixmap); 1392 XFreePixmap (dpy, pixmap);
1381 1393
1382 pixmap = tiled_root_pmap; 1394 pixmap = tiled_root_pmap;
1383 pmap_width = window_width; 1395 pmap_width = window_width;
1384 pmap_height = window_height; 1396 pmap_height = window_height;
1385 pmap_depth = root_depth; 1397 pmap_depth = target->depth;
1386 } 1398 }
1399
1400 if (recoded_root_pmap != root_pixmap)
1401 XFreePixmap (dpy, recoded_root_pmap);
1387 1402
1388 return result; 1403 return result;
1389} 1404}
1390 1405
1391bool 1406void
1392bgPixmap_t::set_root_pixmap () 1407bgPixmap_t::set_root_pixmap ()
1393{ 1408{
1394 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1409 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1395 if (new_root_pixmap == None) 1410 if (new_root_pixmap == None)
1396 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1411 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1397 1412
1398 if (new_root_pixmap != root_pixmap)
1399 {
1400 root_pixmap = new_root_pixmap; 1413 root_pixmap = new_root_pixmap;
1401 return true;
1402 }
1403
1404 return false;
1405} 1414}
1406# endif /* ENABLE_TRANSPARENCY */ 1415# endif /* ENABLE_TRANSPARENCY */
1407 1416
1408# ifndef HAVE_AFTERIMAGE 1417# ifndef HAVE_AFTERIMAGE
1409static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1418static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm);
1423 { 1432 {
1424 /* we need to re-generate transparency pixmap in that case ! */ 1433 /* we need to re-generate transparency pixmap in that case ! */
1425 background_flags = make_transparency_pixmap (); 1434 background_flags = make_transparency_pixmap ();
1426 if (background_flags == 0) 1435 if (background_flags == 0)
1427 return false; 1436 return false;
1428 else if ((background_flags & transpTransformations) == (flags & transpTransformations) 1437 else if ((background_flags & transpTransformations) == (flags & transpTransformations))
1429 && pmap_depth == target->depth)
1430 flags = flags & ~isInvalid; 1438 flags = flags & ~isInvalid;
1431 } 1439 }
1432# endif 1440# endif
1433 1441
1434# ifdef BG_IMAGE_FROM_FILE 1442# ifdef BG_IMAGE_FROM_FILE
1447 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1455 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1448 } 1456 }
1449 1457
1450 if (result) 1458 if (result)
1451 { 1459 {
1452# if !defined(HAVE_AFTERIMAGE) && !XFT 1460# if !defined(HAVE_AFTERIMAGE) && !XRENDER
1453 /* our own client-side tinting */ 1461 /* our own client-side tinting */
1454 /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side.
1455 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1456 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1462 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1457 { 1463 {
1458 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1464 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1459 if (flags & tintSet) 1465 if (flags & tintSet)
1460 tint.get (c); 1466 tint.get (c);
1464 1470
1465 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1471 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1466 1472
1467 if (gc) 1473 if (gc)
1468 { 1474 {
1469 if (/*pmap_depth != target->depth &&*/ pixmap != None)
1470 {
1471 XFreePixmap (target->dpy, pixmap);
1472 pixmap = None;
1473 }
1474
1475 if (pixmap == None)
1476 {
1477 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth);
1478 pmap_width = result->width;
1479 pmap_height = result->height;
1480 pmap_depth = target->depth;
1481 }
1482
1483 if (pmap_depth != result->depth)
1484 {
1485 /* Bad Match error will ensue ! stupid X !!!! */
1486 if (result->depth == 24 && pmap_depth == 32)
1487 result->depth = 32;
1488 else if (result->depth == 32 && pmap_depth == 24)
1489 result->depth = 24;
1490 else
1491 {
1492 /* TODO: implement image recoding */
1493 }
1494 }
1495
1496 if (pmap_depth == result->depth)
1497 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1475 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1498 1476
1499 XFreeGC (target->dpy, gc); 1477 XFreeGC (target->dpy, gc);
1500 flags = flags & ~isInvalid; 1478 flags = flags & ~isInvalid;
1501 } 1479 }
1502 1480
1517 valid_since = ev::now (); 1495 valid_since = ev::now ();
1518 1496
1519 return true; 1497 return true;
1520} 1498}
1521 1499
1522bool 1500void
1523bgPixmap_t::set_target (rxvt_term *new_target) 1501bgPixmap_t::set_target (rxvt_term *new_target)
1524{ 1502{
1525 if (new_target)
1526 if (target != new_target)
1527 {
1528 target = new_target; 1503 target = new_target;
1529# ifdef ENABLE_TRANSPARENCY 1504
1530 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); 1505 flags &= ~(HAS_RENDER | HAS_RENDER_CONV);
1506#if XRENDER
1507 int major, minor;
1508 if (XRenderQueryVersion (target->dpy, &major, &minor))
1509 flags |= HAS_RENDER;
1510 XFilters *filters = XRenderQueryFilters (target->dpy, target->vt);
1511 if (filters)
1512 {
1513 for (int i = 0; i < filters->nfilter; i++)
1514 if (!strcmp (filters->filter[i], FilterConvolution))
1515 flags |= HAS_RENDER_CONV;
1516
1517 XFree (filters);
1518 }
1531# endif 1519#endif
1532 return true;
1533 }
1534
1535 return false;
1536} 1520}
1537 1521
1538void 1522void
1539bgPixmap_t::apply () 1523bgPixmap_t::apply ()
1540{ 1524{
1541 if (target) 1525 if (target == NULL)
1542 { 1526 return;
1543 flags &= ~isVtOrigin;
1544 1527
1545 if (pixmap != None) 1528 if (pixmap != None)
1546 { 1529 {
1547 /* set target's background to pixmap */ 1530 /* set target's background to pixmap */
1548# ifdef ENABLE_TRANSPARENCY 1531# ifdef ENABLE_TRANSPARENCY
1549 if (flags & isTransparent) 1532 if (flags & isTransparent)
1550 { 1533 {
1551 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); 1534 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap);
1552 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); 1535 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative);
1553 1536
1554 if (target->scrollBar.win) 1537 if (target->scrollBar.win)
1555 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); 1538 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative);
1556 } 1539 }
1557 else 1540 else
1558# endif 1541# endif
1559 { 1542 {
1560 flags |= isVtOrigin;
1561 /* force old pixmap dereference in case it was transparent before :*/ 1543 /* force old pixmap dereference in case it was transparent before :*/
1562 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1563 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap);
1564 /* do we also need to set scrollbar's background here ? */
1565
1566 if (target->scrollBar.win)
1567 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1568 }
1569 }
1570 else
1571 {
1572 /* set target background to a pixel */
1573 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1544 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1574 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); 1545 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap);
1575 /* do we also need to set scrollbar's background here ? */ 1546 /* do we also need to set scrollbar's background here ? */
1547
1576 if (target->scrollBar.win) 1548 if (target->scrollBar.win)
1577 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1549 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1578 } 1550 }
1551 }
1552 else
1553 {
1554 /* set target background to a pixel */
1555 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1556 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]);
1557 /* do we also need to set scrollbar's background here ? */
1558 if (target->scrollBar.win)
1559 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1560 }
1579 1561
1580 /* don't want Expose on the parent or vt. It is better to use 1562 /* don't want Expose on the parent or vt. It is better to use
1581 scr_touch or we get a great deal of flicker otherwise: */ 1563 scr_touch or we get a great deal of flicker otherwise: */
1582 XClearWindow (target->dpy, target->parent[0]); 1564 XClearWindow (target->dpy, target->parent[0]);
1583 1565
1584 if (target->scrollBar.state && target->scrollBar.win) 1566 if (target->scrollBar.state && target->scrollBar.win)
1585 { 1567 {
1586 target->scrollBar.state = STATE_IDLE; 1568 target->scrollBar.state = STATE_IDLE;
1587 target->scrollBar.show (0); 1569 target->scrollBar.show (0);
1588 } 1570 }
1589 1571
1590 target->want_refresh = 1; 1572 target->want_refresh = 1;
1591 flags |= hasChanged; 1573 flags |= hasChanged;
1592 }
1593} 1574}
1594 1575
1595#endif /* HAVE_BG_PIXMAP */ 1576#endif /* HAVE_BG_PIXMAP */
1596 1577
1597#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT 1578#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER
1598/* taken from aterm-0.4.2 */ 1579/* taken from aterm-0.4.2 */
1599 1580
1600static void 1581static void
1601ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1582ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm)
1602{ 1583{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines