Bug 224033

Summary: Background image redrawing issues on scroll
Product: [Applications] konversation Reporter: Pascal Bakhuis <pBakhuis>
Component: generalAssignee: Konversation Developers <konversation-devel>
Status: RESOLVED FIXED    
Severity: normal CC: b.buschinski, hein
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot of Konversation redrawing issue.

Description Pascal Bakhuis 2010-01-24 14:01:46 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

When scrolling, or simply when a new message comes (causing the window to scroll automatically) and a background image is set it doesn't redraw the entire window.
I'll attach a screenshot of the issue in a comment on this bug report as it's easier to just see it rather than explain it.

Don't know if it's of any help, but I have this issue using the NVIDIA driver, 190.53. (NVIDIA 9600M GT videocard)
Comment 1 Pascal Bakhuis 2010-01-24 14:03:01 UTC
Created attachment 40195 [details]
Screenshot of Konversation redrawing issue.
Comment 2 Eike Hein 2010-01-24 16:51:05 UTC
We really need your KDE and Qt version numbers as well, since we don't control the background image drawing ourselves - it's a Qt widget. So the bug is unlikely to be ours and might be specific to a particular Qt version (it doesn't happen here).
Comment 3 Eike Hein 2010-01-24 16:51:56 UTC
(I have KDE 4.4rc1 on Qt 4.6.1, fwiw.)
Comment 4 Pascal Bakhuis 2010-01-24 23:39:22 UTC
KDE 4.3.95 (KDE 4.4 RC2) "Release 214" and Qt 4.6.1-86.1

Packages from: http://download.opensuse.org/repositories/KDE:/KDE4:/Factory:/Desktop/openSUSE_11.2/x86_64/
I've had the same thing happen under KDE 4.5 however
Comment 5 Bernd Buschinski 2010-09-10 14:23:22 UTC
commit c0491dc653337f7b40a8e4cb88835e745fde7968
Author: Bernd Buschinski <b.buschinski@web.de>
Date:   Fri Sep 10 14:08:58 2010 +0200

    Set backgroundimage with Qt Style Sheets as they seems
    to be more eager in repainting the whole image
    as the QPalette background brush.
    Tested on my intel-gfx laptop with current git drivers
    (where it always happened) and on my desktop gf8800gt
    with nvidia-260.19.04(where it only happens with my test login).
    BUG:224033

diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cpp
index 6cecaa1..90c2bf6 100644
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -557,25 +557,19 @@ void IRCView::updateAppearance()
 
     setVerticalScrollBarPolicy(Preferences::self()->showIRCViewScrollBar() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
 
-    QPalette p;
-
-    p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground));
-
     if (Preferences::self()->showBackgroundImage())
     {
         KUrl url = Preferences::self()->backgroundImage();
 
         if (!url.isEmpty())
         {
-            QBrush brush;
-
-            brush.setTexture(QPixmap(url.path()));
-
-            p.setBrush(QPalette::Base, brush);
+            setStyleSheet("QTextBrowser { background-image: url("+url.path()+");background-attachment: fixed }");
         }
     }
-
-    setPalette(p);
+    else
+    {
+        setStyleSheet("QTextBrowser { background-color:" + Preferences::self()->color(Preferences::TextViewBackground).name() + " }");
+    }
 }
 
 // Data insertion
Comment 6 Bernd Buschinski 2010-09-10 16:47:37 UTC
commit c5da3e3f4e8c527f7e77aa4abef7eabbacfe4158
Author: Bernd Buschinski <b.buschinski@web.de>
Date:   Fri Sep 10 16:47:33 2010 +0200

    Revert Qt Style Sheet solution, as it breaks scrollbar drawing
    CCBUG:224033

diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cpp
index 4d55bd8..33bf88b 100644
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -557,28 +557,24 @@ void IRCView::updateAppearance()
 
     setVerticalScrollBarPolicy(Preferences::self()->showIRCViewScrollBar() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
 
-    bool bgImageSet = false;
+    QPalette p;
+
+    p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground));
+
     if (Preferences::self()->showBackgroundImage())
     {
         KUrl url = Preferences::self()->backgroundImage();
 
         if (!url.isEmpty())
         {
-            setStyleSheet("QTextBrowser { background-image: url("+url.path()+");background-attachment: fixed }");
-            bgImageSet = true;
-        }
-    }
+            QBrush brush;
 
-    if (!bgImageSet)
-    {
-        if (!styleSheet().isEmpty())
-        {
-            setStyleSheet("");
+            brush.setTexture(QPixmap(url.path()));
+
+            p.setBrush(QPalette::Base, brush);
         }
-        QPalette p;
-        p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground));
-        setPalette(p);
     }
+    setPalette(p);
 }
 
 // Data insertion
Comment 7 Eike Hein 2010-09-11 09:02:34 UTC
commit 01e0349a8e6ee2d1ed6bfa81daaaa5ecdb77f7b4
Author: Eike Hein <hein@kde.org>
Date:   Sat Sep 11 09:06:06 2010 +0200

    Rejig ircview background image code.
    
    Back to the stylesheet approach, but set it only on the
    viewport. Plus better sanity checking on the wallpaper
    path.
    
    BUG:224033

diff --git a/ChangeLog b/ChangeLog
index dcf085d..82861d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -184,6 +184,8 @@ Changes since 1.3.1:
   the connection status tab before the "Looking for server" message if the
   DNS response was already cached.
 * Added support for the 475 numeric (ERR_BADCHANNELKEY).
+* Rewrote chat text view wallpaper image support to avoid rendering pro-
+  blems some users were experiencing.
 
 
 Changes from 1.3 to 1.3.1:
diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cpp
index 33bf88b..5928ce6 100644
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -557,26 +557,27 @@ void IRCView::updateAppearance()
 
     setVerticalScrollBarPolicy(Preferences::self()->showIRCViewScrollBar() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
 
-    QPalette p;
-
-    p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground));
-
     if (Preferences::self()->showBackgroundImage())
     {
         KUrl url = Preferences::self()->backgroundImage();
 
-        if (!url.isEmpty())
+        if (url.hasPath())
         {
-            QBrush brush;
-
-            brush.setTexture(QPixmap(url.path()));
+            viewport()->setStyleSheet("QWidget { background-image: url("+url.path()+"); background-attachment:fixed; }");
 
-            p.setBrush(QPalette::Base, brush);
+            return;
         }
     }
+
+    if (!viewport()->styleSheet().isEmpty())
+        viewport()->setStyleSheet("");
+
+    QPalette p;
+    p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground));
     setPalette(p);
 }
 
+
 // Data insertion
 
 void IRCView::append(const QString& nick, const QString& message)