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.102 by sf-exg, Sun Oct 31 09:34:23 2010 UTC vs.
Revision 1.103 by sf-exg, Sun Oct 31 11:15:29 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;
114#endif 113#endif
115 flags = 0; 114 flags = 0;
116 pixmap = None; 115 pixmap = None;
117 valid_since = invalid_since = 0; 116 valid_since = invalid_since = 0;
118 target = 0; 117 target = 0;
127#endif 126#endif
128 127
129#ifdef HAVE_PIXBUF 128#ifdef HAVE_PIXBUF
130 if (pixbuf) 129 if (pixbuf)
131 g_object_unref (pixbuf); 130 g_object_unref (pixbuf);
132#endif
133
134#ifdef ENABLE_TRANSPARENCY
135 if (recoded_root_pmap && target)
136 XFreePixmap (target->dpy, recoded_root_pmap);
137#endif 131#endif
138 132
139 if (pixmap && target) 133 if (pixmap && target)
140 XFreePixmap (target->dpy, pixmap); 134 XFreePixmap (target->dpy, pixmap);
141} 135}
1307 /* 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
1308 * be always up-to-date, so let's use it : 1302 * be always up-to-date, so let's use it :
1309 */ 1303 */
1310 int screen = target->display->screen; 1304 int screen = target->display->screen;
1311 Display *dpy = target->dpy; 1305 Display *dpy = target->dpy;
1306 int root_depth = DefaultDepth (dpy, screen);
1312 int root_width = DisplayWidth (dpy, screen); 1307 int root_width = DisplayWidth (dpy, screen);
1313 int root_height = DisplayHeight (dpy, screen); 1308 int root_height = DisplayHeight (dpy, screen);
1309 unsigned int root_pmap_width, root_pmap_height;
1314 int window_width = target->szHint.width; 1310 int window_width = target->szHint.width;
1315 int window_height = target->szHint.height; 1311 int window_height = target->szHint.height;
1316 int sx, sy; 1312 int sx, sy;
1317 XGCValues gcv; 1313 XGCValues gcv;
1318 GC gc; 1314 GC gc;
1322 /* 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 : */
1323 if (sx + window_width <= 0 || sy + window_height <= 0 1319 if (sx + window_width <= 0 || sy + window_height <= 0
1324 || sx >= root_width || sy >= root_height) 1320 || sx >= root_width || sy >= root_height)
1325 return 0; 1321 return 0;
1326 1322
1327 if (root_pixmap == None) 1323 // validate root pixmap and get its size
1328 return 0;
1329
1330 Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth);
1331
1332 if (tiled_root_pmap == None) /* something really bad happened - abort */
1333 return 0;
1334
1335 /* straightforward pixmap copy */
1336 gcv.tile = root_pixmap;
1337 gcv.fill_style = FillTiled;
1338
1339 while (sx < 0) sx += (int)root_width;
1340 while (sy < 0) sy += (int)root_height;
1341
1342 gcv.ts_x_origin = -sx;
1343 gcv.ts_y_origin = -sy;
1344 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1345
1346 if (gc)
1347 {
1348 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1349 result |= transpPmapTiled;
1350 XFreeGC (dpy, gc);
1351 }
1352
1353 if (tiled_root_pmap != None)
1354 {
1355 if (!need_client_side_rendering ())
1356 {
1357 if (flags & (blurNeeded | blurServerSide))
1358 {
1359 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1360 result |= transpPmapBlurred;
1361 }
1362 if (flags & (tintNeeded | tintServerSide))
1363 {
1364 if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1365 result |= transpPmapTinted;
1366 }
1367 } /* server side rendering completed */
1368
1369 if (pixmap)
1370 XFreePixmap (dpy, pixmap);
1371
1372 pixmap = tiled_root_pmap;
1373 pmap_width = window_width;
1374 pmap_height = window_height;
1375 pmap_depth = target->depth;
1376 }
1377
1378 return result;
1379}
1380
1381void
1382bgPixmap_t::set_root_pixmap ()
1383{
1384 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1385 if (new_root_pixmap == None)
1386 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1387
1388 root_pixmap = new_root_pixmap;
1389
1390 unsigned int width, height;
1391 int depth = DefaultDepth (target->dpy, target->display->screen);
1392
1393 // validate root pixmap
1394 if (root_pixmap != None) 1324 if (root_pixmap != None)
1395 { 1325 {
1396 Window wdummy; 1326 Window wdummy;
1397 int idummy; 1327 int idummy;
1398 unsigned int udummy; 1328 unsigned int udummy;
1399 1329
1400 target->allowedxerror = -1; 1330 target->allowedxerror = -1;
1401 1331
1402 if (!XGetGeometry (target->dpy, root_pixmap, &wdummy, &idummy, &idummy, &width, &height, &udummy, &udummy)) 1332 if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy))
1403 root_pixmap = None; 1333 root_pixmap = None;
1404 1334
1405 target->allowedxerror = 0; 1335 target->allowedxerror = 0;
1406 } 1336 }
1407 1337
1338 Pixmap recoded_root_pmap = root_pixmap;
1339
1408 if (root_pixmap != None && depth != target->depth) 1340 if (root_pixmap != None && root_depth != target->depth)
1409 { 1341 {
1410#if XRENDER 1342#if XRENDER
1411 Display *dpy = target->dpy;
1412 XRenderPictureAttributes pa; 1343 XRenderPictureAttributes pa;
1413 1344
1414 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, target->display->screen)); 1345 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1415 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1346 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1416 1347
1417 if (recoded_root_pmap)
1418 XFreePixmap (dpy, recoded_root_pmap);
1419 recoded_root_pmap = XCreatePixmap (dpy, target->vt, width, height, target->depth); 1348 recoded_root_pmap = XCreatePixmap (dpy, target->vt, root_pmap_width, root_pmap_height, target->depth);
1420 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); 1349 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual);
1421 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1350 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1422 1351
1423 if (src && dst) 1352 if (src && dst)
1424 {
1425 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, width, height); 1353 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1426 root_pixmap = recoded_root_pmap;
1427 }
1428 else 1354 else
1429 root_pixmap = None; 1355 root_pixmap = None;
1430 1356
1431 XRenderFreePicture (dpy, src); 1357 XRenderFreePicture (dpy, src);
1432 XRenderFreePicture (dpy, dst); 1358 XRenderFreePicture (dpy, dst);
1433#else 1359#else
1434 root_pixmap = None; 1360 root_pixmap = None;
1435#endif 1361#endif
1436 } 1362 }
1363
1364 if (root_pixmap == None)
1365 return 0;
1366
1367 Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth);
1368
1369 if (tiled_root_pmap == None) /* something really bad happened - abort */
1370 return 0;
1371
1372 /* straightforward pixmap copy */
1373 gcv.tile = recoded_root_pmap;
1374 gcv.fill_style = FillTiled;
1375
1376 while (sx < 0) sx += (int)root_width;
1377 while (sy < 0) sy += (int)root_height;
1378
1379 gcv.ts_x_origin = -sx;
1380 gcv.ts_y_origin = -sy;
1381 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1382
1383 if (gc)
1384 {
1385 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1386 result |= transpPmapTiled;
1387 XFreeGC (dpy, gc);
1388 }
1389
1390 if (tiled_root_pmap != None)
1391 {
1392 if (!need_client_side_rendering ())
1393 {
1394 if (flags & (blurNeeded | blurServerSide))
1395 {
1396 if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1397 result |= transpPmapBlurred;
1398 }
1399 if (flags & (tintNeeded | tintServerSide))
1400 {
1401 if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height))
1402 result |= transpPmapTinted;
1403 }
1404 } /* server side rendering completed */
1405
1406 if (pixmap)
1407 XFreePixmap (dpy, pixmap);
1408
1409 pixmap = tiled_root_pmap;
1410 pmap_width = window_width;
1411 pmap_height = window_height;
1412 pmap_depth = target->depth;
1413 }
1414
1415 if (recoded_root_pmap != root_pixmap)
1416 XFreePixmap (dpy, recoded_root_pmap);
1417
1418 return result;
1419}
1420
1421void
1422bgPixmap_t::set_root_pixmap ()
1423{
1424 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1425 if (new_root_pixmap == None)
1426 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1427
1428 root_pixmap = new_root_pixmap;
1437} 1429}
1438# endif /* ENABLE_TRANSPARENCY */ 1430# endif /* ENABLE_TRANSPARENCY */
1439 1431
1440# ifndef HAVE_AFTERIMAGE 1432# ifndef HAVE_AFTERIMAGE
1441static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1433static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines