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.101 by sf-exg, Sun Oct 31 08:28:04 2010 UTC vs.
Revision 1.102 by sf-exg, Sun Oct 31 09:34:23 2010 UTC

108 h_scale = v_scale = 0; 108 h_scale = v_scale = 0;
109 h_align = v_align = 0; 109 h_align = v_align = 0;
110#endif 110#endif
111#ifdef ENABLE_TRANSPARENCY 111#ifdef ENABLE_TRANSPARENCY
112 shade = 100; 112 shade = 100;
113 recoded_root_pmap = None;
113#endif 114#endif
114 flags = 0; 115 flags = 0;
115 pixmap = None; 116 pixmap = None;
116 valid_since = invalid_since = 0; 117 valid_since = invalid_since = 0;
117 target = 0; 118 target = 0;
126#endif 127#endif
127 128
128#ifdef HAVE_PIXBUF 129#ifdef HAVE_PIXBUF
129 if (pixbuf) 130 if (pixbuf)
130 g_object_unref (pixbuf); 131 g_object_unref (pixbuf);
132#endif
133
134#ifdef ENABLE_TRANSPARENCY
135 if (recoded_root_pmap && target)
136 XFreePixmap (target->dpy, recoded_root_pmap);
131#endif 137#endif
132 138
133 if (pixmap && target) 139 if (pixmap && target)
134 XFreePixmap (target->dpy, pixmap); 140 XFreePixmap (target->dpy, pixmap);
135} 141}
862 if (background_flags) 868 if (background_flags)
863 { 869 {
864 Display *dpy = target->dpy; 870 Display *dpy = target->dpy;
865 XRenderPictureAttributes pa; 871 XRenderPictureAttributes pa;
866 872
867 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, target->display->screen)); 873 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, target->visual);
868 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 874 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
869 875
870 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); 876 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual);
871 Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); 877 Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa);
872 878
1001 flags &= ~blurNeeded; 1007 flags &= ~blurNeeded;
1002 else 1008 else
1003 flags |= blurNeeded; 1009 flags |= blurNeeded;
1004 1010
1005#if XRENDER 1011#if XRENDER
1006 XFilters *filters = XRenderQueryFilters (target->dpy, target->display->root); 1012 XFilters *filters = XRenderQueryFilters (target->dpy, target->vt);
1007 if (filters) 1013 if (filters)
1008 { 1014 {
1009 for (int i = 0; i < filters->nfilter; i++) 1015 for (int i = 0; i < filters->nfilter; i++)
1010 if (!strcmp (filters->filter[i], FilterConvolution)) 1016 if (!strcmp (filters->filter[i], FilterConvolution))
1011 flags |= bgPixmap_t::blurServerSide; 1017 flags |= bgPixmap_t::blurServerSide;
1299 return 0; 1305 return 0;
1300 1306
1301 /* root dimensions may change from call to call - but Display structure should 1307 /* root dimensions may change from call to call - but Display structure should
1302 * be always up-to-date, so let's use it : 1308 * be always up-to-date, so let's use it :
1303 */ 1309 */
1304 Window root = target->display->root;
1305 int screen = target->display->screen; 1310 int screen = target->display->screen;
1306 Display *dpy = target->dpy; 1311 Display *dpy = target->dpy;
1307 int root_width = DisplayWidth (dpy, screen); 1312 int root_width = DisplayWidth (dpy, screen);
1308 int root_height = DisplayHeight (dpy, screen); 1313 int root_height = DisplayHeight (dpy, screen);
1309 int window_width = target->szHint.width; 1314 int window_width = target->szHint.width;
1320 return 0; 1325 return 0;
1321 1326
1322 if (root_pixmap == None) 1327 if (root_pixmap == None)
1323 return 0; 1328 return 0;
1324 1329
1325 Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); 1330 Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth);
1326 1331
1327 if (tiled_root_pmap == None) /* something really bad happened - abort */ 1332 if (tiled_root_pmap == None) /* something really bad happened - abort */
1328 return 0; 1333 return 0;
1329 1334
1330 /* straightforward pixmap copy */ 1335 /* straightforward pixmap copy */
1334 while (sx < 0) sx += (int)root_width; 1339 while (sx < 0) sx += (int)root_width;
1335 while (sy < 0) sy += (int)root_height; 1340 while (sy < 0) sy += (int)root_height;
1336 1341
1337 gcv.ts_x_origin = -sx; 1342 gcv.ts_x_origin = -sx;
1338 gcv.ts_y_origin = -sy; 1343 gcv.ts_y_origin = -sy;
1339 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1344 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1340 1345
1341 if (gc) 1346 if (gc)
1342 { 1347 {
1343 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1348 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1344 result |= transpPmapTiled; 1349 result |= transpPmapTiled;
1349 { 1354 {
1350 if (!need_client_side_rendering ()) 1355 if (!need_client_side_rendering ())
1351 { 1356 {
1352 if (flags & (blurNeeded | blurServerSide)) 1357 if (flags & (blurNeeded | blurServerSide))
1353 { 1358 {
1354 if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) 1359 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1355 result |= transpPmapBlurred; 1360 result |= transpPmapBlurred;
1356 } 1361 }
1357 if (flags & (tintNeeded | tintServerSide)) 1362 if (flags & (tintNeeded | tintServerSide))
1358 { 1363 {
1359 if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, screen), window_width, window_height)) 1364 if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1360 result |= transpPmapTinted; 1365 result |= transpPmapTinted;
1361 } 1366 }
1362 } /* server side rendering completed */ 1367 } /* server side rendering completed */
1363 1368
1364 if (pixmap) 1369 if (pixmap)
1365 XFreePixmap (dpy, pixmap); 1370 XFreePixmap (dpy, pixmap);
1366 1371
1367 pixmap = tiled_root_pmap; 1372 pixmap = tiled_root_pmap;
1368 pmap_width = window_width; 1373 pmap_width = window_width;
1369 pmap_height = window_height; 1374 pmap_height = window_height;
1370 pmap_depth = root_depth; 1375 pmap_depth = target->depth;
1371 } 1376 }
1372 1377
1373 return result; 1378 return result;
1374} 1379}
1375 1380
1380 if (new_root_pixmap == None) 1385 if (new_root_pixmap == None)
1381 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1386 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1382 1387
1383 root_pixmap = new_root_pixmap; 1388 root_pixmap = new_root_pixmap;
1384 1389
1390 unsigned int width, height;
1391 int depth = DefaultDepth (target->dpy, target->display->screen);
1392
1385 // validate root pixmap 1393 // validate root pixmap
1386 if (root_pixmap != None) 1394 if (root_pixmap != None)
1387 { 1395 {
1388 unsigned int width, height;
1389 Window wdummy; 1396 Window wdummy;
1390 int idummy; 1397 int idummy;
1391 unsigned int udummy; 1398 unsigned int udummy;
1392 1399
1393 target->allowedxerror = -1; 1400 target->allowedxerror = -1;
1394 1401
1395 if (!XGetGeometry (target->dpy, root_pixmap, &wdummy, &idummy, &idummy, &width, &height, &udummy, &udummy)) 1402 if (!XGetGeometry (target->dpy, root_pixmap, &wdummy, &idummy, &idummy, &width, &height, &udummy, &udummy))
1396 root_pixmap = None; 1403 root_pixmap = None;
1397 1404
1398 target->allowedxerror = 0; 1405 target->allowedxerror = 0;
1406 }
1407
1408 if (root_pixmap != None && depth != target->depth)
1409 {
1410#if XRENDER
1411 Display *dpy = target->dpy;
1412 XRenderPictureAttributes pa;
1413
1414 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, target->display->screen));
1415 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1416
1417 if (recoded_root_pmap)
1418 XFreePixmap (dpy, recoded_root_pmap);
1419 recoded_root_pmap = XCreatePixmap (dpy, target->vt, width, height, target->depth);
1420 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual);
1421 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1422
1423 if (src && dst)
1424 {
1425 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, width, height);
1426 root_pixmap = recoded_root_pmap;
1427 }
1428 else
1429 root_pixmap = None;
1430
1431 XRenderFreePicture (dpy, src);
1432 XRenderFreePicture (dpy, dst);
1433#else
1434 root_pixmap = None;
1435#endif
1399 } 1436 }
1400} 1437}
1401# endif /* ENABLE_TRANSPARENCY */ 1438# endif /* ENABLE_TRANSPARENCY */
1402 1439
1403# ifndef HAVE_AFTERIMAGE 1440# ifndef HAVE_AFTERIMAGE
1418 { 1455 {
1419 /* we need to re-generate transparency pixmap in that case ! */ 1456 /* we need to re-generate transparency pixmap in that case ! */
1420 background_flags = make_transparency_pixmap (); 1457 background_flags = make_transparency_pixmap ();
1421 if (background_flags == 0) 1458 if (background_flags == 0)
1422 return false; 1459 return false;
1423 else if ((background_flags & transpTransformations) == (flags & transpTransformations) 1460 else if ((background_flags & transpTransformations) == (flags & transpTransformations))
1424 && pmap_depth == target->depth)
1425 flags = flags & ~isInvalid; 1461 flags = flags & ~isInvalid;
1426 } 1462 }
1427# endif 1463# endif
1428 1464
1429# ifdef BG_IMAGE_FROM_FILE 1465# ifdef BG_IMAGE_FROM_FILE
1457 1493
1458 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1494 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1459 1495
1460 if (gc) 1496 if (gc)
1461 { 1497 {
1462 if (/*pmap_depth != target->depth &&*/ pixmap != None)
1463 {
1464 XFreePixmap (target->dpy, pixmap);
1465 pixmap = None;
1466 }
1467
1468 if (pixmap == None)
1469 {
1470 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth);
1471 pmap_width = result->width;
1472 pmap_height = result->height;
1473 pmap_depth = target->depth;
1474 }
1475
1476 if (pmap_depth != result->depth)
1477 {
1478 /* Bad Match error will ensue ! stupid X !!!! */
1479 if (result->depth == 24 && pmap_depth == 32)
1480 result->depth = 32;
1481 else if (result->depth == 32 && pmap_depth == 24)
1482 result->depth = 24;
1483 else
1484 {
1485 /* TODO: implement image recoding */
1486 }
1487 }
1488
1489 if (pmap_depth == result->depth)
1490 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1498 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1491 1499
1492 XFreeGC (target->dpy, gc); 1500 XFreeGC (target->dpy, gc);
1493 flags = flags & ~isInvalid; 1501 flags = flags & ~isInvalid;
1494 } 1502 }
1495 1503
1517{ 1525{
1518 if (new_target) 1526 if (new_target)
1519 if (target != new_target) 1527 if (target != new_target)
1520 { 1528 {
1521 target = new_target; 1529 target = new_target;
1522# ifdef ENABLE_TRANSPARENCY
1523 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen));
1524# endif
1525 return true; 1530 return true;
1526 } 1531 }
1527 1532
1528 return false; 1533 return false;
1529} 1534}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines