… | |
… | |
428 | { |
428 | { |
429 | flags = new_flags; |
429 | flags = new_flags; |
430 | changed++; |
430 | changed++; |
431 | } |
431 | } |
432 | |
432 | |
433 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
|
|
434 | // flags, h_scale, v_scale, h_align, v_align); |
|
|
435 | return (changed > 0); |
433 | return (changed > 0); |
436 | } |
434 | } |
437 | |
435 | |
438 | void |
436 | void |
439 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
437 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
… | |
… | |
529 | |
527 | |
530 | int x = 0; |
528 | int x = 0; |
531 | int y = 0; |
529 | int y = 0; |
532 | int w = 0; |
530 | int w = 0; |
533 | int h = 0; |
531 | int h = 0; |
534 | |
|
|
535 | TIMING_TEST_START (asim); |
|
|
536 | |
532 | |
537 | if (original_asim) |
533 | if (original_asim) |
538 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
534 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
539 | |
535 | |
540 | if (!original_asim |
536 | if (!original_asim |
… | |
… | |
657 | } |
653 | } |
658 | |
654 | |
659 | free (layers); |
655 | free (layers); |
660 | } |
656 | } |
661 | } |
657 | } |
662 | TIMING_TEST_PRINT_RESULT (asim); |
|
|
663 | |
658 | |
664 | bool ret = false; |
659 | bool ret = false; |
665 | |
660 | |
666 | if (result) |
661 | if (result) |
667 | { |
662 | { |
… | |
… | |
713 | |
708 | |
714 | if (result != background && result != original_asim) |
709 | if (result != background && result != original_asim) |
715 | destroy_asimage (&result); |
710 | destroy_asimage (&result); |
716 | |
711 | |
717 | XFreeGC (target->dpy, gc); |
712 | XFreeGC (target->dpy, gc); |
718 | TIMING_TEST_PRINT_RESULT (asim); |
|
|
719 | |
713 | |
720 | ret = true; |
714 | ret = true; |
721 | } |
715 | } |
722 | |
716 | |
723 | if (background) |
717 | if (background) |
… | |
… | |
1283 | } |
1277 | } |
1284 | |
1278 | |
1285 | XRenderFreePicture (dpy, mask_pic); |
1279 | XRenderFreePicture (dpy, mask_pic); |
1286 | XRenderFreePicture (dpy, overlay_pic); |
1280 | XRenderFreePicture (dpy, overlay_pic); |
1287 | XRenderFreePicture (dpy, back_pic); |
1281 | XRenderFreePicture (dpy, back_pic); |
1288 | # if DO_TIMING_TEST |
|
|
1289 | XSync (dpy, False); |
|
|
1290 | # endif |
|
|
1291 | # endif |
1282 | # endif |
1292 | } |
1283 | } |
1293 | |
1284 | |
1294 | return ret; |
1285 | return ret; |
1295 | } |
1286 | } |
1296 | |
1287 | |
1297 | /* make_transparency_pixmap() |
1288 | /* make_transparency_pixmap() |
1298 | * 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 |
1299 | * 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 |
1300 | * our window. |
1291 | * our window. |
1301 | */ |
1292 | */ |
1302 | unsigned long |
1293 | unsigned long |
1303 | bgPixmap_t::make_transparency_pixmap () |
1294 | bgPixmap_t::make_transparency_pixmap () |
1304 | { |
1295 | { |
… | |
… | |
1313 | Window root = target->display->root; |
1304 | Window root = target->display->root; |
1314 | int screen = target->display->screen; |
1305 | int screen = target->display->screen; |
1315 | Display *dpy = target->dpy; |
1306 | Display *dpy = target->dpy; |
1316 | int root_width = DisplayWidth (dpy, screen); |
1307 | int root_width = DisplayWidth (dpy, screen); |
1317 | int root_height = DisplayHeight (dpy, screen); |
1308 | int root_height = DisplayHeight (dpy, screen); |
1318 | unsigned int root_pmap_width, root_pmap_height; |
|
|
1319 | int window_width = target->szHint.width; |
1309 | int window_width = target->szHint.width; |
1320 | int window_height = target->szHint.height; |
1310 | int window_height = target->szHint.height; |
1321 | int sx, sy; |
1311 | int sx, sy; |
1322 | XGCValues gcv; |
1312 | XGCValues gcv; |
1323 | GC gc; |
1313 | GC gc; |
1324 | |
1314 | |
1325 | TIMING_TEST_START (tp); |
|
|
1326 | target->get_window_origin (sx, sy); |
1315 | target->get_window_origin (sx, sy); |
1327 | |
1316 | |
1328 | /* check if we are outside of the visible part of the virtual screen : */ |
1317 | /* check if we are outside of the visible part of the virtual screen : */ |
1329 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1318 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1330 | || sx >= root_width || sy >= root_height) |
1319 | || sx >= root_width || sy >= root_height) |
1331 | return 0; |
1320 | return 0; |
1332 | |
1321 | |
1333 | if (root_pixmap != None) |
|
|
1334 | { |
|
|
1335 | /* we want to validate the pixmap and get its size at the same time : */ |
|
|
1336 | int junk; |
|
|
1337 | unsigned int ujunk; |
|
|
1338 | /* root pixmap may be bad - allow a error */ |
|
|
1339 | target->allowedxerror = -1; |
|
|
1340 | |
|
|
1341 | if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) |
|
|
1342 | root_pixmap = None; |
|
|
1343 | |
|
|
1344 | target->allowedxerror = 0; |
|
|
1345 | } |
|
|
1346 | |
|
|
1347 | if (root_pixmap == None) |
1322 | if (root_pixmap == None) |
1348 | return 0; |
1323 | return 0; |
1349 | |
1324 | |
1350 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
1325 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
1351 | |
1326 | |
… | |
… | |
1367 | { |
1342 | { |
1368 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1343 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1369 | result |= transpPmapTiled; |
1344 | result |= transpPmapTiled; |
1370 | XFreeGC (dpy, gc); |
1345 | XFreeGC (dpy, gc); |
1371 | } |
1346 | } |
1372 | TIMING_TEST_PRINT_RESULT (tp); |
|
|
1373 | |
1347 | |
1374 | if (tiled_root_pmap != None) |
1348 | if (tiled_root_pmap != None) |
1375 | { |
1349 | { |
1376 | if (!need_client_side_rendering ()) |
1350 | if (!need_client_side_rendering ()) |
1377 | { |
1351 | { |
… | |
… | |
1394 | pmap_width = window_width; |
1368 | pmap_width = window_width; |
1395 | pmap_height = window_height; |
1369 | pmap_height = window_height; |
1396 | pmap_depth = root_depth; |
1370 | pmap_depth = root_depth; |
1397 | } |
1371 | } |
1398 | |
1372 | |
1399 | TIMING_TEST_PRINT_RESULT (tp); |
|
|
1400 | |
|
|
1401 | return result; |
1373 | return result; |
1402 | } |
1374 | } |
1403 | |
1375 | |
1404 | bool |
1376 | void |
1405 | bgPixmap_t::set_root_pixmap () |
1377 | bgPixmap_t::set_root_pixmap () |
1406 | { |
1378 | { |
1407 | Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1379 | Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1408 | if (new_root_pixmap == None) |
1380 | if (new_root_pixmap == None) |
1409 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1381 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1410 | |
1382 | |
1411 | if (new_root_pixmap != root_pixmap) |
|
|
1412 | { |
|
|
1413 | root_pixmap = new_root_pixmap; |
1383 | root_pixmap = new_root_pixmap; |
1414 | return true; |
1384 | |
|
|
1385 | // validate root pixmap |
|
|
1386 | if (root_pixmap != None) |
1415 | } |
1387 | { |
|
|
1388 | unsigned int width, height; |
|
|
1389 | Window wdummy; |
|
|
1390 | int idummy; |
|
|
1391 | unsigned int udummy; |
1416 | |
1392 | |
1417 | return false; |
1393 | target->allowedxerror = -1; |
|
|
1394 | |
|
|
1395 | if (!XGetGeometry (target->dpy, root_pixmap, &wdummy, &idummy, &idummy, &width, &height, &udummy, &udummy)) |
|
|
1396 | root_pixmap = None; |
|
|
1397 | |
|
|
1398 | target->allowedxerror = 0; |
|
|
1399 | } |
1418 | } |
1400 | } |
1419 | # endif /* ENABLE_TRANSPARENCY */ |
1401 | # endif /* ENABLE_TRANSPARENCY */ |
1420 | |
1402 | |
1421 | # ifndef HAVE_AFTERIMAGE |
1403 | # ifndef HAVE_AFTERIMAGE |
1422 | static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); |
1404 | static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); |
… | |
… | |
1427 | { |
1409 | { |
1428 | unsigned long background_flags = 0; |
1410 | unsigned long background_flags = 0; |
1429 | |
1411 | |
1430 | if (target == NULL) |
1412 | if (target == NULL) |
1431 | return false; |
1413 | return false; |
1432 | |
|
|
1433 | TIMING_TEST_START (tp); |
|
|
1434 | |
1414 | |
1435 | invalidate (); |
1415 | invalidate (); |
1436 | # ifdef ENABLE_TRANSPARENCY |
1416 | # ifdef ENABLE_TRANSPARENCY |
1437 | if (flags & isTransparent) |
1417 | if (flags & isTransparent) |
1438 | { |
1418 | { |
… | |
… | |
1464 | |
1444 | |
1465 | if (result) |
1445 | if (result) |
1466 | { |
1446 | { |
1467 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
1447 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
1468 | /* our own client-side tinting */ |
1448 | /* our own client-side tinting */ |
1469 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1470 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1471 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1449 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1472 | { |
1450 | { |
1473 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1451 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1474 | if (flags & tintSet) |
1452 | if (flags & tintSet) |
1475 | tint.get (c); |
1453 | tint.get (c); |
… | |
… | |
1527 | } |
1505 | } |
1528 | } |
1506 | } |
1529 | |
1507 | |
1530 | apply (); |
1508 | apply (); |
1531 | |
1509 | |
1532 | XSync (target->dpy, False); |
|
|
1533 | valid_since = ev::now (); |
1510 | valid_since = ev::now (); |
1534 | |
|
|
1535 | TIMING_TEST_PRINT_RESULT (tp); |
|
|
1536 | |
1511 | |
1537 | return true; |
1512 | return true; |
1538 | } |
1513 | } |
1539 | |
1514 | |
1540 | bool |
1515 | bool |
… | |
… | |
1556 | void |
1531 | void |
1557 | bgPixmap_t::apply () |
1532 | bgPixmap_t::apply () |
1558 | { |
1533 | { |
1559 | if (target) |
1534 | if (target) |
1560 | { |
1535 | { |
1561 | flags &= ~isVtOrigin; |
|
|
1562 | |
|
|
1563 | if (pixmap != None) |
1536 | if (pixmap != None) |
1564 | { |
1537 | { |
1565 | /* set target's background to pixmap */ |
1538 | /* set target's background to pixmap */ |
1566 | # ifdef ENABLE_TRANSPARENCY |
1539 | # ifdef ENABLE_TRANSPARENCY |
1567 | if (flags & isTransparent) |
1540 | if (flags & isTransparent) |
… | |
… | |
1573 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1546 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1574 | } |
1547 | } |
1575 | else |
1548 | else |
1576 | # endif |
1549 | # endif |
1577 | { |
1550 | { |
1578 | flags |= isVtOrigin; |
|
|
1579 | /* force old pixmap dereference in case it was transparent before :*/ |
1551 | /* force old pixmap dereference in case it was transparent before :*/ |
1580 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1552 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1581 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1553 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1582 | /* do we also need to set scrollbar's background here ? */ |
1554 | /* do we also need to set scrollbar's background here ? */ |
1583 | |
1555 | |