mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +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
@@ -7,6 +7,7 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/context/contextapplicationproxy.h"
|
||||
#include "blackmisc/dbus.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
@@ -38,6 +39,8 @@ namespace BlackCore
|
||||
}
|
||||
});
|
||||
|
||||
connect(this, &CContextApplicationProxy::remoteHotkeyAction, this, &CContextApplicationProxy::processRemoteHotkeyActionCall);
|
||||
|
||||
m_pingTimer.setObjectName(serviceName + "::m_pingTimer");
|
||||
connect(&m_pingTimer, &QTimer::timeout, this, &CContextApplicationProxy::reRegisterApplications);
|
||||
m_pingTimer.start(PingIdentifiersMs);
|
||||
@@ -158,9 +161,9 @@ namespace BlackCore
|
||||
m_dBusInterface->callDBus(QLatin1String("registerHotkeyActions"), actions, origin);
|
||||
}
|
||||
|
||||
void CContextApplicationProxy::callHotkeyAction(const QString &action, bool argument, const CIdentifier &origin)
|
||||
void CContextApplicationProxy::callHotkeyActionRemotely(const QString &action, bool argument, const CIdentifier &origin)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1String("callHotkeyAction"), action, argument, origin);
|
||||
m_dBusInterface->callDBus(QLatin1String("callHotkeyActionRemotely"), action, argument, origin);
|
||||
}
|
||||
|
||||
CIdentifier CContextApplicationProxy::registerApplication(const CIdentifier &application)
|
||||
@@ -243,5 +246,12 @@ namespace BlackCore
|
||||
CDBusServer::disconnectFromDBus(connection, dBusAddress);
|
||||
return ok;
|
||||
}
|
||||
|
||||
void CContextApplicationProxy::processRemoteHotkeyActionCall(const QString &action, bool argument, const BlackMisc::CIdentifier &origin)
|
||||
{
|
||||
if (origin.isFromLocalMachine()) { return; }
|
||||
sApp->getInputManager()->callFunctionsBy(action, argument);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << "Calling function" << action << "from origin" << origin.getMachineName();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user