Bug 473358

Summary: Bad repaint region for window caption leaves artifacts when text changes in tabletMode
Product: [Plasma] Breeze Reporter: ratijas <me>
Component: window decorationAssignee: Plasma Bugs List <plasma-bugs-null>
Status: REPORTED ---    
Severity: normal CC: kwin-bugs-null, nate, uhhadd
Priority: NOR    
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: glitches
window-title.qml

Description ratijas 2023-08-14 10:09:07 UTC
Created attachment 160944 [details]
glitches

SUMMARY

With Tablet Mode (configurable in Workspace Behavior -> General Behavior -> Touch Mode) window decorations of Breeze become almost twice as large. However, when window caption text changes, it might leave a trail of artifacts due to bad repaint region not extending enough to the bottom.

STEPS TO REPRODUCE
1. Enable Touch Mode
2. Switch web browser tabs, or force change window caption text to change without resizing the window.
3. Resize the window.

OBSERVED RESULT
After step 2 you might get glitches artifacts as shown on the picture. After step 3 it should fully repaint and become normal.

EXPECTED RESULT
Text should repaint its full height.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10
Kernel Version: 6.4.10-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION

I use default AlignCenterFullWidth title alignment mode.

I *suspect* the offending code is in function Decoration::captionRect() or in Decoration::paintTitleBar which is the only client of captionRect. It could as well be Decoration::captionHeight() because it does not seem to be accounting for neither touch mode or font size.

It could also be a rounding error when converting QRectF::toRect()

>             QRect boundingRect(settings()->fontMetrics().boundingRect(c->caption()).toRect());

unlikely, however, because fontMetrics' height is disregarded in favor of captionHeight()
Comment 1 ratijas 2023-08-14 10:11:17 UTC
Created attachment 160945 [details]
window-title.qml

Simple QML snippet to help reproduce the issue. Literally just a QtQuick/Window with a title bound to TextInput's text.