21 #include <tqpainter.h>
23 #include <tdeapplication.h>
24 #include "tdescreensaver.h"
36 class KScreenSaverPrivate
50 XSync(tqt_xdisplay(),
false);
52 d =
new KScreenSaverPrivate;
53 d->owner = find(
id );
55 installEventFilter(
this );
60 XGetGeometry(tqt_xdisplay(), (Drawable)
id, &root, &ai, &ai,
64 create(
id,
false,
true );
67 if ( w == 0 ) w = 600;
68 if ( h == 0 ) h = 420;
70 TDEApplication::sendPostedEvents();
74 KScreenSaver::~KScreenSaver()
76 destroy(
false,
false );
82 TDEApplication::sendPostedEvents();
84 XReparentWindow(tqt_xdisplay(), w->winId(), winId(), 0, 0);
86 w->setGeometry( 0, 0, width(), height() );
87 TDEApplication::sendPostedEvents();
90 bool KScreenSaver::eventFilter( TQObject *o, TQEvent *e )
93 if ( d->owner && o ==
this ) {
94 TQApplication::sendEvent( d->owner, e );
98 return TQWidget::eventFilter( o, e );
103 class KBlankEffectPrivate
106 KBlankEffect::BlankEffect currentEffect;
112 KBlankEffect::BlankEffect KBlankEffect::effects[] = {
113 &KBlankEffect::blankNormal,
114 &KBlankEffect::blankSweepRight,
115 &KBlankEffect::blankSweepDown,
116 &KBlankEffect::blankBlocks
119 KBlankEffect::KBlankEffect( TQObject *parent ) : TQObject( parent )
121 d =
new KBlankEffectPrivate;
122 d->currentEffect = &KBlankEffect::blankNormal;
123 d->effectProgress = 0;
124 d->timer =
new TQTimer(
this );
125 connect( d->timer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(timeout()) );
129 KBlankEffect::~KBlankEffect()
134 void KBlankEffect::finished()
137 d->effectProgress = 0;
149 if ( effect == Random )
150 effect = (Effect)(kapp->random() % MaximumEffects);
152 d->effectProgress = 0;
154 d->currentEffect = effects[ (int)effect ];
155 d->timer->start( 10 );
158 void KBlankEffect::timeout()
160 (this->*d->currentEffect)();
163 void KBlankEffect::blankNormal()
165 TQPainter p( d->widget );
166 p.fillRect( 0, 0, d->widget->width(), d->widget->height(), black );
171 void KBlankEffect::blankSweepRight()
173 TQPainter p( d->widget );
174 p.fillRect( d->effectProgress, 0, 50, d->widget->height(), black );
176 d->effectProgress += 50;
177 if ( d->effectProgress >= d->widget->width() )
182 void KBlankEffect::blankSweepDown()
184 TQPainter p( d->widget );
185 p.fillRect( 0, d->effectProgress, d->widget->width(), 50, black );
187 d->effectProgress += 50;
188 if ( d->effectProgress >= d->widget->height() )
193 void KBlankEffect::blankBlocks()
195 static int *block = 0;
197 int bx = (d->widget->width()+63)/64;
198 int by = (d->widget->height()+63)/64;
200 if ( !d->effectProgress ) {
201 block =
new int [ bx*by ];
203 for (
int i = 0; i < bx*by; i++ )
205 for (
int i = 0; i < bx*by; i++ ) {
206 int swap = kapp->random()%(bx*by);
208 block[i] = block[swap];
213 TQPainter p( d->widget );
216 for (
int i = 0; i < 2 && d->effectProgress < bx*by; i++ ) {
217 int x = block[d->effectProgress]%bx;
218 int y = block[d->effectProgress]/bx;
219 p.fillRect( x*64, y*64, 64, 64, black );
225 if ( d->effectProgress >= bx*by ) {
231 #include "tdescreensaver.moc"
void doneBlank()
emitted when a blanking effect has completed.
void blank(TQWidget *w, Effect effect=Random)
Blank a widget using the specified effect.
void embed(TQWidget *widget)
You cannot create a new widget with this widget as parent, since this widget may not be owned by your...