[PATCH] Flicker less drawing
REGAT-BARREL Aurelien
arbvtk at yahoo.fr
Wed Dec 15 03:17:52 CET 2004
Hi,
In file qwidget_win.cpp, in function
void QWidget::repaint( int x, int y, int w, int h, bool erase )
lines 1547-1548
QPaintEvent e( r, erase );
if ( r != rect() )
qt_set_paintevent_clipping( this, r );
-> if ( erase )
-> this->erase( x, y, w, h );
QApplication::sendEvent( this, &e );
If erasing is needed, it is done with erase(). I dont know where but it seems to be done a second time in response to the QPaintEvent raised. So I removed this 2 lines:
if ( erase )
this->erase( x, y, w, h );
and it removed the flickering I saw on the application I am testing.
In file qapplication_win.cpp, lines 5653 & 5705, QWidget window class style is:
wcx.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
I always hated CS_HREDRAW and CS_VREDRAW styles. They cause entire window redrawing => background erasing + redrawing, which causes flickering. I removed this 2 styles. But, if the window size grows, then painting is needed.
So I modified
QETWidget::translateConfigEvent
line 4831:
if ( isVisible() ) {
QResizeEvent e( newSize, oldSize );
QApplication::sendSpontaneousEvent( this, &e );
-> this->repaint();
} else {
QResizeEvent * e = new QResizeEvent( newSize, oldSize );
QApplication::postEvent( this, e );
}
I added the repaint() call.
After that, there is less flickering. This is also true with the dirview example. But more testing is needed.
There is something strange : if you resize the window backwards / forwards horizontally OR vertically, it doesn't flicker. It you resize both horizontally and vertically (bottom right corner), it does. I think it is because the 2 resize events are not merged, but 2 events = 2 repaint() are received / called very shortly. I tried to batch the repaint() call with InvalidateRect / postEvent(), but it does nothing. But it is the same behaviour with Qt 2.3 NC. So, if the patch is approved, maybe the bug "[ 1060157 ] Unnecessary flicker during repaint" could be considered corrected.
Here are the diff output from my local CVS copy:
-----------------------------------8<----------------------------------------------
diff -r1.1.2.30.2.23 qapplication_win.cpp
4831a4832,4833
>
> this->repaint();
4835c4837
< }
---
> }
5653c5655
< wcx.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
---
> wcx.style = CS_DBLCLKS; // | CS_HREDRAW | CS_VREDRAW;
5705c5707
< wcx.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
---
> wcx.style = CS_DBLCLKS; // | CS_HREDRAW | CS_VREDRAW;
-----------------------------------8<----------------------------------------------
diff -r1.1.2.15.2.14 qwidget_win.cpp
1547,1548c1547,1548
< if ( erase )
< this->erase( x, y, w, h );
---
> //if ( erase )
> // this->erase( x, y, w, h );
-----------------------------------8<----------------------------------------------
Regards.
Aurelien REGAT-BARREL
---------------------------------
Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Créez votre Yahoo! Mail
Avec Yahoo! faites un don et soutenez le Téléthon !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-cygwin/attachments/20041215/4b0a03a0/attachment.html
More information about the kde-cygwin
mailing list