From 53105e6c983105b6cfa866c9bdc2c19aab8cb9b5 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Wed, 8 Apr 2026 00:57:04 +0300
Subject: kcharselect: do redraws from the event loop

This enhances interface responsiveness when there are frequent user
input interleaved with repaints of the widget and fixes an issue with
side areas being not repainted noticed in the comments to
TDE/tdelibsi#396.

This requires additional changes to tqt (see TDE/tqt#278).

See-also: https://mirror.git.trinitydesktop.org/gitea/TDE/tdelibs/pulls/396#issuecomment-85309
See-also: https://mirror.git.trinitydesktop.org/gitea/TDE/tqt/pulls/278
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 tdeui/kcharselect.cpp | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/tdeui/kcharselect.cpp b/tdeui/kcharselect.cpp
index 20b4cbaca..2fd73e7d9 100644
--- a/tdeui/kcharselect.cpp
+++ b/tdeui/kcharselect.cpp
@@ -125,24 +125,23 @@ private:
 //==================================================================
 KCharSelectTable::KCharSelectTable( TQWidget *parent, const char *name, const TQString &_font,
 				    const TQChar &_chr, int _tableNum )
-    : TQGridView( parent, name ), vFont( _font ), vChr( _chr ),
+    : TQGridView( parent, name, TQt::WNoAutoErase ), vFont( _font ), vChr( _chr ),
       vTableNum( _tableNum ), vPos( 0, 0 ), focusItem( _chr ), focusPos( 0, 0 ),
       d(new KCharSelectTable::KCharSelectTablePrivate)
 {
-    setBackgroundColor( colorGroup().base() );
-
+    // Note: when updating we are completely overpainting the widget to
+    //       avoid flickering, hence we use TQt::WNoAutoErase.
     setCellWidth( 20 );
     setCellHeight( 25 );
 
     setNumCols( 32 );
     setNumRows( 8 );
 
-    repaintContents( false );
+    updateContents();
 
     d->t = new KCharSelectTableToolTip(this);
 
     setFocusPolicy( TQWidget::StrongFocus );
-    setBackgroundMode( TQWidget::NoBackground );
 }
 
 KCharSelectTable::~KCharSelectTable () {
@@ -156,7 +155,7 @@ void KCharSelectTable::setFont( const TQString &_font )
     if(_font == vFont)
        return;
     vFont = _font;
-    repaintContents( false );
+    updateContents();
 }
 
 //==================================================================
@@ -165,7 +164,7 @@ void KCharSelectTable::setChar( const TQChar &_chr )
     if(_chr == vChr)
        return;
     vChr = _chr;
-    repaintContents( false );
+    updateContents();
 }
 
 //==================================================================
@@ -176,7 +175,7 @@ void KCharSelectTable::setTableNum( int _tableNum )
     focusItem = TQChar( _tableNum * 256 );
 
     vTableNum = _tableNum;
-    repaintContents( false );
+    updateContents();
 
     emit tableNumChanged(vTableNum);
 }
@@ -306,9 +305,9 @@ void KCharSelectTable::contentsMouseMoveEvent( TQMouseEvent *e )
 	focusPos = vPos;
 	focusItem = vChr;
 
-	repaintCell( oldFocus.y(), oldFocus.x(), true );
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( vPos.y(), vPos.x(), true );
+	updateCell( oldFocus.y(), oldFocus.x() );
+	updateCell( oldPos.y(),   oldPos.x()   );
+	updateCell( vPos.y(),     vPos.x()     );
 
 	emit highlighted( vChr );
 	emit highlighted();
@@ -360,8 +359,8 @@ void KCharSelectTable::keyPressEvent( TQKeyEvent *e )
 	vPos = focusPos;
 	vChr = focusItem;
 
-	repaintCell( oldPos.y(), oldPos.x(), true );
-	repaintCell( vPos.y(), vPos.x(), true );
+	updateCell( oldPos.y(), oldPos.x() );
+	updateCell( vPos.y(),   vPos.x()   );
 
 	emit activated( vChr );
 	emit activated();
@@ -418,8 +417,8 @@ void KCharSelectTable::doGoto(int dx, int dy)
     focusPos += TQPoint(dx, dy);
     focusItem = charAt( focusPos.y(), focusPos.x() );
 
-    repaintCell( oldPos.y(), oldPos.x(), true );
-    repaintCell( focusPos.y(), focusPos.x(), true );
+    updateCell( oldPos.y(),   oldPos.x()   );
+    updateCell( focusPos.y(), focusPos.x() );
 
     emit focusItemChanged( vChr );
     emit focusItemChanged();
-- 
cgit v1.2.3

