diff --git a/shell/desktopview.cpp b/shell/desktopview.cpp --- a/shell/desktopview.cpp +++ b/shell/desktopview.cpp @@ -197,15 +197,7 @@ bool DesktopView::event(QEvent *e) { - if (e->type() == QEvent::KeyRelease) { - QKeyEvent *ke = static_cast(e); - if (KWindowSystem::showingDesktop() && ke->key() == Qt::Key_Escape) { - ShellCorona *c = qobject_cast(corona()); - if (c) { - KWindowSystem::setShowingDesktop(false); - } - } - } else if (e->type() == QEvent::PlatformSurface) { + if (e->type() == QEvent::PlatformSurface) { if (auto pe = dynamic_cast(e)) { switch (pe->surfaceEventType()) { case QPlatformSurfaceEvent::SurfaceCreated: @@ -227,8 +219,18 @@ { ContainmentView::keyPressEvent(e); + if (e->isAccepted()) { + return; + } + + if (e->key() == Qt::Key_Escape && KWindowSystem::showingDesktop()) { + KWindowSystem::setShowingDesktop(false); + e->accept(); + return; + } + // When a key is pressed on desktop when nothing else is active forward the key to krunner - if ((!e->modifiers() || e->modifiers() == Qt::ShiftModifier) && !e->isAccepted()) { + if (!e->modifiers() || e->modifiers() == Qt::ShiftModifier) { const QString text = e->text().trimmed(); if (!text.isEmpty() && text[0].isPrint()) { const QString interface(QStringLiteral("org.kde.krunner")); @@ -238,11 +240,11 @@ org::kde::krunner::App krunner(interface, QStringLiteral("/App"), QDBusConnection::sessionBus()); krunner.query(text); e->accept(); + return; } } } - void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { if (m_configView) {