Bug 380391 - Titlebar height is not set properly after it is changed from empty string
Summary: Titlebar height is not set properly after it is changed from empty string
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-31 12:32 UTC by memidormid
Modified: 2017-06-06 16:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Sample Java code to reproduce the bug (814 bytes, text/x-java)
2017-05-31 12:32 UTC, memidormid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description memidormid 2017-05-31 12:32:47 UTC
Created attachment 105801 [details]
Sample Java code to reproduce the bug

Titlebar height of the windows are not set properly if the window is created with empty title initially and its title is changed later. This affects some applications including LibreOffice (if started maximized) and Spotify. To reproduce the bug follow these steps:

1. Open Libreoffice Writer, maximize the window and exit.
2. Go to System Settings > Font and set Window Title font size to a big value (like 20) and Apply.
3. Open Libreoffice Writer.

The titlebar is sized according to the window buttons (maximize, minimize, close etc.) only, so half of the window title is cropped. If the window is unmaximized after that, it is set properly.

This seems to happen when window is created with empty title and its title is changed later. Tested this with the attached Java code.

Screenshot (notice that the bottom of 'p' character is cropped):
https://www.kde.org/announcements/plasma-5.10/plymouth-kcm.png
Comment 1 Christoph Feck 2017-06-06 15:18:22 UTC
Hugo, could you check if this is a KWin or breeze decoration issue?
Comment 2 Hugo Pereira Da Costa 2017-06-06 15:34:03 UTC
Hi Christoph

Probably a breeze bug.
When we calculate the decoration borders we use: 
fm.boundingRect(c->caption()) (fm being fontMetrics)
So when caption is empty, this gives 0.
It is then not updated on caption change.
I guess I shoud just use fm.height()
(after all you do not want the size of the decoration to change depending on the caracters that appear in the caption !)
Comment 3 Hugo Pereira Da Costa 2017-06-06 15:47:38 UTC
Git commit 2cc0f8ba2da50ca3efa500ebdcc3655c8d0e47f8 by Hugo Pereira Da Costa.
Committed on 06/06/2017 at 15:47.
Pushed by hpereiradacosta into branch 'master'.

use fontMetrics.height() rather than boundingRect(...).height()
the height of the title bar should not depend on the caption content.

M  +1    -1    kdecoration/breezedecoration.cpp

https://commits.kde.org/breeze/2cc0f8ba2da50ca3efa500ebdcc3655c8d0e47f8
Comment 4 Hugo Pereira Da Costa 2017-06-06 16:05:03 UTC
Was able to test with the provided java code (thanks !)
Now fixed.
Will backport and also fix oxygen.
Thanks for reporting the issue

Hugo
Comment 5 Hugo Pereira Da Costa 2017-06-06 16:06:24 UTC
Git commit 4f0940b79001ae8b400d01a8abf63d03b8dbd9fc by Hugo Pereira Da Costa.
Committed on 06/06/2017 at 16:06.
Pushed by hpereiradacosta into branch 'Plasma/5.10'.

use fontMetrics.height() rather than boundingRect(...).height()
the height of the title bar should not depend on the caption content.

M  +1    -1    kdecoration/breezedecoration.cpp

https://commits.kde.org/breeze/4f0940b79001ae8b400d01a8abf63d03b8dbd9fc