|
Lines 93-99
Link Here
|
| 93 |
for (unsigned i=0; i<m_Renderer.size(); i++) |
93 |
for (unsigned i=0; i<m_Renderer.size(); i++) |
| 94 |
{ |
94 |
{ |
| 95 |
m_Cache.insert(i, new KBackgroundCacheEntry); |
95 |
m_Cache.insert(i, new KBackgroundCacheEntry); |
| 96 |
m_Cache[i]->pixmap = 0L; |
96 |
m_Cache[i]->pixmap = KPixmap(); |
| 97 |
m_Cache[i]->hash = 0; |
97 |
m_Cache[i]->hash = 0; |
| 98 |
m_Cache[i]->exp_from = -1; |
98 |
m_Cache[i]->exp_from = -1; |
| 99 |
m_Renderer.insert (i, new KVirtualBGRenderer(i,m_pConfig)); |
99 |
m_Renderer.insert (i, new KVirtualBGRenderer(i,m_pConfig)); |
|
Lines 102-109
Link Here
|
| 102 |
} |
102 |
} |
| 103 |
|
103 |
|
| 104 |
#ifdef COMPOSITE |
104 |
#ifdef COMPOSITE |
| 105 |
m_tPixmap = new KPixmap(kapp->desktop()->size()); |
105 |
m_tPixmap = KPixmap(kapp->desktop()->size()); |
| 106 |
m_tPixmap->fill(TQColor(0, 0x0)); |
106 |
m_tPixmap.fill(TQColor(0, 0x0)); |
| 107 |
connect(myApp, TQT_SIGNAL(cmBackgroundChanged( bool )), |
107 |
connect(myApp, TQT_SIGNAL(cmBackgroundChanged( bool )), |
| 108 |
TQT_SLOT(slotCmBackgroundChanged( bool ))); |
108 |
TQT_SLOT(slotCmBackgroundChanged( bool ))); |
| 109 |
#endif |
109 |
#endif |
|
Lines 175-184
Link Here
|
| 175 |
return; |
175 |
return; |
| 176 |
|
176 |
|
| 177 |
for (unsigned i=0; i<m_Cache.size(); i++) |
177 |
for (unsigned i=0; i<m_Cache.size(); i++) |
| 178 |
{ |
|
|
| 179 |
delete m_Cache[i]->pixmap; |
| 180 |
delete m_Cache[i]; |
178 |
delete m_Cache[i]; |
| 181 |
} |
|
|
| 182 |
} |
179 |
} |
| 183 |
|
180 |
|
| 184 |
|
181 |
|
|
Lines 334-340
Link Here
|
| 334 |
for (int i=oldsz; i<num; i++) |
331 |
for (int i=oldsz; i<num; i++) |
| 335 |
{ |
332 |
{ |
| 336 |
m_Cache.insert(i, new KBackgroundCacheEntry); |
333 |
m_Cache.insert(i, new KBackgroundCacheEntry); |
| 337 |
m_Cache[i]->pixmap = 0L; |
334 |
m_Cache[i]->pixmap = KPixmap(); |
| 338 |
m_Cache[i]->hash = 0; |
335 |
m_Cache[i]->hash = 0; |
| 339 |
m_Cache[i]->exp_from = -1; |
336 |
m_Cache[i]->exp_from = -1; |
| 340 |
m_Renderer.insert(i, new KVirtualBGRenderer(i,m_pConfig)); |
337 |
m_Renderer.insert(i, new KVirtualBGRenderer(i,m_pConfig)); |
|
Lines 382-388
Link Here
|
| 382 |
// If we have the background already rendered: set it |
379 |
// If we have the background already rendered: set it |
| 383 |
for (unsigned i=0; i<m_Cache.size(); i++) |
380 |
for (unsigned i=0; i<m_Cache.size(); i++) |
| 384 |
{ |
381 |
{ |
| 385 |
if (!m_Cache[i]->pixmap) |
382 |
if (m_Cache[i]->pixmap.isNull()) |
| 386 |
continue; |
383 |
continue; |
| 387 |
if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) |
384 |
if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) |
| 388 |
continue; |
385 |
continue; |
|
Lines 392-397
Link Here
|
| 392 |
setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); |
389 |
setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i); |
| 393 |
m_Cache[i]->atime = m_Serial; |
390 |
m_Cache[i]->atime = m_Serial; |
| 394 |
exportBackground(i, desk); |
391 |
exportBackground(i, desk); |
|
|
392 |
|
| 395 |
return; |
393 |
return; |
| 396 |
} |
394 |
} |
| 397 |
|
395 |
|
|
Lines 443-449
Link Here
|
| 443 |
// If we have the background already rendered: set it |
441 |
// If we have the background already rendered: set it |
| 444 |
for (unsigned i=0; i<m_Cache.size(); i++) |
442 |
for (unsigned i=0; i<m_Cache.size(); i++) |
| 445 |
{ |
443 |
{ |
| 446 |
if (!m_Cache[i]->pixmap) |
444 |
if (m_Cache[i]->pixmap.isNull()) |
| 447 |
continue; |
445 |
continue; |
| 448 |
if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) |
446 |
if (m_Cache[i]->hash != m_Renderer[edesk]->hash()) |
| 449 |
continue; |
447 |
continue; |
|
Lines 490-505
Link Here
|
| 490 |
/* |
488 |
/* |
| 491 |
* Paint the pixmap to the root window. |
489 |
* Paint the pixmap to the root window. |
| 492 |
*/ |
490 |
*/ |
| 493 |
void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk) |
491 |
void KBackgroundManager::setPixmap(const KPixmap &pm, int hash, int desk) |
| 494 |
{ |
492 |
{ |
| 495 |
KPixmap *ep = pm; |
493 |
KPixmap ep = pm; |
| 496 |
|
494 |
|
| 497 |
#ifdef COMPOSITE |
495 |
#ifdef COMPOSITE |
| 498 |
if (argb_visual && (KDesktopSettings::backgroundOpacity() < 100 |
496 |
if (argb_visual && (KDesktopSettings::backgroundOpacity() < 100 |
| 499 |
|| myApp->cmBackground())) |
497 |
|| myApp->cmBackground())) |
| 500 |
{ |
498 |
{ |
| 501 |
ep = m_tPixmap; |
499 |
ep = m_tPixmap; |
| 502 |
if (KDesktopSettings::backgroundOpacity() > 0 && pm |
500 |
if (KDesktopSettings::backgroundOpacity() > 0 && !pm.isNull() |
| 503 |
&& !myApp->cmBackground()) |
501 |
&& !myApp->cmBackground()) |
| 504 |
{ |
502 |
{ |
| 505 |
XRenderPictFormat *format; |
503 |
XRenderPictFormat *format; |
|
Lines 514-526
Link Here
|
| 514 |
fillColor.alpha = color; |
512 |
fillColor.alpha = color; |
| 515 |
|
513 |
|
| 516 |
Picture fill = XRenderCreateSolidFill (tqt_xdisplay(), &fillColor); |
514 |
Picture fill = XRenderCreateSolidFill (tqt_xdisplay(), &fillColor); |
| 517 |
Picture src = XRenderCreatePicture(tqt_xdisplay(), pm->handle(), |
515 |
Picture src = XRenderCreatePicture(tqt_xdisplay(), pm.handle(), |
| 518 |
format, 0, NULL); |
516 |
format, 0, NULL); |
| 519 |
Picture dst = XRenderCreatePicture(tqt_xdisplay(), ep->handle(), |
517 |
Picture dst = XRenderCreatePicture(tqt_xdisplay(), ep.handle(), |
| 520 |
format, 0, NULL); |
518 |
format, 0, NULL); |
| 521 |
|
519 |
|
| 522 |
XRenderComposite (tqt_xdisplay(), PictOpSrc, src, fill, dst, 0, 0, 0, |
520 |
XRenderComposite (tqt_xdisplay(), PictOpSrc, src, fill, dst, 0, 0, 0, |
| 523 |
0, 0, 0, pm->width(), pm->height()); |
521 |
0, 0, 0, pm.width(), pm.height()); |
| 524 |
|
522 |
|
| 525 |
XRenderFreePicture (tqt_xdisplay(), fill); |
523 |
XRenderFreePicture (tqt_xdisplay(), fill); |
| 526 |
XRenderFreePicture (tqt_xdisplay(), src); |
524 |
XRenderFreePicture (tqt_xdisplay(), src); |
|
Lines 536-542
Link Here
|
| 536 |
// Qt eats repaint events in this case :-(( |
534 |
// Qt eats repaint events in this case :-(( |
| 537 |
sv->viewport()->update(); |
535 |
sv->viewport()->update(); |
| 538 |
} |
536 |
} |
| 539 |
m_pDesktop->setErasePixmap(*ep); |
537 |
m_pDesktop->setErasePixmap(ep); |
| 540 |
m_pDesktop->repaint(); |
538 |
m_pDesktop->repaint(); |
| 541 |
static bool root_cleared = false; |
539 |
static bool root_cleared = false; |
| 542 |
if( !root_cleared ) |
540 |
if( !root_cleared ) |
|
Lines 544-561
Link Here
|
| 544 |
root_cleared = true; |
542 |
root_cleared = true; |
| 545 |
TQTimer::singleShot( 0, this, TQT_SLOT( clearRoot())); |
543 |
TQTimer::singleShot( 0, this, TQT_SLOT( clearRoot())); |
| 546 |
// but make the pixmap visible until m_pDesktop is visible |
544 |
// but make the pixmap visible until m_pDesktop is visible |
| 547 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); |
545 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(ep); |
| 548 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); |
546 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); |
| 549 |
} |
547 |
} |
| 550 |
} |
548 |
} |
| 551 |
else |
549 |
else |
| 552 |
{ |
550 |
{ |
| 553 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); |
551 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(ep); |
| 554 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); |
552 |
TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); |
| 555 |
} |
553 |
} |
| 556 |
|
554 |
|
| 557 |
// and export it via Esetroot-style for gnome/GTK apps to share in the pretties |
555 |
// and export it via Esetroot-style for gnome/GTK apps to share in the pretties |
| 558 |
Pixmap bgPm = pm->handle(); // fetch the actual X handle to it |
556 |
Pixmap bgPm = pm.handle(); // fetch the actual X handle to it |
| 559 |
//kdDebug() << "Esetroot compat: setting pixmap to " << bgPm << endl; |
557 |
//kdDebug() << "Esetroot compat: setting pixmap to " << bgPm << endl; |
| 560 |
|
558 |
|
| 561 |
// don't set the ESETROOT_PMAP_ID property - that would result in possible XKillClient() |
559 |
// don't set the ESETROOT_PMAP_ID property - that would result in possible XKillClient() |
|
Lines 605-619
Link Here
|
| 605 |
mAlpha = 1; |
603 |
mAlpha = 1; |
| 606 |
m_crossTimer->stop(); |
604 |
m_crossTimer->stop(); |
| 607 |
KPixmap pixm(mNextScreen); |
605 |
KPixmap pixm(mNextScreen); |
| 608 |
setPixmap(&pixm, r->hash(), fadeDesk); |
606 |
setPixmap(pixm, r->hash(), fadeDesk); |
| 609 |
return; |
607 |
return; |
| 610 |
} |
608 |
} |
| 611 |
// Reset Timer |
609 |
// Reset Timer |
| 612 |
mBenchmark.start(); |
610 |
mBenchmark.start(); |
| 613 |
|
611 |
|
| 614 |
TQPixmap dst = crossFade(*mOldScreen, mNextScreen, mAlpha, crossInit); |
612 |
TQPixmap dst = crossFade(mOldScreen, mNextScreen, mAlpha, crossInit); |
| 615 |
KPixmap pixm(dst); |
613 |
KPixmap pixm(dst); |
| 616 |
setPixmap(&pixm, r->hash(), fadeDesk); |
614 |
setPixmap(pixm, r->hash(), fadeDesk); |
| 617 |
|
615 |
|
| 618 |
mAlpha -=0.03; |
616 |
mAlpha -=0.03; |
| 619 |
crossInit = false; |
617 |
crossInit = false; |
|
Lines 631-637
Link Here
|
| 631 |
m_numberOfViewports = 1; |
629 |
m_numberOfViewports = 1; |
| 632 |
} |
630 |
} |
| 633 |
|
631 |
|
| 634 |
KPixmap *pm = new KPixmap(); |
632 |
KPixmap pm = KPixmap(); |
| 635 |
KVirtualBGRenderer *r = m_Renderer[desk]; |
633 |
KVirtualBGRenderer *r = m_Renderer[desk]; |
| 636 |
bool do_cleanup = true; |
634 |
bool do_cleanup = true; |
| 637 |
fadeDesk = desk; |
635 |
fadeDesk = desk; |
|
Lines 639-645
Link Here
|
| 639 |
int width,height; |
637 |
int width,height; |
| 640 |
|
638 |
|
| 641 |
|
639 |
|
| 642 |
*pm = r->pixmap(); |
640 |
pm = r->pixmap(); |
| 643 |
// If current: paint it |
641 |
// If current: paint it |
| 644 |
bool current = (r->hash() == m_Renderer[effectiveDesktop()]->hash()); |
642 |
bool current = (r->hash() == m_Renderer[effectiveDesktop()]->hash()); |
| 645 |
if (current) |
643 |
if (current) |
|
Lines 653-672
Link Here
|
| 653 |
if (mode == KBackgroundSettings::NoWallpaper || mode == KBackgroundSettings::Tiled || mode == KBackgroundSettings::CenterTiled ){ |
651 |
if (mode == KBackgroundSettings::NoWallpaper || mode == KBackgroundSettings::Tiled || mode == KBackgroundSettings::CenterTiled ){ |
| 654 |
mNextScreen = TQPixmap(width,height); |
652 |
mNextScreen = TQPixmap(width,height); |
| 655 |
TQPainter p (&mNextScreen); |
653 |
TQPainter p (&mNextScreen); |
| 656 |
p.drawTiledPixmap(0,0,width,height,*pm); |
654 |
p.drawTiledPixmap(0,0,width,height,pm); |
| 657 |
} else { |
655 |
} else { |
| 658 |
mNextScreen = TQPixmap(*pm); |
656 |
mNextScreen = TQPixmap(pm); |
| 659 |
} |
657 |
} |
| 660 |
|
658 |
|
|
|
659 |
TQPixmap *mOldScreen_ = NULL; |
| 661 |
if (m_pDesktop){ |
660 |
if (m_pDesktop){ |
| 662 |
mOldScreen = const_cast<TQPixmap *>( m_pDesktop->backgroundPixmap() ); |
661 |
mOldScreen_ = const_cast<TQPixmap *>( m_pDesktop->backgroundPixmap() ); |
| 663 |
}else{ |
662 |
}else{ |
| 664 |
mOldScreen = const_cast<TQPixmap *>( |
663 |
mOldScreen_ = const_cast<TQPixmap *>( |
| 665 |
TQApplication::desktop()->screen()->backgroundPixmap() ); |
664 |
TQApplication::desktop()->screen()->backgroundPixmap() ); |
| 666 |
} |
665 |
} |
| 667 |
|
666 |
|
| 668 |
//TODO Find a way to discover if CrossFade effect needs to run |
667 |
//TODO Find a way to discover if CrossFade effect needs to run |
| 669 |
if (mOldScreen){ |
668 |
if (mOldScreen_){ |
|
|
669 |
mOldScreen = *mOldScreen_; |
| 670 |
crossInit = true; |
670 |
crossInit = true; |
| 671 |
m_crossTimer->start(70); |
671 |
m_crossTimer->start(70); |
| 672 |
} else{ |
672 |
} else{ |
|
Lines 688-696
Link Here
|
| 688 |
if (m_bExport || !m_bCommon) { |
688 |
if (m_bExport || !m_bCommon) { |
| 689 |
addCache(pm, r->hash(), desk); |
689 |
addCache(pm, r->hash(), desk); |
| 690 |
} |
690 |
} |
| 691 |
else { |
|
|
| 692 |
delete pm; |
| 693 |
} |
| 694 |
|
691 |
|
| 695 |
if (current) { |
692 |
if (current) { |
| 696 |
exportBackground(desk, realDesktop()); |
693 |
exportBackground(desk, realDesktop()); |
|
Lines 717-725
Link Here
|
| 717 |
/* |
714 |
/* |
| 718 |
* Size in bytes of a TQPixmap. For use in the pixmap cache. |
715 |
* Size in bytes of a TQPixmap. For use in the pixmap cache. |
| 719 |
*/ |
716 |
*/ |
| 720 |
int KBackgroundManager::pixmapSize(TQPixmap *pm) |
717 |
int KBackgroundManager::pixmapSize(const TQPixmap &pm) |
| 721 |
{ |
718 |
{ |
| 722 |
return (pm->width() * pm->height()) * ((pm->depth() + 7) / 8); |
719 |
return (pm.width() * pm.height()) * ((pm.depth() + 7) / 8); |
| 723 |
} |
720 |
} |
| 724 |
|
721 |
|
| 725 |
|
722 |
|
|
Lines 731-737
Link Here
|
| 731 |
int total = 0; |
728 |
int total = 0; |
| 732 |
for (unsigned i=0; i<m_Cache.size(); i++) |
729 |
for (unsigned i=0; i<m_Cache.size(); i++) |
| 733 |
{ |
730 |
{ |
| 734 |
if (m_Cache[i]->pixmap) |
731 |
if (!m_Cache[i]->pixmap.isNull()) |
| 735 |
total += pixmapSize(m_Cache[i]->pixmap); |
732 |
total += pixmapSize(m_Cache[i]->pixmap); |
| 736 |
} |
733 |
} |
| 737 |
return total; |
734 |
return total; |
|
Lines 745-753
Link Here
|
| 745 |
{ |
742 |
{ |
| 746 |
if (m_bExport) |
743 |
if (m_bExport) |
| 747 |
m_pPixmapServer->remove(KRootPixmap::pixmapName(desk+1)); |
744 |
m_pPixmapServer->remove(KRootPixmap::pixmapName(desk+1)); |
| 748 |
else |
745 |
m_Cache[desk]->pixmap = KPixmap(); |
| 749 |
delete m_Cache[desk]->pixmap; |
|
|
| 750 |
m_Cache[desk]->pixmap = 0L; |
| 751 |
m_Cache[desk]->hash = 0; |
746 |
m_Cache[desk]->hash = 0; |
| 752 |
m_Cache[desk]->exp_from = -1; |
747 |
m_Cache[desk]->exp_from = -1; |
| 753 |
m_Cache[desk]->atime = 0; |
748 |
m_Cache[desk]->atime = 0; |
|
Lines 784-790
Link Here
|
| 784 |
min = m_Serial+1; j = 0; |
779 |
min = m_Serial+1; j = 0; |
| 785 |
for (unsigned i=0; i<m_Cache.size(); i++) |
780 |
for (unsigned i=0; i<m_Cache.size(); i++) |
| 786 |
{ |
781 |
{ |
| 787 |
if (m_Cache[i]->pixmap && (m_Cache[i]->atime < min)) |
782 |
if (!m_Cache[i]->pixmap.isNull() && (m_Cache[i]->atime < min)) |
| 788 |
{ |
783 |
{ |
| 789 |
min = m_Cache[i]->atime; |
784 |
min = m_Cache[i]->atime; |
| 790 |
j = i; |
785 |
j = i; |
|
Lines 800-814
Link Here
|
| 800 |
* Try to add a pixmap to the pixmap cache. We don't use TQPixmapCache here |
795 |
* Try to add a pixmap to the pixmap cache. We don't use TQPixmapCache here |
| 801 |
* because if we're exporting pixmaps, this needs special care. |
796 |
* because if we're exporting pixmaps, this needs special care. |
| 802 |
*/ |
797 |
*/ |
| 803 |
void KBackgroundManager::addCache(KPixmap *pm, int hash, int desk) |
798 |
void KBackgroundManager::addCache(const KPixmap &pm, int hash, int desk) |
| 804 |
{ |
799 |
{ |
| 805 |
if (m_Cache[desk]->pixmap) |
800 |
if (!m_Cache[desk]->pixmap.isNull()) |
| 806 |
removeCache(desk); |
801 |
removeCache(desk); |
| 807 |
|
802 |
|
| 808 |
if (m_bLimitCache && !m_bExport && !freeCache(pixmapSize(pm))) |
803 |
if (m_bLimitCache && !m_bExport && !freeCache(pixmapSize(pm))) |
| 809 |
{ |
804 |
{ |
| 810 |
// pixmap does not fit in cache |
805 |
// pixmap does not fit in cache |
| 811 |
delete pm; |
|
|
| 812 |
return; |
806 |
return; |
| 813 |
} |
807 |
} |
| 814 |
|
808 |
|
|
Lines 1024-1033
Link Here
|
| 1024 |
} |
1018 |
} |
| 1025 |
|
1019 |
|
| 1026 |
#ifdef COMPOSITE |
1020 |
#ifdef COMPOSITE |
| 1027 |
if (m_tPixmap) |
1021 |
m_tPixmap = KPixmap(kapp->desktop()->size()); |
| 1028 |
delete m_tPixmap; |
1022 |
m_tPixmap.fill(TQColor(0, 0x0)); |
| 1029 |
m_tPixmap = new KPixmap(kapp->desktop()->size()); |
|
|
| 1030 |
m_tPixmap->fill(TQColor(0, 0x0)); |
| 1031 |
#endif |
1023 |
#endif |
| 1032 |
|
1024 |
|
| 1033 |
m_Hash = 0; |
1025 |
m_Hash = 0; |
|
Lines 1100-1106
Link Here
|
| 1100 |
#ifdef COMPOSITE |
1092 |
#ifdef COMPOSITE |
| 1101 |
void KBackgroundManager::slotCmBackgroundChanged( bool ) |
1093 |
void KBackgroundManager::slotCmBackgroundChanged( bool ) |
| 1102 |
{ |
1094 |
{ |
| 1103 |
m_tPixmap->fill(TQColor(0, 0x0)); |
1095 |
m_tPixmap.fill(TQColor(0, 0x0)); |
| 1104 |
m_Hash = 0; |
1096 |
m_Hash = 0; |
| 1105 |
slotChangeDesktop(0); |
1097 |
slotChangeDesktop(0); |
| 1106 |
} |
1098 |
} |