Refactor the remote hotkeys to avoid round trips

The previous implementation was hard to follow and maintain. Instead of
doing intentional rounds trips, we use now a two way approach. GUI is
automatically forwarding remote actions by calling "callHotkeyActionRemotely"
through DBus. Core on the other hand, emits a signal "remoteHotkeyAction"
that is processed in a different function in GUI.
On both sides, actions from the same local machine are filtered.

ref T402
This commit is contained in:
Roland Winklmeier
2018-10-16 17:17:43 +02:00
committed by Klaus Basan
parent 9bb75a6f2e
commit 1addcf631a
9 changed files with 38 additions and 24 deletions

View File

@@ -131,10 +131,22 @@ namespace BlackCore
emit this->hotkeyActionsRegistered(actions, origin);
}
void CContextApplication::callHotkeyAction(const QString &action, bool argument, const CIdentifier &origin)
void CContextApplication::callHotkeyActionRemotely(const QString &action, bool argument, const CIdentifier &origin)
{
// Intentionally don't check for round trip here
emit this->remoteHotkeyAction(action, argument, origin);
if (origin.hasApplicationProcessId())
{
// If it originated from this process, then we are going to emit a signal
emit this->remoteHotkeyAction(action, argument, origin);
}
else
{
// action came from a different process but on the same machine. Ignore
if (origin.isFromLocalMachine()) { return; }
// Different process and different machine. Process it.
// However, it should not emit a remote action itself.
sApp->getInputManager()->callFunctionsBy(action, argument, false);
}
}
bool CContextApplication::writeToFile(const QString &fileName, const QString &content)