mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
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:
committed by
Klaus Basan
parent
9bb75a6f2e
commit
1addcf631a
@@ -112,23 +112,13 @@ namespace BlackCore
|
||||
s = connect(sApp->getInputManager(), &CInputManager::remoteActionFromLocal, this, [ = ](const QString & action, bool argument)
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->callHotkeyAction(action, argument, {});
|
||||
this->callHotkeyActionRemotely(action, argument, {});
|
||||
},
|
||||
Qt::QueuedConnection);
|
||||
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect remote action failed");
|
||||
Q_UNUSED(s);
|
||||
|
||||
s = connect(this, &IContextApplication::remoteHotkeyAction, [ = ](const QString & action, bool argument, const CIdentifier & origin)
|
||||
{
|
||||
if (!myself) { return; }
|
||||
if (origin.isFromLocalMachine()) { return; }
|
||||
sApp->getInputManager()->callFunctionsBy(action, argument);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << "Calling function" << action << "from origin" << origin.getMachineName();
|
||||
});
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect remote hotkey action failed");
|
||||
Q_UNUSED(s);
|
||||
|
||||
// Enable event forwarding from GUI process to core
|
||||
sApp->getInputManager()->setForwarding(true);
|
||||
}
|
||||
@@ -158,7 +148,7 @@ namespace BlackCore
|
||||
qFatal("Not implemented"); // avoid losing a change during context interface construction
|
||||
}
|
||||
|
||||
void IContextApplication::callHotkeyAction(const QString &action, bool argument, const CIdentifier &origin)
|
||||
void IContextApplication::callHotkeyActionRemotely(const QString &action, bool argument, const CIdentifier &origin)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(argument);
|
||||
|
||||
Reference in New Issue
Block a user