[DesktopView] Move cancelling showing desktop into keyPressEvent

This will route the event through the containment first which can then intercept it, e.g. to prevent
Escape from exiting showing desktop while renaming where it should only cancel that.

CCBUG: 352988

Differential Revision: https://phabricator.kde.org/D7630
wilder-5.14
Kai Uwe Broulik 9 years ago
parent 3257f5f923
commit 55d74c6821
  1. 24
      shell/desktopview.cpp

@ -197,15 +197,7 @@ DesktopView::SessionType DesktopView::sessionType() const
bool DesktopView::event(QEvent *e)
{
if (e->type() == QEvent::KeyRelease) {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if (KWindowSystem::showingDesktop() && ke->key() == Qt::Key_Escape) {
ShellCorona *c = qobject_cast<ShellCorona *>(corona());
if (c) {
KWindowSystem::setShowingDesktop(false);
}
}
} else if (e->type() == QEvent::PlatformSurface) {
if (e->type() == QEvent::PlatformSurface) {
if (auto pe = dynamic_cast<QPlatformSurfaceEvent*>(e)) {
switch (pe->surfaceEventType()) {
case QPlatformSurfaceEvent::SurfaceCreated:
@ -227,8 +219,18 @@ void DesktopView::keyPressEvent(QKeyEvent *e)
{
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 @@ void DesktopView::keyPressEvent(QKeyEvent *e)
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) {

Loading…
Cancel
Save