[Konsole-devel] [PATCH] Get rid of excessive repaints when resizing a konsole part
Andreas Kling
kling at impul.se
Sat Jul 1 15:31:58 UTC 2006
...and a few minutes later, I found bug #54230. Submitting the patch to
that bug now.
Andreas Kling wrote:
> Greetings, gentle folks.
>
> When resizing a konsole part, there is a lot of flickering, especially
> noticeable with text in the terminal. This is because the TEWidget is
> cleared with the background color before each repaint.
>
> I hacked up a patch to make it use the WNoAutoErase QWidget flag and
> just draw the necessary parts once, and I've been running it for a while
> without problems.
>
> So the time has come for you guys to take a look. Please see the
> included diff against konsole (3.5 branch) in SVN.
>
> Best regards,
> Andreas Kling
>
> ------------------------------------------------------------------------
>
> Index: TEWidget.cpp
> ===================================================================
> --- TEWidget.cpp (revision 556756)
> +++ TEWidget.cpp (working copy)
> @@ -316,7 +316,7 @@ void TEWidget::setFont(const QFont &)
> /* ------------------------------------------------------------------------- */
>
> TEWidget::TEWidget(QWidget *parent, const char *name)
> -:QFrame(parent,name)
> +:QFrame(parent,name,WNoAutoErase)
> ,font_h(1)
> ,font_w(1)
> ,font_a(1)
> @@ -982,6 +982,48 @@ void TEWidget::paintEvent( QPaintEvent*
> paintContents(paint, rect, pm != 0);
>
> drawFrame( &paint );
> +
> + // Since we're using WNoAutoErase, we have to make sure that
> + // every single pixel is painted by the paint event.
> + // To do this, we must figure out which pixels are left in the
> + // area between the terminal image and the frame border.
> +
> + // Calculate the contents rect excluding scroll bar.
> + QRect innerRect = contentsRect();
> + if( scrollLoc != SCRNONE )
> + innerRect.setWidth( innerRect.width() - scrollbar->width() );
> +
> + innerRect.setWidth( innerRect.width() + 3 );
> + innerRect.setHeight( innerRect.height() );
> +
> + // Calculate the emulation rect (area needed for actual terminal contents)
> + QRect emurect( contentsRect().topLeft(), QSize( columns * font_w + 2 * rimX, lines * font_h + 2 * rimY ));
> +
> + // Now erase() the remaining pixels on all sides of the emulation
> +
> + // Top
> + QRect er( innerRect );
> + er.setBottom( emurect.top() );
> + erase( er );
> +
> + // Bottom
> + er.setBottom( innerRect.bottom() );
> + er.setTop( emurect.bottom() );
> + erase( er );
> +
> + // Left
> + er.setTop( emurect.top() );
> + er.setBottom( emurect.bottom() - 1 );
> + er.setRight( emurect.left() );
> + erase( er );
> +
> + // Right
> + er.setRight( innerRect.right() );
> + er.setTop( emurect.top() );
> + er.setBottom( emurect.bottom() - 1 );
> + er.setLeft( emurect.right() );
> + erase( er );
> +
> paint.end();
> setUpdatesEnabled(true);
> }
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> konsole-devel mailing list
> konsole-devel at kde.org
> https://mail.kde.org/mailman/listinfo/konsole-devel
>
More information about the konsole-devel
mailing list