… | |
… | |
729 | return false; |
729 | return false; |
730 | |
730 | |
731 | if (!pixbuf) |
731 | if (!pixbuf) |
732 | return false; |
732 | return false; |
733 | |
733 | |
734 | #if !XFT |
734 | #if !XRENDER |
735 | if (background_flags) |
735 | if (background_flags) |
736 | return false; |
736 | return false; |
737 | #endif |
737 | #endif |
738 | |
738 | |
739 | GdkPixbuf *result; |
739 | GdkPixbuf *result; |
… | |
… | |
856 | dst_width, dst_height, |
856 | dst_width, dst_height, |
857 | XLIB_RGB_DITHER_NONE, |
857 | XLIB_RGB_DITHER_NONE, |
858 | 0, 0); |
858 | 0, 0); |
859 | } |
859 | } |
860 | |
860 | |
861 | #if XFT |
861 | #if XRENDER |
862 | if (background_flags) |
862 | if (background_flags) |
863 | { |
863 | { |
864 | Display *dpy = target->dpy; |
864 | Display *dpy = target->dpy; |
865 | XRenderPictureAttributes pa; |
865 | XRenderPictureAttributes pa; |
866 | |
866 | |
867 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, target->display->screen)); |
867 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, target->visual); |
868 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
868 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
869 | |
869 | |
870 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); |
870 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); |
871 | Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); |
871 | Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); |
872 | |
872 | |
… | |
… | |
1000 | if (v_blurRadius == 0 && h_blurRadius == 0) |
1000 | if (v_blurRadius == 0 && h_blurRadius == 0) |
1001 | flags &= ~blurNeeded; |
1001 | flags &= ~blurNeeded; |
1002 | else |
1002 | else |
1003 | flags |= blurNeeded; |
1003 | flags |= blurNeeded; |
1004 | |
1004 | |
1005 | #if XFT |
1005 | #if XRENDER |
1006 | XFilters *filters = XRenderQueryFilters (target->dpy, target->display->root); |
1006 | XFilters *filters = XRenderQueryFilters (target->dpy, target->vt); |
1007 | if (filters) |
1007 | if (filters) |
1008 | { |
1008 | { |
1009 | for (int i = 0; i < filters->nfilter; i++) |
1009 | for (int i = 0; i < filters->nfilter; i++) |
1010 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1010 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1011 | flags |= bgPixmap_t::blurServerSide; |
1011 | flags |= bgPixmap_t::blurServerSide; |
… | |
… | |
1050 | { |
1050 | { |
1051 | if (flags & bgPixmap_t::tintWholesome) |
1051 | if (flags & bgPixmap_t::tintWholesome) |
1052 | flags |= bgPixmap_t::tintServerSide; |
1052 | flags |= bgPixmap_t::tintServerSide; |
1053 | else |
1053 | else |
1054 | { |
1054 | { |
1055 | #if XFT |
1055 | #if XRENDER |
1056 | flags |= bgPixmap_t::tintServerSide; |
1056 | flags |= bgPixmap_t::tintServerSide; |
1057 | #endif |
1057 | #endif |
1058 | } |
1058 | } |
1059 | } |
1059 | } |
1060 | |
1060 | |
… | |
… | |
1107 | } |
1107 | } |
1108 | |
1108 | |
1109 | return false; |
1109 | return false; |
1110 | } |
1110 | } |
1111 | |
1111 | |
1112 | #if XFT |
1112 | #if XRENDER |
1113 | static void |
1113 | static void |
1114 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
1114 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
1115 | { |
1115 | { |
1116 | double sigma = radius / 2.0; |
1116 | double sigma = radius / 2.0; |
1117 | double scale = sqrt (2.0 * M_PI) * sigma; |
1117 | double scale = sqrt (2.0 * M_PI) * sigma; |
… | |
… | |
1134 | |
1134 | |
1135 | bool |
1135 | bool |
1136 | bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1136 | bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1137 | { |
1137 | { |
1138 | bool ret = false; |
1138 | bool ret = false; |
1139 | #if XFT |
1139 | #if XRENDER |
1140 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1140 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1141 | double *kernel = (double *)malloc (size * sizeof (double)); |
1141 | double *kernel = (double *)malloc (size * sizeof (double)); |
1142 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1142 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1143 | |
1143 | |
1144 | Display *dpy = target->dpy; |
1144 | Display *dpy = target->dpy; |
… | |
… | |
1221 | XFreeGC (dpy, gc); |
1221 | XFreeGC (dpy, gc); |
1222 | } |
1222 | } |
1223 | } |
1223 | } |
1224 | else |
1224 | else |
1225 | { |
1225 | { |
1226 | # if XFT |
1226 | # if XRENDER |
1227 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1227 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1228 | |
1228 | |
1229 | if (flags & tintSet) |
1229 | if (flags & tintSet) |
1230 | tint.get (c); |
1230 | tint.get (c); |
1231 | |
1231 | |
… | |
… | |
1284 | |
1284 | |
1285 | return ret; |
1285 | return ret; |
1286 | } |
1286 | } |
1287 | |
1287 | |
1288 | /* make_transparency_pixmap() |
1288 | /* make_transparency_pixmap() |
1289 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
1289 | * 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 |
1290 | * the tiled portion of the root pixmap that is supposed to be covered by |
1291 | * our window. |
1291 | * our window. |
1292 | */ |
1292 | */ |
1293 | unsigned long |
1293 | unsigned long |
1294 | bgPixmap_t::make_transparency_pixmap () |
1294 | bgPixmap_t::make_transparency_pixmap () |
1295 | { |
1295 | { |
… | |
… | |
1299 | return 0; |
1299 | return 0; |
1300 | |
1300 | |
1301 | /* root dimensions may change from call to call - but Display structure should |
1301 | /* root dimensions may change from call to call - but Display structure should |
1302 | * be always up-to-date, so let's use it : |
1302 | * be always up-to-date, so let's use it : |
1303 | */ |
1303 | */ |
1304 | Window root = target->display->root; |
|
|
1305 | int screen = target->display->screen; |
1304 | int screen = target->display->screen; |
1306 | Display *dpy = target->dpy; |
1305 | Display *dpy = target->dpy; |
|
|
1306 | int root_depth = DefaultDepth (dpy, screen); |
1307 | int root_width = DisplayWidth (dpy, screen); |
1307 | int root_width = DisplayWidth (dpy, screen); |
1308 | int root_height = DisplayHeight (dpy, screen); |
1308 | int root_height = DisplayHeight (dpy, screen); |
1309 | unsigned int root_pmap_width, root_pmap_height; |
1309 | unsigned int root_pmap_width, root_pmap_height; |
1310 | int window_width = target->szHint.width; |
1310 | int window_width = target->szHint.width; |
1311 | int window_height = target->szHint.height; |
1311 | int window_height = target->szHint.height; |
… | |
… | |
1318 | /* check if we are outside of the visible part of the virtual screen : */ |
1318 | /* check if we are outside of the visible part of the virtual screen : */ |
1319 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1319 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1320 | || sx >= root_width || sy >= root_height) |
1320 | || sx >= root_width || sy >= root_height) |
1321 | return 0; |
1321 | return 0; |
1322 | |
1322 | |
|
|
1323 | // validate root pixmap and get its size |
1323 | if (root_pixmap != None) |
1324 | if (root_pixmap != None) |
1324 | { |
1325 | { |
1325 | /* we want to validate the pixmap and get its size at the same time : */ |
1326 | Window wdummy; |
1326 | int junk; |
1327 | int idummy; |
1327 | unsigned int ujunk; |
1328 | unsigned int udummy; |
1328 | /* root pixmap may be bad - allow a error */ |
1329 | |
1329 | target->allowedxerror = -1; |
1330 | target->allowedxerror = -1; |
1330 | |
1331 | |
1331 | if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) |
1332 | if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy)) |
1332 | root_pixmap = None; |
1333 | root_pixmap = None; |
1333 | |
1334 | |
1334 | target->allowedxerror = 0; |
1335 | target->allowedxerror = 0; |
|
|
1336 | } |
|
|
1337 | |
|
|
1338 | Pixmap recoded_root_pmap = root_pixmap; |
|
|
1339 | |
|
|
1340 | if (root_pixmap != None && root_depth != target->depth) |
|
|
1341 | { |
|
|
1342 | #if XRENDER |
|
|
1343 | XRenderPictureAttributes pa; |
|
|
1344 | |
|
|
1345 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
|
|
1346 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
|
|
1347 | |
|
|
1348 | recoded_root_pmap = XCreatePixmap (dpy, target->vt, root_pmap_width, root_pmap_height, target->depth); |
|
|
1349 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); |
|
|
1350 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
|
|
1351 | |
|
|
1352 | if (src && dst) |
|
|
1353 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
|
|
1354 | else |
|
|
1355 | { |
|
|
1356 | XFreePixmap (dpy, recoded_root_pmap); |
|
|
1357 | root_pixmap = None; |
|
|
1358 | } |
|
|
1359 | |
|
|
1360 | XRenderFreePicture (dpy, src); |
|
|
1361 | XRenderFreePicture (dpy, dst); |
|
|
1362 | #else |
|
|
1363 | root_pixmap = None; |
|
|
1364 | #endif |
1335 | } |
1365 | } |
1336 | |
1366 | |
1337 | if (root_pixmap == None) |
1367 | if (root_pixmap == None) |
1338 | return 0; |
1368 | return 0; |
1339 | |
1369 | |
1340 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
1370 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth); |
1341 | |
1371 | |
1342 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1372 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1343 | return 0; |
1373 | return 0; |
1344 | |
1374 | |
1345 | /* straightforward pixmap copy */ |
1375 | /* straightforward pixmap copy */ |
1346 | gcv.tile = root_pixmap; |
1376 | gcv.tile = recoded_root_pmap; |
1347 | gcv.fill_style = FillTiled; |
1377 | gcv.fill_style = FillTiled; |
1348 | |
1378 | |
1349 | while (sx < 0) sx += (int)root_width; |
1379 | while (sx < 0) sx += (int)root_width; |
1350 | while (sy < 0) sy += (int)root_height; |
1380 | while (sy < 0) sy += (int)root_height; |
1351 | |
1381 | |
1352 | gcv.ts_x_origin = -sx; |
1382 | gcv.ts_x_origin = -sx; |
1353 | gcv.ts_y_origin = -sy; |
1383 | gcv.ts_y_origin = -sy; |
1354 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1384 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1355 | |
1385 | |
1356 | if (gc) |
1386 | if (gc) |
1357 | { |
1387 | { |
1358 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1388 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1359 | result |= transpPmapTiled; |
1389 | result |= transpPmapTiled; |
… | |
… | |
1362 | |
1392 | |
1363 | if (tiled_root_pmap != None) |
1393 | if (tiled_root_pmap != None) |
1364 | { |
1394 | { |
1365 | if (!need_client_side_rendering ()) |
1395 | if (!need_client_side_rendering ()) |
1366 | { |
1396 | { |
1367 | if (flags & (blurNeeded | blurServerSide)) |
1397 | if ((flags & blurNeeded) |
|
|
1398 | && (flags & blurServerSide)) |
1368 | { |
1399 | { |
1369 | if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) |
1400 | if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height)) |
1370 | result |= transpPmapBlurred; |
1401 | result |= transpPmapBlurred; |
1371 | } |
1402 | } |
1372 | if (flags & (tintNeeded | tintServerSide)) |
1403 | if ((flags & tintNeeded) |
|
|
1404 | && (flags & tintServerSide)) |
1373 | { |
1405 | { |
1374 | if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) |
1406 | if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height)) |
1375 | result |= transpPmapTinted; |
1407 | result |= transpPmapTinted; |
1376 | } |
1408 | } |
1377 | } /* server side rendering completed */ |
1409 | } /* server side rendering completed */ |
1378 | |
1410 | |
1379 | if (pixmap) |
1411 | if (pixmap) |
1380 | XFreePixmap (dpy, pixmap); |
1412 | XFreePixmap (dpy, pixmap); |
1381 | |
1413 | |
1382 | pixmap = tiled_root_pmap; |
1414 | pixmap = tiled_root_pmap; |
1383 | pmap_width = window_width; |
1415 | pmap_width = window_width; |
1384 | pmap_height = window_height; |
1416 | pmap_height = window_height; |
1385 | pmap_depth = root_depth; |
1417 | pmap_depth = target->depth; |
1386 | } |
1418 | } |
|
|
1419 | |
|
|
1420 | if (recoded_root_pmap != root_pixmap) |
|
|
1421 | XFreePixmap (dpy, recoded_root_pmap); |
1387 | |
1422 | |
1388 | return result; |
1423 | return result; |
1389 | } |
1424 | } |
1390 | |
1425 | |
1391 | void |
1426 | void |
… | |
… | |
1417 | { |
1452 | { |
1418 | /* we need to re-generate transparency pixmap in that case ! */ |
1453 | /* we need to re-generate transparency pixmap in that case ! */ |
1419 | background_flags = make_transparency_pixmap (); |
1454 | background_flags = make_transparency_pixmap (); |
1420 | if (background_flags == 0) |
1455 | if (background_flags == 0) |
1421 | return false; |
1456 | return false; |
1422 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1457 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1423 | && pmap_depth == target->depth) |
|
|
1424 | flags = flags & ~isInvalid; |
1458 | flags = flags & ~isInvalid; |
1425 | } |
1459 | } |
1426 | # endif |
1460 | # endif |
1427 | |
1461 | |
1428 | # ifdef BG_IMAGE_FROM_FILE |
1462 | # ifdef BG_IMAGE_FROM_FILE |
… | |
… | |
1441 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1475 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1442 | } |
1476 | } |
1443 | |
1477 | |
1444 | if (result) |
1478 | if (result) |
1445 | { |
1479 | { |
1446 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
1480 | # if !defined(HAVE_AFTERIMAGE) && !XRENDER |
1447 | /* our own client-side tinting */ |
1481 | /* our own client-side tinting */ |
1448 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1449 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1450 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1482 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1451 | { |
1483 | { |
1452 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1484 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1453 | if (flags & tintSet) |
1485 | if (flags & tintSet) |
1454 | tint.get (c); |
1486 | tint.get (c); |
… | |
… | |
1458 | |
1490 | |
1459 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1491 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1460 | |
1492 | |
1461 | if (gc) |
1493 | if (gc) |
1462 | { |
1494 | { |
1463 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
|
|
1464 | { |
|
|
1465 | XFreePixmap (target->dpy, pixmap); |
|
|
1466 | pixmap = None; |
|
|
1467 | } |
|
|
1468 | |
|
|
1469 | if (pixmap == None) |
|
|
1470 | { |
|
|
1471 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
|
|
1472 | pmap_width = result->width; |
|
|
1473 | pmap_height = result->height; |
|
|
1474 | pmap_depth = target->depth; |
|
|
1475 | } |
|
|
1476 | |
|
|
1477 | if (pmap_depth != result->depth) |
|
|
1478 | { |
|
|
1479 | /* Bad Match error will ensue ! stupid X !!!! */ |
|
|
1480 | if (result->depth == 24 && pmap_depth == 32) |
|
|
1481 | result->depth = 32; |
|
|
1482 | else if (result->depth == 32 && pmap_depth == 24) |
|
|
1483 | result->depth = 24; |
|
|
1484 | else |
|
|
1485 | { |
|
|
1486 | /* TODO: implement image recoding */ |
|
|
1487 | } |
|
|
1488 | } |
|
|
1489 | |
|
|
1490 | if (pmap_depth == result->depth) |
|
|
1491 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1495 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1492 | |
1496 | |
1493 | XFreeGC (target->dpy, gc); |
1497 | XFreeGC (target->dpy, gc); |
1494 | flags = flags & ~isInvalid; |
1498 | flags = flags & ~isInvalid; |
1495 | } |
1499 | } |
1496 | |
1500 | |
… | |
… | |
1518 | { |
1522 | { |
1519 | if (new_target) |
1523 | if (new_target) |
1520 | if (target != new_target) |
1524 | if (target != new_target) |
1521 | { |
1525 | { |
1522 | target = new_target; |
1526 | target = new_target; |
1523 | # ifdef ENABLE_TRANSPARENCY |
|
|
1524 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
|
|
1525 | # endif |
|
|
1526 | return true; |
1527 | return true; |
1527 | } |
1528 | } |
1528 | |
1529 | |
1529 | return false; |
1530 | return false; |
1530 | } |
1531 | } |
… | |
… | |
1583 | } |
1584 | } |
1584 | } |
1585 | } |
1585 | |
1586 | |
1586 | #endif /* HAVE_BG_PIXMAP */ |
1587 | #endif /* HAVE_BG_PIXMAP */ |
1587 | |
1588 | |
1588 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1589 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER |
1589 | /* taken from aterm-0.4.2 */ |
1590 | /* taken from aterm-0.4.2 */ |
1590 | |
1591 | |
1591 | static void |
1592 | static void |
1592 | ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) |
1593 | ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) |
1593 | { |
1594 | { |