From 2a155925719f7540373386e29c6a23a5c6021b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 31 Oct 2016 15:56:01 +0100 Subject: [PATCH] Simplify the window title passed in from the window system Summary: 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: https://phabricator.kde.org/D3215 --- autotests/integration/shell_client_test.cpp | 2 -- autotests/integration/x11_client_test.cpp | 2 -- client.cpp | 4 ++-- shell_client.cpp | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp index c6740d2ace..6aed3e385e 100644 --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -556,9 +556,7 @@ void TestShellClient::testCaptionSimplified() shellSurface->setTitle(origTitle); auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); - QEXPECT_FAIL("", "BUG 323798", Continue); QVERIFY(c->caption() != origTitle); - QEXPECT_FAIL("", "BUG 323798", Continue); QCOMPARE(c->caption(), origTitle.simplified()); } diff --git a/autotests/integration/x11_client_test.cpp b/autotests/integration/x11_client_test.cpp index 0ca060ca7e..f391b80d15 100644 --- a/autotests/integration/x11_client_test.cpp +++ b/autotests/integration/x11_client_test.cpp @@ -111,9 +111,7 @@ void X11ClientTest::testCaptionSimplified() Client *client = windowCreatedSpy.first().first().value(); QVERIFY(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 diff --git a/client.cpp b/client.cpp index 8ae4d9e172..ef51aa2fa3 100644 --- a/client.cpp +++ b/client.cpp @@ -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(); else - return KWindowSystem::readNameProperty(window(), XCB_ATOM_WM_NAME); + return KWindowSystem::readNameProperty(window(), XCB_ATOM_WM_NAME).simplified(); } // The list is taken from http://www.unicode.org/reports/tr9/ (#154840) diff --git a/shell_client.cpp b/shell_client.cpp index 8315725801..e41efb0a56 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -90,12 +90,12 @@ ShellClient::~ShellClient() = default; template 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(); } );