Commit 2a155925 authored by Martin Flöser's avatar Martin Flöser

Simplify the window title passed in from the window system

So far KWin used the window title provided from the window directly
without any sanitizing. This could result in broken window decorations
if the title included line breaks. Those were passed to the decoration
and depending on the way how the decoration renders the title, it could
result in visual breakage.

Having line breaks in a window title doesn't make sense. Given that KWin
now simplifies the title when copying it to it's own structure. This
also ensures that the title passed to e.g. task manager does not have
any line breaks on Wayland.

BUG: 323798
FIXED-IN: 5.8.4

Test Plan: Opened the web page in a nested KWin, properly rendered now.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision:
parent 3c637139
......@@ -556,9 +556,7 @@ void TestShellClient::testCaptionSimplified()
auto c = Test::renderAndWaitForShown(, QSize(100, 50), Qt::blue);
QEXPECT_FAIL("", "BUG 323798", Continue);
QVERIFY(c->caption() != origTitle);
QEXPECT_FAIL("", "BUG 323798", Continue);
QCOMPARE(c->caption(), origTitle.simplified());
......@@ -111,9 +111,7 @@ void X11ClientTest::testCaptionSimplified()
Client *client = windowCreatedSpy.first().first().value<Client*>();
QCOMPARE(client->window(), w);
QEXPECT_FAIL("", "BUG 323798", Continue);
QVERIFY(client->caption() != QString::fromUtf8(origTitle));
QEXPECT_FAIL("", "BUG 323798", Continue);
QCOMPARE(client->caption(), QString::fromUtf8(origTitle).simplified());
// and destroy the window again
......@@ -1417,9 +1417,9 @@ void Client::fetchName()
QString Client::readName() const
if (info->name() && info->name()[0] != '\0')
return QString::fromUtf8(info->name());
return QString::fromUtf8(info->name()).simplified();
return KWindowSystem::readNameProperty(window(), XCB_ATOM_WM_NAME);
return KWindowSystem::readNameProperty(window(), XCB_ATOM_WM_NAME).simplified();
// The list is taken from (#154840)
......@@ -90,12 +90,12 @@ ShellClient::~ShellClient() = default;
template <class T>
void ShellClient::initSurface(T *shellSurface)
m_caption = shellSurface->title();
m_caption = shellSurface->title().simplified();
connect(shellSurface, &T::titleChanged, this, &ShellClient::captionChanged);
connect(shellSurface, &T::destroyed, this, &ShellClient::destroyClient);
connect(shellSurface, &T::titleChanged, this,
[this] (const QString &s) {
m_caption = s;
m_caption = s.simplified();
emit captionChanged();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment