Bug 477800 - konsole does not use background images if opacity is not supported
Summary: konsole does not use background images if opacity is not supported
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 24.01.80
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords: reproducible
Depends on:
Blocks:
 
Reported: 2023-11-30 21:10 UTC by R Tapia
Modified: 2023-12-16 23:56 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R Tapia 2023-11-30 21:10:11 UTC
SUMMARY
***
I'm running Rocky Linux 9. My window manager is FVWM3. I have background images configured, but konsole displays a blank (black) background.
***

STEPS TO REPRODUCE
1. Under Rocky Linux 9 with FVWM3 as a window manager, run konsole. 
2. Configure a background in a profile.
3. Run konsole using that profile.

OBSERVED RESULT

Konsole's background is blank (black).

EXPECTED RESULT

Konsole's background is the image that was configured.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Rocky 9 - 9.3 (Blue Onyx) - Linux 5.14.0-362.8.1.el9_3.x86_64
(available in About System)
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION

I can make konsole behave normally (the way that I expect) by reverting the following change:

```
git diff 57c9a6856439926972f217f61ad4a4e23ebbe0cc 1e611bd45870c0f094a480610633ec85f1f330a2
diff --git a/src/Part.cpp b/src/Part.cpp
index 4a7cb601b..88ddfa3d1 100644
--- a/src/Part.cpp
+++ b/src/Part.cpp
@@ -60,8 +60,10 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &)
         action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
     }

-    // Enable translucency support.
-    _viewManager->widget()->setAttribute(Qt::WA_TranslucentBackground, true);
+    // Enable translucency support if supported by the app.
+    if (_viewManager->widget()->window() && _viewManager->widget()->window()->testAttribute(Qt::WA_TranslucentBackground)) {
+        _viewManager->widget()->setAttribute(Qt::WA_TranslucentBackground, true);
+    }

     // create basic session
     createSession();
diff --git a/src/terminalDisplay/TerminalDisplay.cpp b/src/terminalDisplay/TerminalDisplay.cpp
index a685e9d68..794e4ff68 100644
--- a/src/terminalDisplay/TerminalDisplay.cpp
+++ b/src/terminalDisplay/TerminalDisplay.cpp
@@ -697,7 +697,11 @@ void TerminalDisplay::paintEvent(QPaintEvent *pe)

     for (const QRect &rect : region) {
         dirtyImageRegion += widgetToImage(rect);
-        _terminalPainter->drawBackground(paint, rect, _terminalColor->backgroundColor(), true /* use opacity setting */);
+        // We can use the opacity settings only if we are in a top level window which actually supports opacity.
+        // Many apps that use a konsole part such as kate or dolphin don't for performance reasons.
+        // This will result in repaint glitches iin wayland due to missing damage information
+        const bool useOpacity = window() && window()->testAttribute(Qt::WA_TranslucentBackground);
+        _terminalPainter->drawBackground(paint, rect, _terminalColor->backgroundColor(), useOpacity);
     }

     if (_displayVerticalLine) {
```
I have no interest in transparency. I think that this two line "fix" needs to be reverted and replaced with something a little more nuanced. It seems that whether or not background images are displayed is orthogonal to whether or not an application supports transparency.
Comment 1 Bug Janitor Service 2023-12-01 01:35:21 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/933
Comment 2 Kurt Hindenburg 2023-12-16 23:56:55 UTC
Git commit 8939910b61f2b9fd035a9bf9292dcdbda7ef17eb by Kurt Hindenburg, on behalf of Luis Javier Merino Morán.
Committed on 16/12/2023 at 18:25.
Pushed by hindenburg into branch 'master'.

Show wallpaper on non-translucent top-levels

For reasons, showing the background image (wallpaper) has become
dependant on the ability of the top-level window to be translucent.

This does not need to be so.  Since 5bac30ab3, to draw the wallpaper,
first a background color is used to fill the dirty region, and then the
wallpaper is drawn, and the opacity of the background color and the
wallpaper are separate, so we can fill with a totally opaque background
color, and then draw a maybe translucent wallpaper over that, and no
glitches should appear.
Related: bug 312843, bug 157882

M  +2    -2    src/terminalDisplay/TerminalPainter.cpp

https://invent.kde.org/utilities/konsole/-/commit/8939910b61f2b9fd035a9bf9292dcdbda7ef17eb