diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -27,6 +27,7 @@ #include +#include #include @@ -142,7 +143,6 @@ void firstRunDialogFinished(); void firstRunDialogOk(); - private: void setupActions(); @@ -205,6 +205,11 @@ void initWayland(); KWayland::Client::PlasmaShell *m_plasmaShell; #endif + + // Previously-focused widget. + // Workaround for a terminal focus issue when toggling + // window state using the hotkey when compositing is enabled. + QPointer m_previouslyFocusedWidget; }; #endif diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -1059,6 +1059,10 @@ void MainWindow::toggleWindowState() { bool visible = isVisible(); + if (visible) { + // Save the currently-focused widget for later. + m_previouslyFocusedWidget = this->focusWidget(); + } if (visible && KWindowSystem::activeWindow() != winId() && Settings::keepOpen()) { @@ -1130,6 +1134,12 @@ sharedAfterOpenWindow(); } } + + if (!visible && m_previouslyFocusedWidget) { + // Reset the widget focus. + m_previouslyFocusedWidget->setFocus(); + m_previouslyFocusedWidget.clear(); + } } #if HAVE_X11