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.80 by sf-exg, Wed Oct 13 23:04:57 2010 UTC vs.
Revision 1.81 by sf-exg, Wed Oct 13 23:08:11 2010 UTC

1316 unsigned int root_pmap_width, root_pmap_height; 1316 unsigned int root_pmap_width, root_pmap_height;
1317 int window_width = target->szHint.width; 1317 int window_width = target->szHint.width;
1318 int window_height = target->szHint.height; 1318 int window_height = target->szHint.height;
1319 int sx, sy; 1319 int sx, sy;
1320 XGCValues gcv; 1320 XGCValues gcv;
1321 GC gc;
1321 1322
1322 TIMING_TEST_START (tp); 1323 TIMING_TEST_START (tp);
1323 target->get_window_origin (sx, sy); 1324 target->get_window_origin (sx, sy);
1324 1325
1325 /* check if we are outside of the visible part of the virtual screen : */ 1326 /* check if we are outside of the visible part of the virtual screen : */
1339 root_pixmap = None; 1340 root_pixmap = None;
1340 1341
1341 target->allowedxerror = 0; 1342 target->allowedxerror = 0;
1342 } 1343 }
1343 1344
1345 if (root_pixmap == None)
1346 return 0;
1347
1344 Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); 1348 Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth);
1345 GC gc = NULL;
1346 1349
1347 if (tiled_root_pmap == None) /* something really bad happened - abort */ 1350 if (tiled_root_pmap == None) /* something really bad happened - abort */
1348 return 0; 1351 return 0;
1349 1352
1350 if (root_pixmap == None)
1351 {
1352 /* use tricks to obtain the root background image :*/
1353 /* we want to create Overrideredirect window overlapping out window
1354 with background type of Parent Relative and then grab it */
1355 XSetWindowAttributes attr;
1356 Window src;
1357 bool success = false;
1358
1359 attr.background_pixmap = ParentRelative;
1360 attr.backing_store = Always;
1361 attr.event_mask = ExposureMask;
1362 attr.override_redirect = True;
1363 src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0,
1364 CopyFromParent, CopyFromParent, CopyFromParent,
1365 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask,
1366 &attr);
1367
1368 if (src != None)
1369 {
1370 XEvent event;
1371 int ev_count = 0;
1372 XGrabServer (dpy);
1373 XMapRaised (dpy, src);
1374 XSync (dpy, False);
1375
1376 /* XSync should get window where it's properly exposed,
1377 * but to be on the safe side - let's check for the actual event to arrive : */
1378 while (XCheckWindowEvent (dpy, src, ExposureMask, &event))
1379 ++ev_count;
1380
1381 if (ev_count > 0);
1382 {
1383 /* hooray! - we can grab the image! */
1384 gc = XCreateGC (dpy, root, 0, NULL);
1385 if (gc)
1386 {
1387 XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0);
1388 success = true;
1389 }
1390 }
1391
1392 XDestroyWindow (dpy, src);
1393 XUngrabServer (dpy);
1394 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count);
1395 }
1396
1397 if (!success)
1398 {
1399 XFreePixmap (dpy, tiled_root_pmap);
1400 tiled_root_pmap = None;
1401 }
1402 else
1403 result |= transpPmapTiled;
1404 }
1405 else
1406 {
1407 /* straightforward pixmap copy */ 1353 /* straightforward pixmap copy */
1408 gcv.tile = root_pixmap; 1354 gcv.tile = root_pixmap;
1409 gcv.fill_style = FillTiled; 1355 gcv.fill_style = FillTiled;
1410 1356
1411 while (sx < 0) sx += (int)root_width; 1357 while (sx < 0) sx += (int)root_width;
1412 while (sy < 0) sy += (int)root_height; 1358 while (sy < 0) sy += (int)root_height;
1413 1359
1414 gcv.ts_x_origin = -sx; 1360 gcv.ts_x_origin = -sx;
1415 gcv.ts_y_origin = -sy; 1361 gcv.ts_y_origin = -sy;
1416 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1362 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1417 1363
1418 if (gc) 1364 if (gc)
1419 { 1365 {
1420 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1366 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1421 result |= transpPmapTiled; 1367 result |= transpPmapTiled;
1422 } 1368 XFreeGC (dpy, gc);
1423 } 1369 }
1424 TIMING_TEST_PRINT_RESULT (tp); 1370 TIMING_TEST_PRINT_RESULT (tp);
1425 1371
1426 if (tiled_root_pmap != None) 1372 if (tiled_root_pmap != None)
1427 { 1373 {
1445 pixmap = tiled_root_pmap; 1391 pixmap = tiled_root_pmap;
1446 pmap_width = window_width; 1392 pmap_width = window_width;
1447 pmap_height = window_height; 1393 pmap_height = window_height;
1448 pmap_depth = root_depth; 1394 pmap_depth = root_depth;
1449 } 1395 }
1450
1451 if (gc)
1452 XFreeGC (dpy, gc);
1453 1396
1454 TIMING_TEST_PRINT_RESULT (tp); 1397 TIMING_TEST_PRINT_RESULT (tp);
1455 1398
1456 return result; 1399 return result;
1457} 1400}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines