Commit 08455f29 authored by Martin Flöser's avatar Martin Flöser
Browse files

Ensure the QToolTip on the deocration does not steal key events

Summary:
BUG: 393253
FIXED-IN: 5.13.0

Test Plan: manual testing and new unit test

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12633
parent 04dab3de
......@@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/shell.h>
......@@ -78,6 +79,8 @@ private Q_SLOTS:
void testModifierScrollOpacity();
void testTouchEvents_data();
void testTouchEvents();
void testTooltipDoesntEatKeyEvents_data();
void testTooltipDoesntEatKeyEvents();
private:
AbstractClient *showWindow(Test::ShellSurfaceType type);
......@@ -834,6 +837,55 @@ void DecorationInputTest::testTouchEvents()
QCOMPARE(hoverLeaveSpy.count(), 1);
}
void DecorationInputTest::testTooltipDoesntEatKeyEvents_data()
{
QTest::addColumn<Test::ShellSurfaceType>("type");
QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell;
QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6;
}
void DecorationInputTest::testTooltipDoesntEatKeyEvents()
{
// this test verifies that a tooltip on the decoration does not steal key events
// BUG: 393253
// first create a keyboard
auto keyboard = Test::waylandSeat()->createKeyboard(Test::waylandSeat());
QVERIFY(keyboard);
QSignalSpy enteredSpy(keyboard, &KWayland::Client::Keyboard::entered);
QVERIFY(enteredSpy.isValid());
QFETCH(Test::ShellSurfaceType, type);
AbstractClient *c = showWindow(type);
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
QTRY_COMPARE(enteredSpy.count(), 1);
QSignalSpy keyEvent(keyboard, &KWayland::Client::Keyboard::keyChanged);
QVERIFY(keyEvent.isValid());
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
c->decoratedClient()->requestShowToolTip(QStringLiteral("test"));
// now we should get an internal window
QVERIFY(clientAddedSpy.wait());
ShellClient *internal = clientAddedSpy.first().first().value<ShellClient*>();
QVERIFY(internal->isInternal());
QVERIFY(internal->internalWindow()->flags().testFlag(Qt::ToolTip));
// now send a key
quint32 timestamp = 0;
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
c->decoratedClient()->requestHideToolTip();
Test::waitForWindowDestroyed(internal);
}
}
WAYLANDTEST_MAIN(KWin::DecorationInputTest)
......
......@@ -910,6 +910,9 @@ class InternalWindowEventFilter : public InputEventFilter {
if (w->property("outputOnly").toBool()) {
continue;
}
if (w->flags().testFlag(Qt::ToolTip)) {
continue;
}
found = w;
break;
}
......
Supports Markdown
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