less flicker (once again)

svn path=/trunk/kdebase/kwin/; revision=73778
This commit is contained in:
Matthias Ettrich 2000-12-07 13:17:57 +00:00
parent 287b654d39
commit 7be5b88851

View file

@ -605,24 +605,35 @@ void KDEClient::resizeEvent( QResizeEvent* e)
doShape();
calcHiddenButtons();
if (isVisibleToTLW()) {
update(rect());
int dx = 0;
int dy = 0;
if ( e->oldSize().width() != width() )
dx = 32 + QABS( e->oldSize().width() - width() );
if ( e->oldSize().height() != height() )
dy = 8 + QABS( e->oldSize().height() - height() );
if ( dy )
update( 0, height() - dy + 1, width(), dy );
if ( dx ) {
update( width() - dx + 1, 0, dx, height() );
update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) );
update( QRect( titlebar->geometry().topRight(), QPoint( width() - 4, titlebar->geometry().bottom() ) ) );
if ( !isVisible() )
return;
// make layout update titlebar->geometry() in case some buttons
// where shown or hidden in calcHiddenButtons() above
QApplication::sendPostedEvents( this, QEvent::LayoutHint );
// we selected WResizeNoErase and WNorthWestGravity. That means:
// on a resize event, we do not get a full paint event and the
// background is not erased. This makes it possible for us to
// reduce flicker. All we have to do is to generate the necessary
// paint events manually. We do this using update(). The titlebar
// is even more special: it draws every pixel, so there is no need
// to erase the background. For that reasons we do not use
// update(), but post a paint event with the erased flag set to
// FALSE.
if ( e->oldSize().width() != width() ) {
int dx = (width() - titlebar->geometry().right()) + QABS( e->oldSize().width() - width() );
if ( dx )
update( width() - dx + 1, 0, dx, height() );
// titlebar needs no background
QApplication::postEvent( this, new QPaintEvent( titlebar->geometry(), FALSE ) );
}
if ( e->oldSize().height() != height() ) {
int dy = 8 + QABS( e->oldSize().height() - height() );
update( 0, height() - dy + 1, width(), dy );
}
}