Commit 25f49b72 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Tomaz Canabrava
Browse files

Support XdgActivation for focus from notification

To support focusing a session from a notification in Wayland, we need to
use the XdgActivation protocol.  This is done by passing to
KWindowSystem an XDG activation token that we get from the notification.
parent 8fb68993
Pipeline #200077 passed with stage
in 2 minutes and 8 seconds
......@@ -154,8 +154,9 @@ void MainWindow::updateUseTransparency()
WindowSystemInfo::HAVE_TRANSPARENCY = useTranslucency;
}
void MainWindow::activationRequest()
void MainWindow::activationRequest(const QString &xdgActivationToken)
{
KWindowSystem::setCurrentXdgActivationToken(xdgActivationToken);
KWindowSystem::forceActiveWindow(winId());
}
......
......@@ -170,7 +170,7 @@ private Q_SLOTS:
void applyKonsoleSettings();
// Ask the window manager to show this application window
void activationRequest();
void activationRequest(const QString &xdgActivationToken);
void updateUseTransparency();
......
......@@ -234,7 +234,7 @@ Q_SIGNALS:
/** Requests creation of a new view, with the selected profile. */
void newViewWithProfileRequest(const QExplicitlySharedDataPointer<Profile> &profile);
void activationRequest();
void activationRequest(const QString &xdgActivationToken);
public Q_SLOTS:
/** DBus slot that returns the number of sessions in the current view. */
......
......@@ -628,7 +628,9 @@ void Session::silenceTimerDone()
view,
KNotification::CloseWhenWidgetActivated);
notification->setDefaultAction(i18n("Show session"));
view->connect(notification, &KNotification::defaultActivated, view, &TerminalDisplay::notificationClicked);
connect(notification, &KNotification::defaultActivated, this, [view, notification]() {
view->notificationClicked(notification->xdgActivationToken());
});
setPendingNotification(Notification::Silence);
}
......@@ -1786,7 +1788,9 @@ void Session::handleActivity()
view,
KNotification::CloseWhenWidgetActivated);
notification->setDefaultAction(i18n("Show session"));
view->connect(notification, &KNotification::defaultActivated, view, &TerminalDisplay::notificationClicked);
connect(notification, &KNotification::defaultActivated, this, [view, notification]() {
view->notificationClicked(notification->xdgActivationToken());
});
// mask activity notification for a while to avoid flooding
_notifiedActivity = true;
......
......@@ -358,7 +358,9 @@ void SessionController::snapshot()
view(),
KNotification::CloseWhenWidgetActivated);
notification->setDefaultAction(i18n("Show session"));
view()->connect(notification, &KNotification::defaultActivated, view(), &TerminalDisplay::notificationClicked);
connect(notification, &KNotification::defaultActivated, this, [this, notification]() {
view()->notificationClicked(notification->xdgActivationToken());
});
}
_previousForegroundProcessName = isForegroundProcessActive ? session()->foregroundProcessName() : QString();
}
......
......@@ -41,7 +41,9 @@ void TerminalBell::bell(TerminalDisplay *terminalDisplay, const QString &message
KNotification *notification =
KNotification::event(terminalHasFocus ? QStringLiteral("BellVisible") : QStringLiteral("BellInvisible"), message, QPixmap(), terminalDisplay);
notification->setDefaultAction(i18n("Show session"));
terminalDisplay->connect(notification, &KNotification::defaultActivated, terminalDisplay, &TerminalDisplay::notificationClicked);
connect(notification, &KNotification::defaultActivated, this, [notification, terminalDisplay]() {
terminalDisplay->notificationClicked(notification->xdgActivationToken());
});
} break;
case Enum::VisualBell:
Q_EMIT visualBell();
......
......@@ -1909,9 +1909,9 @@ Screen::DecodingOptions TerminalDisplay::currentDecodingOptions()
return decodingOptions;
}
void TerminalDisplay::notificationClicked()
void TerminalDisplay::notificationClicked(const QString &xdgActivationToken)
{
Q_EMIT activationRequest();
Q_EMIT activationRequest(xdgActivationToken);
}
void TerminalDisplay::mouseTripleClickEvent(QMouseEvent *ev)
......
......@@ -449,7 +449,7 @@ public Q_SLOTS:
// Used for requestPrint
void printScreen();
void notificationClicked();
void notificationClicked(const QString &xdgActivationToken);
Q_SIGNALS:
void requestToggleExpansion();
......@@ -489,7 +489,7 @@ Q_SIGNALS:
*/
void overrideShortcutCheck(QKeyEvent *keyEvent, bool &override);
void activationRequest();
void activationRequest(const QString &xdgActivationToken);
void sendStringToEmu(const QByteArray &local8BitString);
void compositeFocusChanged(bool focused);
......
......@@ -394,7 +394,7 @@ void TabbedViewContainer::forgetView()
}
}
void TabbedViewContainer::activateView()
void TabbedViewContainer::activateView(const QString & /*xdgActivationToken*/)
{
if (QWidget *widget = qobject_cast<QWidget *>(sender())) {
auto topLevelSplitter = qobject_cast<ViewSplitter *>(widget->parentWidget())->getToplevelSplitter();
......
......@@ -213,7 +213,7 @@ protected:
private Q_SLOTS:
void viewDestroyed(QObject *view);
void konsoleConfigChanged();
void activateView();
void activateView(const QString &xdgActivationToken);
private:
void forgetView();
......
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