@ -33,7 +33,6 @@ add_library(base STATIC
|
||||
Stopwatch.h
|
||||
String.cpp
|
||||
String.h
|
||||
TMethodEventJob.h
|
||||
TMethodJob.h
|
||||
Unicode.cpp
|
||||
Unicode.h
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -8,7 +9,6 @@
|
||||
#include "base/EventQueue.h"
|
||||
|
||||
#include "arch/Arch.h"
|
||||
#include "base/IEventJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/SimpleEventQueueBuffer.h"
|
||||
#include "mt/Lock.h"
|
||||
@ -159,12 +159,12 @@ bool EventQueue::getEvent(Event &event, double timeout)
|
||||
bool EventQueue::dispatchEvent(const Event &event)
|
||||
{
|
||||
void *target = event.getTarget();
|
||||
IEventJob *job = getHandler(event.getType(), target);
|
||||
if (job == nullptr) {
|
||||
job = getHandler(EventTypes::Unknown, target);
|
||||
if (const auto *type_handler = getHandler(event.getType(), target); type_handler) {
|
||||
(*type_handler)(event);
|
||||
return true;
|
||||
}
|
||||
if (job != nullptr) {
|
||||
job->run(event);
|
||||
if (const auto *any_handler = getHandler(EventTypes::Unknown, target); any_handler) {
|
||||
(*any_handler)(event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -257,46 +257,32 @@ void EventQueue::deleteTimer(EventQueueTimer *timer)
|
||||
m_buffer->deleteTimer(timer);
|
||||
}
|
||||
|
||||
void EventQueue::adoptHandler(EventTypes type, void *target, IEventJob *handler)
|
||||
void EventQueue::addHandler(EventTypes type, void *target, const EventHandler &handler)
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
m_handlers[target][type].reset(handler);
|
||||
m_handlers[target][type] = handler;
|
||||
}
|
||||
|
||||
void EventQueue::removeHandler(EventTypes type, void *target)
|
||||
{
|
||||
std::unique_ptr<IEventJob> handler;
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
TypeHandlerTable &typeHandlers = index->second;
|
||||
TypeHandlerTable::iterator index2 = typeHandlers.find(type);
|
||||
if (index2 != typeHandlers.end()) {
|
||||
handler = std::move(index2->second);
|
||||
typeHandlers.erase(index2);
|
||||
}
|
||||
std::scoped_lock lock{m_mutex};
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
TypeHandlerTable &typeHandlers = index->second;
|
||||
TypeHandlerTable::iterator index2 = typeHandlers.find(type);
|
||||
if (index2 != typeHandlers.end()) {
|
||||
typeHandlers.erase(index2);
|
||||
}
|
||||
}
|
||||
// handler is erased here. It is done outside of lock in order to avoid potential deadlock.
|
||||
}
|
||||
|
||||
void EventQueue::removeHandlers(void *target)
|
||||
{
|
||||
std::vector<std::unique_ptr<IEventJob>> handlers;
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
// copy to handlers array and clear table for target
|
||||
TypeHandlerTable &typeHandlers = index->second;
|
||||
for (auto &[key, value] : typeHandlers) {
|
||||
handlers.push_back(std::move(value));
|
||||
}
|
||||
typeHandlers.clear();
|
||||
}
|
||||
std::scoped_lock lock{m_mutex};
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
index->second.clear();
|
||||
}
|
||||
// handler is erased here. It is done outside of lock in order to avoid potential deadlock.
|
||||
}
|
||||
|
||||
bool EventQueue::isEmpty() const
|
||||
@ -304,14 +290,14 @@ bool EventQueue::isEmpty() const
|
||||
return (m_buffer->isEmpty() && getNextTimerTimeout() != 0.0);
|
||||
}
|
||||
|
||||
IEventJob *EventQueue::getHandler(EventTypes type, void *target) const
|
||||
const EventQueue::EventHandler *EventQueue::getHandler(EventTypes type, void *target) const
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
if (HandlerTable::const_iterator index = m_handlers.find(target); index != m_handlers.end()) {
|
||||
const TypeHandlerTable &typeHandlers = index->second;
|
||||
TypeHandlerTable::const_iterator index2 = typeHandlers.find(type);
|
||||
if (index2 != typeHandlers.end()) {
|
||||
return index2->second.get();
|
||||
return &index2->second;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -43,15 +44,15 @@ public:
|
||||
EventQueueTimer *newTimer(double duration, void *target) override;
|
||||
EventQueueTimer *newOneShotTimer(double duration, void *target) override;
|
||||
void deleteTimer(EventQueueTimer *) override;
|
||||
void adoptHandler(EventTypes type, void *target, IEventJob *handler) override;
|
||||
void addHandler(EventTypes type, void *target, const EventHandler &handler) override;
|
||||
void removeHandler(EventTypes type, void *target) override;
|
||||
void removeHandlers(void *target) override;
|
||||
bool isEmpty() const override;
|
||||
IEventJob *getHandler(EventTypes type, void *target) const override;
|
||||
void *getSystemTarget() override;
|
||||
void waitForReady() const override;
|
||||
|
||||
private:
|
||||
const EventHandler *getHandler(EventTypes type, void *target) const;
|
||||
uint32_t saveEvent(const Event &event);
|
||||
Event removeEvent(uint32_t eventID);
|
||||
bool hasTimerExpired(Event &event);
|
||||
@ -99,7 +100,7 @@ private:
|
||||
using TimerQueue = PriorityQueue<Timer>;
|
||||
using EventTable = std::map<uint32_t, Event>;
|
||||
using EventIDList = std::vector<uint32_t>;
|
||||
using TypeHandlerTable = std::map<EventTypes, std::unique_ptr<IEventJob>>;
|
||||
using TypeHandlerTable = std::map<EventTypes, EventHandler>;
|
||||
using HandlerTable = std::map<void *, TypeHandlerTable>;
|
||||
|
||||
int m_systemTarget = 0;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -10,9 +11,10 @@
|
||||
#include "base/Event.h"
|
||||
#include "base/EventTypes.h"
|
||||
#include "common/IInterface.h"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class IEventJob;
|
||||
class IEventQueueBuffer;
|
||||
|
||||
// Opaque type for timer info. This is defined by subclasses of
|
||||
@ -29,6 +31,7 @@ timers which generate events periodically.
|
||||
class IEventQueue : public IInterface
|
||||
{
|
||||
public:
|
||||
using EventHandler = std::function<void(const Event &)>;
|
||||
class TimerEvent
|
||||
{
|
||||
public:
|
||||
@ -64,6 +67,9 @@ public:
|
||||
/*!
|
||||
Looks up the dispatcher for the event's target and invokes it.
|
||||
Returns true iff a dispatcher exists for the target.
|
||||
|
||||
The caller must ensure that the target of the event is not removed by removeHandler() or
|
||||
removeHandlers().
|
||||
*/
|
||||
virtual bool dispatchEvent(const Event &event) = 0;
|
||||
|
||||
@ -119,7 +125,7 @@ public:
|
||||
of type \p type. If no such handler exists it will use the handler
|
||||
for \p target and type \p kUnknown if it exists.
|
||||
*/
|
||||
virtual void adoptHandler(EventTypes type, void *target, IEventJob *handler) = 0;
|
||||
virtual void addHandler(EventTypes type, void *target, const EventHandler &handler) = 0;
|
||||
|
||||
//! Unregister an event handler for an event type
|
||||
/*!
|
||||
@ -152,13 +158,6 @@ public:
|
||||
*/
|
||||
virtual bool isEmpty() const = 0;
|
||||
|
||||
//! Get an event handler
|
||||
/*!
|
||||
Finds and returns the event handler for the \p type, \p target pair
|
||||
if it exists, otherwise it returns nullptr.
|
||||
*/
|
||||
virtual IEventJob *getHandler(EventTypes type, void *target) const = 0;
|
||||
|
||||
//! Get the system event type target
|
||||
/*!
|
||||
Returns the target to use for dispatching \c EventTypes::System events.
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IEventJob.h"
|
||||
|
||||
//! Use a member function as an event job
|
||||
/*!
|
||||
An event job class that invokes a member function.
|
||||
*/
|
||||
template <class T> class TMethodEventJob : public IEventJob
|
||||
{
|
||||
public:
|
||||
//! run(event) invokes \c object->method(event, arg)
|
||||
TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg = nullptr);
|
||||
~TMethodEventJob() override = default;
|
||||
|
||||
// IJob overrides
|
||||
void run(const Event &) override;
|
||||
|
||||
private:
|
||||
T *m_object;
|
||||
void (T::*m_method)(const Event &, void *);
|
||||
void *m_arg;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline TMethodEventJob<T>::TMethodEventJob(T *object, void (T::*method)(const Event &, void *), void *arg)
|
||||
: m_object(object),
|
||||
m_method(method),
|
||||
m_arg(arg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
template <class T> inline void TMethodEventJob<T>::run(const Event &event)
|
||||
{
|
||||
if (m_object != nullptr) {
|
||||
(m_object->*m_method)(event, m_arg);
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,6 @@
|
||||
#include "arch/Arch.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "client/ServerProxy.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
@ -60,12 +59,8 @@ Client::Client(
|
||||
assert(m_screen != nullptr);
|
||||
|
||||
// register suspend/resume event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenSuspend, getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleSuspend)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenResume, getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleResume)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ScreenSuspend, getEventTarget(), [this](const auto &) { handleSuspend(); });
|
||||
m_events->addHandler(EventTypes::ScreenResume, getEventTarget(), [this](const auto &) { handleResume(); });
|
||||
|
||||
m_pHelloBack = std::make_unique<HelloBack>(std::make_shared<HelloBack::Deps>(
|
||||
[this]() {
|
||||
@ -395,51 +390,41 @@ void Client::setupConnecting()
|
||||
assert(m_stream != nullptr);
|
||||
|
||||
if (m_args.m_enableCrypto) {
|
||||
m_events->adoptHandler(
|
||||
EventTypes::DataSocketSecureConnected, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleConnected)
|
||||
);
|
||||
m_events->addHandler(EventTypes::DataSocketSecureConnected, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleConnected();
|
||||
});
|
||||
} else {
|
||||
m_events->adoptHandler(
|
||||
EventTypes::DataSocketConnected, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleConnected)
|
||||
);
|
||||
m_events->addHandler(EventTypes::DataSocketConnected, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleConnected();
|
||||
});
|
||||
}
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::DataSocketConnectionFailed, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleConnectionFailed)
|
||||
);
|
||||
m_events->addHandler(EventTypes::DataSocketConnectionFailed, m_stream->getEventTarget(), [this](const auto &e) {
|
||||
handleConnectionFailed(e);
|
||||
});
|
||||
}
|
||||
|
||||
void Client::setupConnection()
|
||||
{
|
||||
assert(m_stream != nullptr);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::SocketDisconnected, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleDisconnected)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputReady, m_stream->getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleHello)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputError, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleOutputError)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputShutdown, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleDisconnected)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputShutdown, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleDisconnected)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::SocketStopRetry, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<Client>(this, &Client::handleStopRetry)
|
||||
);
|
||||
m_events->addHandler(EventTypes::SocketDisconnected, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnected();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputReady, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleHello();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamOutputError, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleOutputError();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputShutdown, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnected();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamOutputShutdown, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnected();
|
||||
});
|
||||
m_events->addHandler(EventTypes::SocketStopRetry, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleStopRetry();
|
||||
});
|
||||
}
|
||||
|
||||
void Client::setupScreen()
|
||||
@ -448,19 +433,19 @@ void Client::setupScreen()
|
||||
|
||||
m_ready = false;
|
||||
m_server = new ServerProxy(this, m_stream, m_events);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenShapeChanged, getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleShapeChanged)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClipboardGrabbed, getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleClipboardGrabbed)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ScreenShapeChanged, getEventTarget(), [this](const auto &) {
|
||||
handleShapeChanged();
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClipboardGrabbed, getEventTarget(), [this](const auto &e) {
|
||||
handleClipboardGrabbed(e);
|
||||
});
|
||||
}
|
||||
|
||||
void Client::setupTimer()
|
||||
{
|
||||
assert(m_timer == nullptr);
|
||||
m_timer = m_events->newOneShotTimer(2.0, nullptr);
|
||||
m_events->adoptHandler(EventTypes::Timer, m_timer, new TMethodEventJob<Client>(this, &Client::handleConnectTimeout));
|
||||
m_events->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { handleConnectTimeout(); });
|
||||
}
|
||||
|
||||
void Client::cleanup()
|
||||
@ -522,7 +507,7 @@ void Client::cleanupStream()
|
||||
m_stream = nullptr;
|
||||
}
|
||||
|
||||
void Client::handleConnected(const Event &, void *)
|
||||
void Client::handleConnected()
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "connected, waiting for hello"));
|
||||
cleanupConnecting();
|
||||
@ -536,7 +521,7 @@ void Client::handleConnected(const Event &, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::handleConnectionFailed(const Event &event, void *)
|
||||
void Client::handleConnectionFailed(const Event &event)
|
||||
{
|
||||
auto *info = static_cast<IDataSocket::ConnectionFailedInfo *>(event.getData());
|
||||
|
||||
@ -548,7 +533,7 @@ void Client::handleConnectionFailed(const Event &event, void *)
|
||||
delete info;
|
||||
}
|
||||
|
||||
void Client::handleConnectTimeout(const Event &, void *)
|
||||
void Client::handleConnectTimeout()
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupConnecting();
|
||||
@ -558,7 +543,7 @@ void Client::handleConnectTimeout(const Event &, void *)
|
||||
sendConnectionFailedEvent("Timed out");
|
||||
}
|
||||
|
||||
void Client::handleOutputError(const Event &, void *)
|
||||
void Client::handleOutputError()
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupScreen();
|
||||
@ -567,7 +552,7 @@ void Client::handleOutputError(const Event &, void *)
|
||||
sendEvent(EventTypes::ClientDisconnected, nullptr);
|
||||
}
|
||||
|
||||
void Client::handleDisconnected(const Event &, void *)
|
||||
void Client::handleDisconnected()
|
||||
{
|
||||
cleanupTimer();
|
||||
cleanupScreen();
|
||||
@ -576,13 +561,13 @@ void Client::handleDisconnected(const Event &, void *)
|
||||
sendEvent(EventTypes::ClientDisconnected, nullptr);
|
||||
}
|
||||
|
||||
void Client::handleShapeChanged(const Event &, void *)
|
||||
void Client::handleShapeChanged()
|
||||
{
|
||||
LOG((CLOG_DEBUG "resolution changed"));
|
||||
m_server->onInfoChanged();
|
||||
}
|
||||
|
||||
void Client::handleClipboardGrabbed(const Event &event, void *)
|
||||
void Client::handleClipboardGrabbed(const Event &event)
|
||||
{
|
||||
if (!m_enableClipboard || (m_maximumClipboardSize == 0)) {
|
||||
return;
|
||||
@ -605,7 +590,7 @@ void Client::handleClipboardGrabbed(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::handleHello(const Event &, void *)
|
||||
void Client::handleHello()
|
||||
{
|
||||
m_pHelloBack->handleHello(m_stream, m_name);
|
||||
|
||||
@ -621,7 +606,7 @@ void Client::handleHello(const Event &, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::handleSuspend(const Event &, void *)
|
||||
void Client::handleSuspend()
|
||||
{
|
||||
if (!m_suspended) {
|
||||
LOG((CLOG_INFO "suspend"));
|
||||
@ -632,7 +617,7 @@ void Client::handleSuspend(const Event &, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::handleResume(const Event &, void *)
|
||||
void Client::handleResume()
|
||||
{
|
||||
if (m_suspended) {
|
||||
LOG((CLOG_INFO "resume"));
|
||||
@ -661,7 +646,7 @@ void Client::bindNetworkInterface(IDataSocket *socket) const
|
||||
}
|
||||
}
|
||||
|
||||
void Client::handleStopRetry(const Event &, void *)
|
||||
void Client::handleStopRetry()
|
||||
{
|
||||
m_args.m_restartable = false;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -168,17 +169,17 @@ private:
|
||||
void cleanupScreen();
|
||||
void cleanupTimer();
|
||||
void cleanupStream();
|
||||
void handleConnected(const Event &, void *);
|
||||
void handleConnectionFailed(const Event &, void *);
|
||||
void handleConnectTimeout(const Event &, void *);
|
||||
void handleOutputError(const Event &, void *);
|
||||
void handleDisconnected(const Event &, void *);
|
||||
void handleShapeChanged(const Event &, void *);
|
||||
void handleClipboardGrabbed(const Event &, void *);
|
||||
void handleHello(const Event &, void *);
|
||||
void handleSuspend(const Event &event, void *);
|
||||
void handleResume(const Event &event, void *);
|
||||
void handleStopRetry(const Event &, void *);
|
||||
void handleConnected();
|
||||
void handleConnectionFailed(const Event &event);
|
||||
void handleConnectTimeout();
|
||||
void handleOutputError();
|
||||
void handleDisconnected();
|
||||
void handleShapeChanged();
|
||||
void handleClipboardGrabbed(const Event &event);
|
||||
void handleHello();
|
||||
void handleSuspend();
|
||||
void handleResume();
|
||||
void handleStopRetry();
|
||||
void sendClipboardThread(void *);
|
||||
void bindNetworkInterface(IDataSocket *socket) const;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -9,7 +10,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/XBase.h"
|
||||
#include "client/Client.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
@ -44,15 +44,10 @@ ServerProxy::ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue
|
||||
m_modifierTranslationTable[id] = id;
|
||||
|
||||
// handle data on stream
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputReady, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ServerProxy>(this, &ServerProxy::handleData)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClipboardSending, this,
|
||||
new TMethodEventJob<ServerProxy>(this, &ServerProxy::handleClipboardSendingEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::StreamInputReady, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleData();
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { handleClipboardSendingEvent(e); });
|
||||
|
||||
// send heartbeat
|
||||
setKeepAliveRate(kKeepAliveRate);
|
||||
@ -73,10 +68,7 @@ void ServerProxy::resetKeepAliveAlarm()
|
||||
}
|
||||
if (m_keepAliveAlarm > 0.0) {
|
||||
m_keepAliveAlarmTimer = m_events->newOneShotTimer(m_keepAliveAlarm, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, m_keepAliveAlarmTimer,
|
||||
new TMethodEventJob<ServerProxy>(this, &ServerProxy::handleKeepAliveAlarm)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, m_keepAliveAlarmTimer, [this](const auto &) { handleKeepAliveAlarm(); });
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +78,7 @@ void ServerProxy::setKeepAliveRate(double rate)
|
||||
resetKeepAliveAlarm();
|
||||
}
|
||||
|
||||
void ServerProxy::handleData(const Event &, void *)
|
||||
void ServerProxy::handleData()
|
||||
{
|
||||
// handle messages until there are no more. first read message code.
|
||||
uint8_t code[4];
|
||||
@ -333,7 +325,7 @@ ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code)
|
||||
return kOkay;
|
||||
}
|
||||
|
||||
void ServerProxy::handleKeepAliveAlarm(const Event &, void *)
|
||||
void ServerProxy::handleKeepAliveAlarm()
|
||||
{
|
||||
LOG((CLOG_NOTE "server is dead"));
|
||||
m_client->disconnect("server is not responding");
|
||||
@ -813,7 +805,7 @@ void ServerProxy::infoAcknowledgment()
|
||||
m_ignoreMouse = false;
|
||||
}
|
||||
|
||||
void ServerProxy::handleClipboardSendingEvent(const Event &event, void *)
|
||||
void ServerProxy::handleClipboardSendingEvent(const Event &event)
|
||||
{
|
||||
ClipboardChunk::send(m_stream, event.getDataObject());
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -74,8 +75,8 @@ private:
|
||||
KeyModifierMask translateModifierMask(KeyModifierMask) const;
|
||||
|
||||
// event handlers
|
||||
void handleData(const Event &, void *);
|
||||
void handleKeepAliveAlarm(const Event &, void *);
|
||||
void handleData();
|
||||
void handleKeepAliveAlarm();
|
||||
|
||||
// message handlers
|
||||
void enter();
|
||||
@ -95,7 +96,7 @@ private:
|
||||
void setOptions();
|
||||
void queryInfo();
|
||||
void infoAcknowledgment();
|
||||
void handleClipboardSendingEvent(const Event &, void *);
|
||||
void handleClipboardSendingEvent(const Event &event);
|
||||
void secureInputNotification();
|
||||
void setServerLanguages();
|
||||
void setActiveServerLanguage(const std::string &language);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -11,7 +12,6 @@
|
||||
#include "base/Event.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "client/Client.h"
|
||||
#include "common/Constants.h"
|
||||
#include "deskflow/ArgParser.h"
|
||||
@ -200,7 +200,7 @@ void ClientApp::updateStatus(const std::string &msg) const
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void ClientApp::handleScreenError(const Event &, void *)
|
||||
void ClientApp::handleScreenError()
|
||||
{
|
||||
LOG((CLOG_CRIT "error on screen"));
|
||||
m_events->addEvent(Event(EventTypes::Quit));
|
||||
@ -209,10 +209,9 @@ void ClientApp::handleScreenError(const Event &, void *)
|
||||
deskflow::Screen *ClientApp::openClientScreen()
|
||||
{
|
||||
deskflow::Screen *screen = createScreen();
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenError, screen->getEventTarget(),
|
||||
new TMethodEventJob<ClientApp>(this, &ClientApp::handleScreenError)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ScreenError, screen->getEventTarget(), [this](const auto &) {
|
||||
handleScreenError();
|
||||
});
|
||||
return screen;
|
||||
}
|
||||
|
||||
@ -224,10 +223,9 @@ void ClientApp::closeClientScreen(deskflow::Screen *screen)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientApp::handleClientRestart(const Event &, void *vtimer)
|
||||
void ClientApp::handleClientRestart(const Event &, EventQueueTimer *timer)
|
||||
{
|
||||
// discard old timer
|
||||
auto *timer = static_cast<EventQueueTimer *>(vtimer);
|
||||
m_events->deleteTimer(timer);
|
||||
m_events->removeHandler(EventTypes::Timer, timer);
|
||||
|
||||
@ -240,18 +238,16 @@ void ClientApp::scheduleClientRestart(double retryTime)
|
||||
// install a timer and handler to retry later
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, timer, new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientRestart, timer)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, timer, [this, timer](const auto &e) { handleClientRestart(e, timer); });
|
||||
}
|
||||
|
||||
void ClientApp::handleClientConnected(const Event &, void *)
|
||||
void ClientApp::handleClientConnected()
|
||||
{
|
||||
LOG((CLOG_NOTE "connected to server"));
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
void ClientApp::handleClientFailed(const Event &e, void *)
|
||||
void ClientApp::handleClientFailed(const Event &e)
|
||||
{
|
||||
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
|
||||
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
||||
@ -263,11 +259,11 @@ void ClientApp::handleClientFailed(const Event &e, void *)
|
||||
}
|
||||
} else {
|
||||
m_lastServerAddressIndex = 0;
|
||||
handleClientRefused(e, nullptr);
|
||||
handleClientRefused(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientApp::handleClientRefused(const Event &e, void *)
|
||||
void ClientApp::handleClientRefused(const Event &e)
|
||||
{
|
||||
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
||||
|
||||
@ -283,7 +279,7 @@ void ClientApp::handleClientRefused(const Event &e, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientApp::handleClientDisconnected(const Event &, void *)
|
||||
void ClientApp::handleClientDisconnected()
|
||||
{
|
||||
LOG((CLOG_NOTE "disconnected from server"));
|
||||
if (!args().m_restartable) {
|
||||
@ -299,25 +295,18 @@ Client *ClientApp::openClient(const std::string &name, const NetworkAddress &add
|
||||
auto *client = new Client(m_events, name, address, getSocketFactory(), screen, args());
|
||||
|
||||
try {
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientConnected, client->getEventTarget(),
|
||||
new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientConnected)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientConnectionFailed, client->getEventTarget(),
|
||||
new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientFailed)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientConnectionRefused, client->getEventTarget(),
|
||||
new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientRefused)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientDisconnected, client->getEventTarget(),
|
||||
new TMethodEventJob<ClientApp>(this, &ClientApp::handleClientDisconnected)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientConnected, client->getEventTarget(), [this](const auto &) {
|
||||
handleClientConnected();
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClientConnectionFailed, client->getEventTarget(), [this](const auto &e) {
|
||||
handleClientFailed(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClientConnectionRefused, client->getEventTarget(), [this](const auto &e) {
|
||||
handleClientRefused(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClientDisconnected, client->getEventTarget(), [this](const auto &) {
|
||||
handleClientDisconnected();
|
||||
});
|
||||
|
||||
} catch (std::bad_alloc &ba) {
|
||||
delete client;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -64,15 +65,15 @@ public:
|
||||
|
||||
void updateStatus() const;
|
||||
void updateStatus(const std::string &msg) const;
|
||||
void handleScreenError(const Event &, void *);
|
||||
void handleScreenError();
|
||||
deskflow::Screen *openClientScreen();
|
||||
void closeClientScreen(deskflow::Screen *screen);
|
||||
void handleClientRestart(const Event &, void *vtimer);
|
||||
void handleClientRestart(const Event &, EventQueueTimer *vtimer);
|
||||
void scheduleClientRestart(double retryTime);
|
||||
void handleClientConnected(const Event &, void *);
|
||||
void handleClientFailed(const Event &e, void *);
|
||||
void handleClientRefused(const Event &e, void *);
|
||||
void handleClientDisconnected(const Event &, void *);
|
||||
void handleClientConnected();
|
||||
void handleClientFailed(const Event &e);
|
||||
void handleClientRefused(const Event &e);
|
||||
void handleClientDisconnected();
|
||||
Client *openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen);
|
||||
void closeClient(Client *client);
|
||||
bool startClient();
|
||||
|
||||
@ -60,7 +60,6 @@ public:
|
||||
private:
|
||||
void daemonize();
|
||||
void handleError(const char *message);
|
||||
void handleIpcMessage(const Event &e, void *);
|
||||
int mainLoop();
|
||||
int daemonLoop();
|
||||
void saveLogLevel(const QString &logLevel) const;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -192,10 +193,9 @@ protected:
|
||||
A platform screen is expected to install a handler for system
|
||||
events in its c'tor like so:
|
||||
\code
|
||||
m_events->adoptHandler(EventTypes::System,
|
||||
m_events->addHandler(EventTypes::System,
|
||||
m_events->getSystemTarget(),
|
||||
new TMethodEventJob<CXXXPlatformScreen>(this,
|
||||
&CXXXPlatformScreen::handleSystemEvent));
|
||||
[this] (const auto &e) {handleSystemEvent(e);});
|
||||
\endcode
|
||||
It should remove the handler in its d'tor. Override the
|
||||
\c handleSystemEvent() method to process system events.
|
||||
@ -211,5 +211,5 @@ protected:
|
||||
The target of all events should be the value returned by
|
||||
\c getEventTarget().
|
||||
*/
|
||||
virtual void handleSystemEvent(const Event &event, void *) = 0;
|
||||
virtual void handleSystemEvent(const Event &event) = 0;
|
||||
};
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
|
||||
#include "deskflow/PacketStreamFilter.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@ -96,7 +96,7 @@ protected:
|
||||
virtual IKeyState *getKeyState() const = 0;
|
||||
|
||||
// IPlatformScreen overrides
|
||||
void handleSystemEvent(const Event &event, void *) override = 0;
|
||||
void handleSystemEvent(const Event &event) override = 0;
|
||||
|
||||
/*!
|
||||
* \brief mapClientScrollDirection
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
#include "deskflow/Screen.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/IPlatformScreen.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
#include "server/ClientProxy.h"
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/Path.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/App.h"
|
||||
#include "deskflow/ArgParser.h"
|
||||
#include "deskflow/Screen.h"
|
||||
@ -150,7 +149,7 @@ void ServerApp::reloadSignalHandler(Arch::ESignal, void *)
|
||||
events->addEvent(Event(EventTypes::ServerAppReloadConfig, events->getSystemTarget()));
|
||||
}
|
||||
|
||||
void ServerApp::reloadConfig(const Event &, void *)
|
||||
void ServerApp::reloadConfig()
|
||||
{
|
||||
LOG((CLOG_DEBUG "reload configuration"));
|
||||
if (loadConfig(args().m_configFile)) {
|
||||
@ -195,16 +194,15 @@ bool ServerApp::loadConfig(const std::string &pathname)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerApp::forceReconnect(const Event &, void *)
|
||||
void ServerApp::forceReconnect()
|
||||
{
|
||||
if (m_server != nullptr) {
|
||||
m_server->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void ServerApp::handleClientConnected(const Event &, void *vlistener)
|
||||
void ServerApp::handleClientConnected(const Event &, ClientListener *listener)
|
||||
{
|
||||
auto *listener = static_cast<ClientListener *>(vlistener);
|
||||
ClientProxy *client = listener->getNextClient();
|
||||
if (client != nullptr) {
|
||||
m_server->adoptClient(client);
|
||||
@ -212,7 +210,7 @@ void ServerApp::handleClientConnected(const Event &, void *vlistener)
|
||||
}
|
||||
}
|
||||
|
||||
void ServerApp::handleClientsDisconnected(const Event &, void *)
|
||||
void ServerApp::handleClientsDisconnected()
|
||||
{
|
||||
m_events->addEvent(Event(EventTypes::Quit));
|
||||
}
|
||||
@ -229,13 +227,8 @@ void ServerApp::closeServer(Server *server)
|
||||
// wait for clients to disconnect for up to timeout seconds
|
||||
double timeout = 3.0;
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(timeout, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, timer, new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientsDisconnected)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerDisconnected, server,
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientsDisconnected)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, timer, [this](const auto &) { handleClientsDisconnected(); });
|
||||
m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { handleClientsDisconnected(); });
|
||||
|
||||
m_events->loop();
|
||||
|
||||
@ -323,7 +316,7 @@ void ServerApp::cleanupServer()
|
||||
assert(m_serverState == kUninitialized);
|
||||
}
|
||||
|
||||
void ServerApp::retryHandler(const Event &, void *)
|
||||
void ServerApp::retryHandler()
|
||||
{
|
||||
// discard old timer
|
||||
assert(m_timer != nullptr);
|
||||
@ -410,7 +403,7 @@ bool ServerApp::initServer()
|
||||
assert(m_timer == nullptr);
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
m_timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(EventTypes::Timer, m_timer, new TMethodEventJob<ServerApp>(this, &ServerApp::retryHandler));
|
||||
m_events->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); });
|
||||
m_serverState = kInitializing;
|
||||
return true;
|
||||
} else {
|
||||
@ -422,17 +415,11 @@ bool ServerApp::initServer()
|
||||
deskflow::Screen *ServerApp::openServerScreen()
|
||||
{
|
||||
deskflow::Screen *screen = createScreen();
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenError, screen->getEventTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::handleScreenError)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenSuspend, screen->getEventTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::handleSuspend)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenResume, screen->getEventTarget(), new TMethodEventJob<ServerApp>(this, &ServerApp::handleResume)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ScreenError, screen->getEventTarget(), [this](const auto &) {
|
||||
handleScreenError();
|
||||
});
|
||||
m_events->addHandler(EventTypes::ScreenSuspend, screen->getEventTarget(), [this](const auto &) { handleSuspend(); });
|
||||
m_events->addHandler(EventTypes::ScreenResume, screen->getEventTarget(), [this](const auto &) { handleResume(); });
|
||||
return screen;
|
||||
}
|
||||
|
||||
@ -488,7 +475,7 @@ bool ServerApp::startServer()
|
||||
const auto retryTime = 10.0;
|
||||
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime));
|
||||
m_timer = m_events->newOneShotTimer(retryTime, nullptr);
|
||||
m_events->adoptHandler(EventTypes::Timer, m_timer, new TMethodEventJob<ServerApp>(this, &ServerApp::retryHandler));
|
||||
m_events->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); });
|
||||
m_serverState = kStarting;
|
||||
return true;
|
||||
} else {
|
||||
@ -528,13 +515,13 @@ PrimaryClient *ServerApp::openPrimaryClient(const std::string &name, deskflow::S
|
||||
return new PrimaryClient(name, screen);
|
||||
}
|
||||
|
||||
void ServerApp::handleScreenError(const Event &, void *)
|
||||
void ServerApp::handleScreenError()
|
||||
{
|
||||
LOG((CLOG_CRIT "error on screen"));
|
||||
m_events->addEvent(Event(EventTypes::Quit));
|
||||
}
|
||||
|
||||
void ServerApp::handleSuspend(const Event &, void *)
|
||||
void ServerApp::handleSuspend()
|
||||
{
|
||||
if (!m_suspended) {
|
||||
LOG((CLOG_INFO "suspend"));
|
||||
@ -543,7 +530,7 @@ void ServerApp::handleSuspend(const Event &, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void ServerApp::handleResume(const Event &, void *)
|
||||
void ServerApp::handleResume()
|
||||
{
|
||||
if (m_suspended) {
|
||||
LOG((CLOG_INFO "resume"));
|
||||
@ -559,10 +546,9 @@ ClientListener *ServerApp::openClientListener(const NetworkAddress &address)
|
||||
|
||||
auto *listen = new ClientListener(getAddress(address), getSocketFactory(), m_events, securityLevel);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientListenerAccepted, listen,
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientConnected, listen)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientListenerAccepted, listen, [this, listen](const auto &e) {
|
||||
handleClientConnected(e, listen);
|
||||
});
|
||||
|
||||
return listen;
|
||||
}
|
||||
@ -571,13 +557,8 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient
|
||||
{
|
||||
auto *server = new Server(config, primaryClient, m_serverScreen, m_events, args());
|
||||
try {
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerDisconnected, server, new TMethodEventJob<ServerApp>(this, &ServerApp::handleNoClients)
|
||||
);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerScreenSwitched, server, new TMethodEventJob<ServerApp>(this, &ServerApp::handleScreenSwitched)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { handleNoClients(); });
|
||||
m_events->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &e) { handleScreenSwitched(e); });
|
||||
|
||||
} catch (std::bad_alloc &ba) {
|
||||
delete server;
|
||||
@ -587,12 +568,12 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient
|
||||
return server;
|
||||
}
|
||||
|
||||
void ServerApp::handleNoClients(const Event &, void *)
|
||||
void ServerApp::handleNoClients()
|
||||
{
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
void ServerApp::handleScreenSwitched(const Event &e, void *)
|
||||
void ServerApp::handleScreenSwitched(const Event &e)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@ -640,24 +621,21 @@ int ServerApp::mainLoop()
|
||||
|
||||
// handle hangup signal by reloading the server's configuration
|
||||
ARCH->setSignalHandler(Arch::kHANGUP, &reloadSignalHandler, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerAppReloadConfig, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::reloadConfig)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ServerAppReloadConfig, m_events->getSystemTarget(), [this](const auto &) {
|
||||
reloadConfig();
|
||||
});
|
||||
|
||||
// handle force reconnect event by disconnecting clients. they'll
|
||||
// reconnect automatically.
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerAppForceReconnect, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::forceReconnect)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ServerAppForceReconnect, m_events->getSystemTarget(), [this](const auto &) {
|
||||
forceReconnect();
|
||||
});
|
||||
|
||||
// to work around the sticky meta keys problem, we'll give users
|
||||
// the option to reset the state of the server.
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerAppResetServer, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<ServerApp>(this, &ServerApp::resetServer)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ServerAppResetServer, m_events->getSystemTarget(), [this](const auto &) {
|
||||
resetServer();
|
||||
});
|
||||
|
||||
// run event loop. if startServer() failed we're supposed to retry
|
||||
// later. the timer installed by startServer() will take care of
|
||||
@ -690,7 +668,7 @@ int ServerApp::mainLoop()
|
||||
return kExitSuccess;
|
||||
}
|
||||
|
||||
void ServerApp::resetServer(const Event &, void *)
|
||||
void ServerApp::resetServer()
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "resetting server"));
|
||||
stopServer();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -78,11 +79,11 @@ public:
|
||||
// Regular functions
|
||||
//
|
||||
|
||||
void reloadConfig(const Event &, void *);
|
||||
void forceReconnect(const Event &, void *);
|
||||
void resetServer(const Event &, void *);
|
||||
void handleClientConnected(const Event &, void *vlistener);
|
||||
void handleClientsDisconnected(const Event &, void *);
|
||||
void reloadConfig();
|
||||
void forceReconnect();
|
||||
void resetServer();
|
||||
void handleClientConnected(const Event &e, ClientListener *listener);
|
||||
void handleClientsDisconnected();
|
||||
void closeServer(Server *server);
|
||||
void stopRetryTimer();
|
||||
void updateStatus() const;
|
||||
@ -93,15 +94,15 @@ public:
|
||||
void closeServerScreen(deskflow::Screen *screen);
|
||||
void cleanupServer();
|
||||
bool initServer();
|
||||
void retryHandler(const Event &, void *);
|
||||
void retryHandler();
|
||||
deskflow::Screen *openServerScreen();
|
||||
PrimaryClient *openPrimaryClient(const std::string &name, deskflow::Screen *screen);
|
||||
void handleScreenError(const Event &, void *);
|
||||
void handleSuspend(const Event &, void *);
|
||||
void handleResume(const Event &, void *);
|
||||
void handleScreenError();
|
||||
void handleSuspend();
|
||||
void handleResume();
|
||||
ClientListener *openClientListener(const NetworkAddress &address);
|
||||
Server *openServer(ServerConfig &config, PrimaryClient *primaryClient);
|
||||
void handleNoClients(const Event &, void *);
|
||||
void handleNoClients();
|
||||
bool startServer();
|
||||
Server *getServerPtr()
|
||||
{
|
||||
@ -124,7 +125,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void handleScreenSwitched(const Event &, void *data);
|
||||
void handleScreenSwitched(const Event &e);
|
||||
ISocketFactory *getSocketFactory() const;
|
||||
NetworkAddress getAddress(const NetworkAddress &address) const;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -7,7 +8,6 @@
|
||||
|
||||
#include "io/StreamFilter.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
|
||||
//
|
||||
// StreamFilter
|
||||
@ -20,10 +20,9 @@ StreamFilter::StreamFilter(IEventQueue *events, deskflow::IStream *stream, bool
|
||||
{
|
||||
// replace handlers for m_stream
|
||||
m_events->removeHandlers(m_stream->getEventTarget());
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Unknown, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<StreamFilter>(this, &StreamFilter::handleUpstreamEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Unknown, m_stream->getEventTarget(), [this](const auto &e) {
|
||||
handleUpstreamEvent(e);
|
||||
});
|
||||
}
|
||||
|
||||
StreamFilter::~StreamFilter()
|
||||
@ -89,7 +88,7 @@ void StreamFilter::filterEvent(const Event &event)
|
||||
m_events->dispatchEvent(Event(event.getType(), getEventTarget(), event.getData()));
|
||||
}
|
||||
|
||||
void StreamFilter::handleUpstreamEvent(const Event &event, void *)
|
||||
void StreamFilter::handleUpstreamEvent(const Event &event)
|
||||
{
|
||||
filterEvent(event);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -59,7 +60,7 @@ protected:
|
||||
virtual void filterEvent(const Event &);
|
||||
|
||||
private:
|
||||
void handleUpstreamEvent(const Event &, void *);
|
||||
void handleUpstreamEvent(const Event &);
|
||||
|
||||
private:
|
||||
deskflow::IStream *m_stream;
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include "base/Log.h"
|
||||
#include "base/Path.h"
|
||||
#include "base/String.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "common/Settings.h"
|
||||
#include "mt/Lock.h"
|
||||
#include "net/FingerprintDatabase.h"
|
||||
@ -87,11 +86,9 @@ void SecureSocket::close()
|
||||
|
||||
void SecureSocket::connect(const NetworkAddress &addr)
|
||||
{
|
||||
m_events->adoptHandler(
|
||||
EventTypes::DataSocketConnected, getEventTarget(),
|
||||
new TMethodEventJob<SecureSocket>(this, &SecureSocket::handleTCPConnected)
|
||||
);
|
||||
|
||||
m_events->addHandler(EventTypes::DataSocketConnected, getEventTarget(), [this](const auto &e) {
|
||||
handleTCPConnected(e);
|
||||
});
|
||||
TCPSocket::connect(addr);
|
||||
}
|
||||
|
||||
@ -728,7 +725,7 @@ ISocketMultiplexerJob *SecureSocket::serviceAccept(ISocketMultiplexerJob *job, b
|
||||
);
|
||||
}
|
||||
|
||||
void SecureSocket::handleTCPConnected(const Event &, void *)
|
||||
void SecureSocket::handleTCPConnected(const Event &)
|
||||
{
|
||||
if (getSocket() == nullptr) {
|
||||
LOG((CLOG_DEBUG "disregarding stale connect event"));
|
||||
|
||||
@ -83,7 +83,7 @@ private:
|
||||
|
||||
ISocketMultiplexerJob *serviceAccept(ISocketMultiplexerJob *, bool, bool, bool);
|
||||
|
||||
void handleTCPConnected(const Event &event, void *);
|
||||
void handleTCPConnected(const Event &event);
|
||||
|
||||
private:
|
||||
// all accesses to m_ssl must be protected by this mutex. The only function that is called
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
#include "arch/Arch.h"
|
||||
#include "arch/XArch.h"
|
||||
#include "base/IEventJob.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "mt/Lock.h"
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/Stopwatch.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "common/Constants.h"
|
||||
#include "deskflow/Clipboard.h"
|
||||
#include "deskflow/KeyMap.h"
|
||||
@ -50,22 +49,18 @@ EiScreen::EiScreen(bool is_primary, IEventQueue *events, bool use_portal)
|
||||
init_ei();
|
||||
key_state_ = new EiKeyState(this, events);
|
||||
// install event handlers
|
||||
events_->adoptHandler(
|
||||
EventTypes::System, events_->getSystemTarget(), new TMethodEventJob<EiScreen>(this, &EiScreen::handleSystemEvent)
|
||||
);
|
||||
events_->addHandler(EventTypes::System, events_->getSystemTarget(), [this](const auto &e) { handleSystemEvent(e); });
|
||||
|
||||
if (use_portal) {
|
||||
events_->adoptHandler(
|
||||
EventTypes::EIConnected, getEventTarget(),
|
||||
new TMethodEventJob<EiScreen>(this, &EiScreen::handle_connected_to_eis_event)
|
||||
);
|
||||
events_->addHandler(EventTypes::EIConnected, getEventTarget(), [this](const auto &e) {
|
||||
handle_connected_to_eis_event(e);
|
||||
});
|
||||
if (is_primary) {
|
||||
portal_input_capture_ = new PortalInputCapture(this, events_);
|
||||
} else {
|
||||
events_->adoptHandler(
|
||||
EventTypes::EISessionClosed, getEventTarget(),
|
||||
new TMethodEventJob<EiScreen>(this, &EiScreen::handle_portal_session_closed)
|
||||
);
|
||||
events_->addHandler(EventTypes::EISessionClosed, getEventTarget(), [this](const auto &) {
|
||||
handle_portal_session_closed();
|
||||
});
|
||||
portal_remote_desktop_ = new PortalRemoteDesktop(this, events_);
|
||||
}
|
||||
} else {
|
||||
@ -698,7 +693,7 @@ void EiScreen::on_abs_motion_event(const ei_event *event) const
|
||||
assert(is_primary_);
|
||||
}
|
||||
|
||||
void EiScreen::handle_connected_to_eis_event(const Event &event, void *)
|
||||
void EiScreen::handle_connected_to_eis_event(const Event &event)
|
||||
{
|
||||
int fd = static_cast<EiConnectInfo *>(event.getData())->m_fd;
|
||||
LOG_DEBUG("eis connection established, fd=%d", fd);
|
||||
@ -709,7 +704,7 @@ void EiScreen::handle_connected_to_eis_event(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void EiScreen::handle_portal_session_closed(const Event &event, void *)
|
||||
void EiScreen::handle_portal_session_closed()
|
||||
{
|
||||
// Portal may or may not EI_EVENT_DISCONNECT us before sending the DBus Closed
|
||||
// signal. Let's clean up either way.
|
||||
@ -718,7 +713,7 @@ void EiScreen::handle_portal_session_closed(const Event &event, void *)
|
||||
init_ei();
|
||||
}
|
||||
|
||||
void EiScreen::handleSystemEvent(const Event &sysevent, void *)
|
||||
void EiScreen::handleSystemEvent(const Event &sysevent)
|
||||
{
|
||||
std::scoped_lock lock{mutex_};
|
||||
|
||||
@ -779,7 +774,7 @@ void EiScreen::handleSystemEvent(const Event &sysevent, void *)
|
||||
portal_input_capture_ = new PortalInputCapture(this, this->events_);
|
||||
}
|
||||
}
|
||||
this->handle_portal_session_closed(sysevent, nullptr);
|
||||
this->handle_portal_session_closed();
|
||||
break;
|
||||
case EI_EVENT_DEVICE_PAUSED:
|
||||
LOG_DEBUG("device %s is paused", ei_device_get_name(device));
|
||||
|
||||
@ -76,7 +76,7 @@ public:
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
void handleSystemEvent(const Event &event, void *) override;
|
||||
void handleSystemEvent(const Event &event) override;
|
||||
void updateButtons() override;
|
||||
IKeyState *getKeyState() const override;
|
||||
std::string getSecureInputApp() const override;
|
||||
@ -100,8 +100,8 @@ private:
|
||||
bool on_hotkey(KeyID key, bool is_press, KeyModifierMask mask);
|
||||
void handle_ei_log_event(ei_log_priority priority, const char *message) const;
|
||||
|
||||
void handle_connected_to_eis_event(const Event &event, void *);
|
||||
void handle_portal_session_closed(const Event &event, void *);
|
||||
void handle_connected_to_eis_event(const Event &event);
|
||||
void handle_portal_session_closed();
|
||||
|
||||
static void cb_handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context)
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -11,7 +12,6 @@
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/IJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "deskflow/IScreenSaver.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
@ -144,9 +144,7 @@ void MSWindowsDesks::enable()
|
||||
// we wouldn't need this if windows notified us of a desktop
|
||||
// change but as far as i can tell it doesn't.
|
||||
m_timer = m_events->newTimer(0.2, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, m_timer, new TMethodEventJob<MSWindowsDesks>(this, &MSWindowsDesks::handleCheckDesk)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { handleCheckDesk(); });
|
||||
|
||||
updateKeys();
|
||||
}
|
||||
@ -807,7 +805,7 @@ void MSWindowsDesks::waitForDesk() const
|
||||
self->m_deskReady = false;
|
||||
}
|
||||
|
||||
void MSWindowsDesks::handleCheckDesk(const Event &, void *)
|
||||
void MSWindowsDesks::handleCheckDesk()
|
||||
{
|
||||
checkDesk();
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -210,7 +211,7 @@ private:
|
||||
void removeDesks();
|
||||
void checkDesk();
|
||||
bool isDeskAccessible(const Desk *desk) const;
|
||||
void handleCheckDesk(const Event &event, void *);
|
||||
void handleCheckDesk();
|
||||
|
||||
// communication with desk threads
|
||||
void waitForDesk() const;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -12,7 +13,6 @@
|
||||
#include "arch/win32/XArchWindows.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "client/Client.h"
|
||||
#include "common/Constants.h"
|
||||
@ -131,10 +131,9 @@ MSWindowsScreen::MSWindowsScreen(
|
||||
}
|
||||
|
||||
// install event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::System, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<MSWindowsScreen>(this, &MSWindowsScreen::handleSystemEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::System, m_events->getSystemTarget(), [this](const auto &e) {
|
||||
handleSystemEvent(e);
|
||||
});
|
||||
|
||||
// install the platform event queue
|
||||
m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events));
|
||||
@ -178,9 +177,7 @@ void MSWindowsScreen::enable()
|
||||
|
||||
// we need to poll some things to fix them
|
||||
m_fixTimer = m_events->newTimer(1.0, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, m_fixTimer, new TMethodEventJob<MSWindowsScreen>(this, &MSWindowsScreen::handleFixes)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, m_fixTimer, [this](const auto &) { handleFixes(); });
|
||||
|
||||
// install our clipboard snooper
|
||||
if (!AddClipboardFormatListener(m_window)) {
|
||||
@ -830,7 +827,7 @@ void MSWindowsScreen::sendClipboardEvent(EventTypes type, ClipboardID id)
|
||||
sendEvent(type, info);
|
||||
}
|
||||
|
||||
void MSWindowsScreen::handleSystemEvent(const Event &event, void *)
|
||||
void MSWindowsScreen::handleSystemEvent(const Event &event)
|
||||
{
|
||||
MSG *msg = static_cast<MSG *>(event.getData());
|
||||
assert(msg != nullptr);
|
||||
@ -1424,7 +1421,7 @@ void MSWindowsScreen::updateScreenShape()
|
||||
m_desks->setShape(m_x, m_y, m_w, m_h, m_xCenter, m_yCenter, m_multimon);
|
||||
}
|
||||
|
||||
void MSWindowsScreen::handleFixes(const Event &, void *)
|
||||
void MSWindowsScreen::handleFixes()
|
||||
{
|
||||
// fix clipboard chain
|
||||
fixClipboardViewer();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -126,7 +127,7 @@ public:
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
void handleSystemEvent(const Event &, void *) override;
|
||||
void handleSystemEvent(const Event &event) override;
|
||||
void updateButtons() override;
|
||||
IKeyState *getKeyState() const override;
|
||||
|
||||
@ -190,7 +191,7 @@ private: // HACK
|
||||
void updateScreenShape();
|
||||
|
||||
// fix timer callback
|
||||
void handleFixes(const Event &, void *);
|
||||
void handleFixes();
|
||||
|
||||
// fix the clipboard viewer chain
|
||||
void fixClipboardViewer();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -99,7 +100,7 @@ public:
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
void handleSystemEvent(const Event &, void *) override;
|
||||
void handleSystemEvent(const Event &e) override;
|
||||
void updateButtons() override;
|
||||
IKeyState *getKeyState() const override;
|
||||
|
||||
@ -148,7 +149,7 @@ private:
|
||||
double getScrollSpeed() const;
|
||||
|
||||
// clipboard check timer handler
|
||||
void handleClipboardCheck(const Event &, void *);
|
||||
void handleClipboardCheck();
|
||||
|
||||
// Resolution switch callback
|
||||
static void displayReconfigurationCallback(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *);
|
||||
@ -162,7 +163,7 @@ private:
|
||||
static void powerChangeCallback(void *refcon, io_service_t service, natural_t messageType, void *messageArgument);
|
||||
void handlePowerChangeRequest(natural_t messageType, void *messageArgument);
|
||||
|
||||
void handleConfirmSleep(const Event &event, void *);
|
||||
void handleConfirmSleep(const Event &event);
|
||||
|
||||
// global hotkey operating mode
|
||||
static bool isGlobalHotKeyOperatingModeAvailable();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -11,7 +12,6 @@
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "client/Client.h"
|
||||
#include "deskflow/ClientApp.h"
|
||||
@ -142,10 +142,9 @@ OSXScreen::OSXScreen(
|
||||
constructMouseButtonEventMap();
|
||||
|
||||
// watch for requests to sleep
|
||||
m_events->adoptHandler(
|
||||
EventTypes::OsxScreenConfirmSleep, getEventTarget(),
|
||||
new TMethodEventJob<OSXScreen>(this, &OSXScreen::handleConfirmSleep)
|
||||
);
|
||||
m_events->addHandler(EventTypes::OsxScreenConfirmSleep, getEventTarget(), [this](const auto &e) {
|
||||
handleConfirmSleep(e);
|
||||
});
|
||||
|
||||
// create thread for monitoring system power state.
|
||||
*m_pmThreadReady = false;
|
||||
@ -167,10 +166,9 @@ OSXScreen::OSXScreen(
|
||||
}
|
||||
|
||||
// install event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::System, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<OSXScreen>(this, &OSXScreen::handleSystemEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::System, m_events->getSystemTarget(), [this](const auto &e) {
|
||||
handleSystemEvent(e);
|
||||
});
|
||||
|
||||
// install the platform event queue
|
||||
m_events->adoptBuffer(new OSXEventQueueBuffer(m_events));
|
||||
@ -649,9 +647,7 @@ void OSXScreen::enable()
|
||||
{
|
||||
// watch the clipboard
|
||||
m_clipboardTimer = m_events->newTimer(1.0, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, m_clipboardTimer, new TMethodEventJob<OSXScreen>(this, &OSXScreen::handleClipboardCheck)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, m_clipboardTimer, [this](const auto &) { handleClipboardCheck(); });
|
||||
|
||||
if (m_isPrimary) {
|
||||
// FIXME -- start watching jump zones
|
||||
@ -836,7 +832,7 @@ void OSXScreen::sendClipboardEvent(EventTypes type, ClipboardID id) const
|
||||
sendEvent(type, info);
|
||||
}
|
||||
|
||||
void OSXScreen::handleSystemEvent(const Event &event, void *)
|
||||
void OSXScreen::handleSystemEvent(const Event &event)
|
||||
{
|
||||
EventRef *carbonEvent = static_cast<EventRef *>(event.getData());
|
||||
assert(carbonEvent != nullptr);
|
||||
@ -996,7 +992,7 @@ bool OSXScreen::onMouseWheel(int32_t xDelta, int32_t yDelta) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void OSXScreen::handleClipboardCheck(const Event &, void *)
|
||||
void OSXScreen::handleClipboardCheck()
|
||||
{
|
||||
checkClipboards();
|
||||
}
|
||||
@ -1448,7 +1444,7 @@ void OSXScreen::handlePowerChangeRequest(natural_t messageType, void *messageArg
|
||||
}
|
||||
}
|
||||
|
||||
void OSXScreen::handleConfirmSleep(const Event &event, void *)
|
||||
void OSXScreen::handleConfirmSleep(const Event &event)
|
||||
{
|
||||
long messageArg = (long)event.getData();
|
||||
if (messageArg != 0) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -12,7 +13,6 @@
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/Stopwatch.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/App.h"
|
||||
#include "deskflow/ArgsBase.h"
|
||||
#include "deskflow/ClientApp.h"
|
||||
@ -151,10 +151,9 @@ XWindowsScreen::XWindowsScreen(
|
||||
}
|
||||
|
||||
// install event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::System, m_events->getSystemTarget(),
|
||||
new TMethodEventJob<XWindowsScreen>(this, &XWindowsScreen::handleSystemEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::System, m_events->getSystemTarget(), [this](const auto &e) {
|
||||
handleSystemEvent(e);
|
||||
});
|
||||
|
||||
// install the platform event queue
|
||||
m_events->adoptBuffer(new XWindowsEventQueueBuffer(m_display, m_window, m_events));
|
||||
@ -1111,7 +1110,7 @@ Bool XWindowsScreen::findKeyEvent(Display *, XEvent *xevent, XPointer arg)
|
||||
: False;
|
||||
}
|
||||
|
||||
void XWindowsScreen::handleSystemEvent(const Event &event, void *)
|
||||
void XWindowsScreen::handleSystemEvent(const Event &event)
|
||||
{
|
||||
auto *xevent = static_cast<XEvent *>(event.getData());
|
||||
assert(xevent != nullptr);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -79,7 +80,7 @@ public:
|
||||
|
||||
protected:
|
||||
// IPlatformScreen overrides
|
||||
void handleSystemEvent(const Event &, void *) override;
|
||||
void handleSystemEvent(const Event &event) override;
|
||||
void updateButtons() override;
|
||||
IKeyState *getKeyState() const override;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -10,7 +11,6 @@
|
||||
#include "base/Event.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/IPlatformScreen.h"
|
||||
#include "platform/XWindowsUtil.h"
|
||||
|
||||
@ -82,9 +82,7 @@ XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, void *
|
||||
}
|
||||
|
||||
// install disable timer event handler
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, this, new TMethodEventJob<XWindowsScreenSaver>(this, &XWindowsScreenSaver::handleDisableTimer)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, this, [this](const auto &) { handleDisableTimer(); });
|
||||
}
|
||||
|
||||
XWindowsScreenSaver::~XWindowsScreenSaver()
|
||||
@ -446,7 +444,7 @@ void XWindowsScreenSaver::updateDisableTimer()
|
||||
}
|
||||
}
|
||||
|
||||
void XWindowsScreenSaver::handleDisableTimer(const Event &, void *)
|
||||
void XWindowsScreenSaver::handleDisableTimer()
|
||||
{
|
||||
// send fake mouse motion directly to xscreensaver
|
||||
if (m_xscreensaver != None) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -87,7 +88,7 @@ private:
|
||||
void updateDisableTimer();
|
||||
|
||||
// called periodically to prevent the screen saver from starting
|
||||
void handleDisableTimer(const Event &, void *);
|
||||
void handleDisableTimer();
|
||||
|
||||
// force DPMS to activate or deactivate
|
||||
void activateDPMS(bool activate);
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/PacketStreamFilter.h"
|
||||
#include "net/IDataSocket.h"
|
||||
#include "net/IListenSocket.h"
|
||||
@ -76,10 +75,9 @@ void ClientListener::start()
|
||||
m_listen = m_socketFactory->createListen(ARCH->getAddrFamily(m_address.getAddress()), m_securityLevel);
|
||||
|
||||
// setup event handler
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ListenSocketConnecting, m_listen,
|
||||
new TMethodEventJob<ClientListener>(this, &ClientListener::handleClientConnecting)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ListenSocketConnecting, m_listen, [this](const auto &) {
|
||||
handleClientConnecting();
|
||||
});
|
||||
|
||||
// bind listen address
|
||||
LOG((CLOG_DEBUG1 "binding listen socket"));
|
||||
@ -121,7 +119,7 @@ void ClientListener::removeUnknownClient(ClientProxyUnknown *unknownClient)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientListener::handleClientConnecting(const Event &, void *)
|
||||
void ClientListener::handleClientConnecting()
|
||||
{
|
||||
// accept client connection
|
||||
auto socket = m_listen->accept();
|
||||
@ -132,9 +130,9 @@ void ClientListener::handleClientConnecting(const Event &, void *)
|
||||
auto rawSocketPointer = socket.release();
|
||||
m_clientSockets.insert(rawSocketPointer);
|
||||
|
||||
m_events->adoptHandler(
|
||||
m_events->addHandler(
|
||||
EventTypes::ClientListenerAccepted, rawSocketPointer->getEventTarget(),
|
||||
new TMethodEventJob<ClientListener>(this, &ClientListener::handleClientAccepted, rawSocketPointer)
|
||||
[this, rawSocketPointer](const auto &) { handleClientAccepted(rawSocketPointer); }
|
||||
);
|
||||
|
||||
// When using non SSL, server accepts clients immediately, while SSL
|
||||
@ -144,12 +142,10 @@ void ClientListener::handleClientConnecting(const Event &, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientListener::handleClientAccepted(const Event &, void *vsocket)
|
||||
void ClientListener::handleClientAccepted(IDataSocket *socket)
|
||||
{
|
||||
LOG((CLOG_NOTE "accepted client connection"));
|
||||
|
||||
auto *socket = static_cast<IDataSocket *>(vsocket);
|
||||
|
||||
// filter socket messages, including a packetizing filter
|
||||
deskflow::IStream *stream = new PacketStreamFilter(m_events, socket, false);
|
||||
assert(m_server != nullptr);
|
||||
@ -160,20 +156,16 @@ void ClientListener::handleClientAccepted(const Event &, void *vsocket)
|
||||
m_newClients.insert(client);
|
||||
|
||||
// watch for events from unknown client
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyUnknownSuccess, client,
|
||||
new TMethodEventJob<ClientListener>(this, &ClientListener::handleUnknownClient, client)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyUnknownFailure, client,
|
||||
new TMethodEventJob<ClientListener>(this, &ClientListener::handleUnknownClientFailure, client)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientProxyUnknownSuccess, client, [this, client](const auto &) {
|
||||
handleUnknownClient(client);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClientProxyUnknownFailure, client, [this, client](const auto &) {
|
||||
handleUnknownClientFailure(client);
|
||||
});
|
||||
}
|
||||
|
||||
void ClientListener::handleUnknownClient(const Event &, void *vclient)
|
||||
void ClientListener::handleUnknownClient(ClientProxyUnknown *unknownClient)
|
||||
{
|
||||
auto unknownClient = static_cast<ClientProxyUnknown *>(vclient);
|
||||
|
||||
// we should have the client in our new client list
|
||||
assert(m_newClients.count(unknownClient) == 1);
|
||||
|
||||
@ -184,10 +176,9 @@ void ClientListener::handleUnknownClient(const Event &, void *vclient)
|
||||
m_events->addEvent(Event(EventTypes::ClientListenerAccepted, this));
|
||||
|
||||
// watch for client to disconnect while it's in our queue
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyDisconnected, client,
|
||||
new TMethodEventJob<ClientListener>(this, &ClientListener::handleClientDisconnected, client)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientProxyDisconnected, client, [this, client](const auto &e) {
|
||||
handleClientDisconnected(client);
|
||||
});
|
||||
} else {
|
||||
auto *stream = unknownClient->getStream();
|
||||
if (stream) {
|
||||
@ -199,16 +190,13 @@ void ClientListener::handleUnknownClient(const Event &, void *vclient)
|
||||
removeUnknownClient(unknownClient);
|
||||
}
|
||||
|
||||
void ClientListener::handleUnknownClientFailure(const Event &, void *vclient)
|
||||
void ClientListener::handleUnknownClientFailure(ClientProxyUnknown *client)
|
||||
{
|
||||
auto unknownClient = static_cast<ClientProxyUnknown *>(vclient);
|
||||
removeUnknownClient(unknownClient);
|
||||
removeUnknownClient(client);
|
||||
}
|
||||
|
||||
void ClientListener::handleClientDisconnected(const Event &, void *vclient)
|
||||
void ClientListener::handleClientDisconnected(ClientProxy *client)
|
||||
{
|
||||
auto *client = static_cast<ClientProxy *>(vclient);
|
||||
|
||||
// find client in waiting clients queue
|
||||
for (WaitingClients::iterator i = m_waitingClients.begin(), n = m_waitingClients.end(); i != n; ++i) {
|
||||
if (*i == client) {
|
||||
|
||||
@ -64,11 +64,11 @@ public:
|
||||
|
||||
private:
|
||||
// client connection event handlers
|
||||
void handleClientConnecting(const Event &, void *);
|
||||
void handleClientAccepted(const Event &, void *);
|
||||
void handleUnknownClient(const Event &, void *);
|
||||
void handleUnknownClientFailure(const Event &, void *);
|
||||
void handleClientDisconnected(const Event &, void *);
|
||||
void handleClientConnecting();
|
||||
void handleClientAccepted(IDataSocket *socket);
|
||||
void handleUnknownClient(ClientProxyUnknown *unknownClient);
|
||||
void handleUnknownClientFailure(ClientProxyUnknown *client);
|
||||
void handleClientDisconnected(ClientProxy *client);
|
||||
|
||||
void cleanupListenSocket();
|
||||
void cleanupClientSockets();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -9,7 +10,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
#include "deskflow/XDeskflow.h"
|
||||
#include "io/IStream.h"
|
||||
@ -26,29 +26,20 @@ ClientProxy1_0::ClientProxy1_0(const std::string &name, deskflow::IStream *strea
|
||||
m_events(events)
|
||||
{
|
||||
// install event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputReady, stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleData, nullptr)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputError, stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleWriteError, nullptr)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputShutdown, stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleDisconnect, nullptr)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputFormatError, stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleDisconnect, nullptr)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputShutdown, stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleWriteError, nullptr)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, this, new TMethodEventJob<ClientProxy1_0>(this, &ClientProxy1_0::handleFlatline, nullptr)
|
||||
);
|
||||
m_events->addHandler(EventTypes::StreamInputReady, stream->getEventTarget(), [this](const auto &) { handleData(); });
|
||||
m_events->addHandler(EventTypes::StreamOutputError, stream->getEventTarget(), [this](const auto &) {
|
||||
handleWriteError();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputShutdown, stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnect();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputFormatError, stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnect();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamOutputShutdown, stream->getEventTarget(), [this](const auto &) {
|
||||
handleWriteError();
|
||||
});
|
||||
m_events->addHandler(EventTypes::Timer, this, [this](const auto &) { handleFlatline(); });
|
||||
|
||||
setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);
|
||||
|
||||
@ -114,7 +105,7 @@ void ClientProxy1_0::setHeartbeatRate(double, double alarm)
|
||||
m_heartbeatAlarm = alarm;
|
||||
}
|
||||
|
||||
void ClientProxy1_0::handleData(const Event &, void *)
|
||||
void ClientProxy1_0::handleData()
|
||||
{
|
||||
// handle messages until there are no more. first read message code.
|
||||
uint8_t code[4];
|
||||
@ -192,19 +183,19 @@ bool ClientProxy1_0::parseMessage(const uint8_t *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientProxy1_0::handleDisconnect(const Event &, void *)
|
||||
void ClientProxy1_0::handleDisconnect()
|
||||
{
|
||||
LOG((CLOG_NOTE "client \"%s\" has disconnected", getName().c_str()));
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void ClientProxy1_0::handleWriteError(const Event &, void *)
|
||||
void ClientProxy1_0::handleWriteError()
|
||||
{
|
||||
LOG((CLOG_WARN "error writing to client \"%s\"", getName().c_str()));
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void ClientProxy1_0::handleFlatline(const Event &, void *)
|
||||
void ClientProxy1_0::handleFlatline()
|
||||
{
|
||||
// didn't get a heartbeat fast enough. assume client is dead.
|
||||
LOG((CLOG_NOTE "client \"%s\" is dead", getName().c_str()));
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -69,10 +70,10 @@ private:
|
||||
void disconnect();
|
||||
void removeHandlers();
|
||||
|
||||
void handleData(const Event &, void *);
|
||||
void handleDisconnect(const Event &, void *);
|
||||
void handleWriteError(const Event &, void *);
|
||||
void handleFlatline(const Event &, void *);
|
||||
void handleData();
|
||||
void handleDisconnect();
|
||||
void handleWriteError();
|
||||
void handleFlatline();
|
||||
|
||||
bool recvInfo();
|
||||
bool recvGrabClipboard();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2006 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -9,7 +10,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -73,10 +73,7 @@ void ClientProxy1_3::addHeartbeatTimer()
|
||||
// create and install a timer to periodically send keep alives
|
||||
if (m_keepAliveRate > 0.0) {
|
||||
m_keepAliveTimer = m_events->newTimer(m_keepAliveRate, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, m_keepAliveTimer,
|
||||
new TMethodEventJob<ClientProxy1_3>(this, &ClientProxy1_3::handleKeepAlive, nullptr)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, m_keepAliveTimer, [this](const auto &) { handleKeepAlive(); });
|
||||
}
|
||||
|
||||
// superclass does the alarm
|
||||
@ -96,7 +93,7 @@ void ClientProxy1_3::removeHeartbeatTimer()
|
||||
ClientProxy1_2::removeHeartbeatTimer();
|
||||
}
|
||||
|
||||
void ClientProxy1_3::handleKeepAlive(const Event &, void *)
|
||||
void ClientProxy1_3::handleKeepAlive()
|
||||
{
|
||||
keepAlive();
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2006 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -24,7 +25,7 @@ public:
|
||||
// IClient overrides
|
||||
void mouseWheel(int32_t xDelta, int32_t yDelta) override;
|
||||
|
||||
void handleKeepAlive(const Event &, void *);
|
||||
void handleKeepAlive();
|
||||
|
||||
protected:
|
||||
// ClientProxy overrides
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
#include "server/Server.h"
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "server/ClientProxy1_5.h"
|
||||
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
#include "deskflow/StreamChunker.h"
|
||||
#include "io/IStream.h"
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "server/ClientProxy1_6.h"
|
||||
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/ClipboardChunk.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
#include "deskflow/StreamChunker.h"
|
||||
@ -22,10 +21,7 @@ ClientProxy1_6::ClientProxy1_6(const std::string &name, deskflow::IStream *strea
|
||||
: ClientProxy1_5(name, stream, server, events),
|
||||
m_events(events)
|
||||
{
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClipboardSending, this,
|
||||
new TMethodEventJob<ClientProxy1_6>(this, &ClientProxy1_6::handleClipboardSendingEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { handleClipboardSendingEvent(e); });
|
||||
}
|
||||
|
||||
void ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard *clipboard)
|
||||
@ -45,7 +41,7 @@ void ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard *clipboard)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy1_6::handleClipboardSendingEvent(const Event &event, void *)
|
||||
void ClientProxy1_6::handleClipboardSendingEvent(const Event &event)
|
||||
{
|
||||
ClipboardChunk::send(getStream(), event.getDataObject());
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ public:
|
||||
bool recvClipboard() override;
|
||||
|
||||
private:
|
||||
void handleClipboardSendingEvent(const Event &, void *);
|
||||
void handleClipboardSendingEvent(const Event &e);
|
||||
|
||||
private:
|
||||
IEventQueue *m_events;
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
#include "server/ClientProxy1_7.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
#include "server/Server.h"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -9,7 +10,6 @@
|
||||
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
#include "deskflow/ProtocolUtil.h"
|
||||
@ -41,10 +41,7 @@ ClientProxyUnknown::ClientProxyUnknown(deskflow::IStream *stream, double timeout
|
||||
{
|
||||
assert(m_server != nullptr);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, this,
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleTimeout, nullptr)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, this, [this](const auto &) { handleTimeout(); });
|
||||
m_timer = m_events->newOneShotTimer(timeout, this);
|
||||
addStreamHandlers();
|
||||
|
||||
@ -95,40 +92,29 @@ void ClientProxyUnknown::sendFailure()
|
||||
void ClientProxyUnknown::addStreamHandlers()
|
||||
{
|
||||
assert(m_stream != nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputReady, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleData)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputError, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleWriteError)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputShutdown, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleDisconnect)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamInputFormatError, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleDisconnect)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::StreamOutputShutdown, m_stream->getEventTarget(),
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleWriteError)
|
||||
);
|
||||
m_events->addHandler(EventTypes::StreamInputReady, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleData();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamOutputError, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleWriteError();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputShutdown, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnect();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamInputFormatError, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleDisconnect();
|
||||
});
|
||||
m_events->addHandler(EventTypes::StreamOutputShutdown, m_stream->getEventTarget(), [this](const auto &) {
|
||||
handleWriteError();
|
||||
});
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::addProxyHandlers()
|
||||
{
|
||||
assert(m_proxy != nullptr);
|
||||
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyReady, m_proxy,
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleReady)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyDisconnected, m_proxy,
|
||||
new TMethodEventJob<ClientProxyUnknown>(this, &ClientProxyUnknown::handleDisconnect)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientProxyReady, m_proxy, [this](const auto &e) { handleReady(); });
|
||||
m_events->addHandler(EventTypes::ClientProxyDisconnected, m_proxy, [this](const auto &e) { handleDisconnect(); });
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::removeHandlers()
|
||||
@ -203,7 +189,7 @@ void ClientProxyUnknown::initProxy(const std::string &name, int major, int minor
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::handleData(const Event &, void *)
|
||||
void ClientProxyUnknown::handleData()
|
||||
{
|
||||
LOG((CLOG_DEBUG1 "parsing hello reply"));
|
||||
|
||||
@ -258,25 +244,25 @@ void ClientProxyUnknown::handleData(const Event &, void *)
|
||||
sendFailure();
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::handleWriteError(const Event &, void *)
|
||||
void ClientProxyUnknown::handleWriteError()
|
||||
{
|
||||
LOG((CLOG_NOTE "error communicating with new client"));
|
||||
sendFailure();
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::handleTimeout(const Event &, void *)
|
||||
void ClientProxyUnknown::handleTimeout()
|
||||
{
|
||||
LOG((CLOG_NOTE "new client is unresponsive"));
|
||||
sendFailure();
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::handleDisconnect(const Event &, void *)
|
||||
void ClientProxyUnknown::handleDisconnect()
|
||||
{
|
||||
LOG((CLOG_NOTE "new client disconnected"));
|
||||
sendFailure();
|
||||
}
|
||||
|
||||
void ClientProxyUnknown::handleReady(const Event &, void *)
|
||||
void ClientProxyUnknown::handleReady()
|
||||
{
|
||||
sendSuccess();
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -59,11 +60,11 @@ private:
|
||||
void removeHandlers();
|
||||
void initProxy(const std::string &name, int major, int minor);
|
||||
void removeTimer();
|
||||
void handleData(const Event &, void *);
|
||||
void handleWriteError(const Event &, void *);
|
||||
void handleTimeout(const Event &, void *);
|
||||
void handleDisconnect(const Event &, void *);
|
||||
void handleReady(const Event &, void *);
|
||||
void handleData();
|
||||
void handleWriteError();
|
||||
void handleTimeout();
|
||||
void handleDisconnect();
|
||||
void handleReady();
|
||||
|
||||
private:
|
||||
deskflow::IStream *m_stream = nullptr;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2005 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -8,7 +9,6 @@
|
||||
#include "server/InputFilter.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "deskflow/KeyMap.h"
|
||||
#include "server/PrimaryClient.h"
|
||||
#include "server/Server.h"
|
||||
@ -796,38 +796,30 @@ void InputFilter::setPrimaryClient(PrimaryClient *client)
|
||||
m_primaryClient = client;
|
||||
|
||||
if (m_primaryClient != nullptr) {
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyDown, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyUp, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyRepeat, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenButtonDown, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenButtonUp, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenHotkeyDown, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenHotkeyUp, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerConnected, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<InputFilter>(this, &InputFilter::handleEvent)
|
||||
);
|
||||
m_events->addHandler(EventTypes::KeyStateKeyDown, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::KeyStateKeyUp, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::KeyStateKeyRepeat, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenButtonDown, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenButtonUp, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenHotkeyDown, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenHotkeyUp, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ServerConnected, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleEvent(e);
|
||||
});
|
||||
|
||||
for (auto rule = m_ruleList.begin(); rule != m_ruleList.end(); ++rule) {
|
||||
rule->enable(m_primaryClient);
|
||||
@ -878,7 +870,7 @@ bool InputFilter::operator!=(const InputFilter &x) const
|
||||
return !operator==(x);
|
||||
}
|
||||
|
||||
void InputFilter::handleEvent(const Event &event, void *)
|
||||
void InputFilter::handleEvent(const Event &event)
|
||||
{
|
||||
// copy event and adjust target
|
||||
Event myEvent(
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2005 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -324,7 +325,7 @@ public:
|
||||
void disable(PrimaryClient *);
|
||||
|
||||
// event handling
|
||||
bool handleEvent(const Event &);
|
||||
bool handleEvent(const Event &e);
|
||||
|
||||
// convert rule to a string
|
||||
std::string format() const;
|
||||
@ -387,7 +388,7 @@ public:
|
||||
|
||||
private:
|
||||
// event handling
|
||||
void handleEvent(const Event &, void *);
|
||||
void handleEvent(const Event &);
|
||||
|
||||
private:
|
||||
RuleList m_ruleList;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers.
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -10,7 +11,6 @@
|
||||
#include "arch/Arch.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "deskflow/AppUtil.h"
|
||||
#include "deskflow/IPlatformScreen.h"
|
||||
@ -71,67 +71,55 @@ Server::Server(
|
||||
}
|
||||
|
||||
// install event handlers
|
||||
m_events->adoptHandler(EventTypes::Timer, this, new TMethodEventJob<Server>(this, &Server::handleSwitchWaitTimeout));
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyDown, m_inputFilter, new TMethodEventJob<Server>(this, &Server::handleKeyDownEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyUp, m_inputFilter, new TMethodEventJob<Server>(this, &Server::handleKeyUpEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::KeyStateKeyRepeat, m_inputFilter, new TMethodEventJob<Server>(this, &Server::handleKeyRepeatEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenButtonDown, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleButtonDownEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenButtonUp, m_inputFilter, new TMethodEventJob<Server>(this, &Server::handleButtonUpEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
m_events->addHandler(EventTypes::Timer, this, [this](const auto &) { handleSwitchWaitTimeout(); });
|
||||
m_events->addHandler(EventTypes::KeyStateKeyDown, m_inputFilter, [this](const auto &e) { handleKeyDownEvent(e); });
|
||||
m_events->addHandler(EventTypes::KeyStateKeyUp, m_inputFilter, [this](const auto &e) { handleKeyUpEvent(e); });
|
||||
m_events->addHandler(EventTypes::KeyStateKeyRepeat, m_inputFilter, [this](const auto &e) {
|
||||
handleKeyRepeatEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenButtonDown, m_inputFilter, [this](const auto &e) {
|
||||
handleButtonDownEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenButtonUp, m_inputFilter, [this](const auto &e) {
|
||||
handleButtonUpEvent(e);
|
||||
});
|
||||
m_events->addHandler(
|
||||
EventTypes::PrimaryScreenMotionOnPrimary, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleMotionPrimaryEvent)
|
||||
[this](const auto &e) { handleMotionPrimaryEvent(e); }
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
m_events->addHandler(
|
||||
EventTypes::PrimaryScreenMotionOnSecondary, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleMotionSecondaryEvent)
|
||||
[this](const auto &e) { handleMotionSecondaryEvent(e); }
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenWheel, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleWheelEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
m_events->addHandler(EventTypes::PrimaryScreenWheel, m_primaryClient->getEventTarget(), [this](const auto &e) {
|
||||
handleWheelEvent(e);
|
||||
});
|
||||
m_events->addHandler(
|
||||
EventTypes::PrimaryScreenSaverActivated, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleScreensaverActivatedEvent)
|
||||
[this](const auto &) { handleScreensaverActivatedEvent(); }
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
m_events->addHandler(
|
||||
EventTypes::PrimaryScreenSaverDeactivated, m_primaryClient->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleScreensaverDeactivatedEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerSwitchToScreen, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleSwitchToScreenEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerSwitchInDirection, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleSwitchInDirectionEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerKeyboardBroadcast, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleKeyboardBroadcastEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ServerLockCursorToScreen, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleLockCursorToScreenEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenFakeInputBegin, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleFakeInputBeginEvent)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::PrimaryScreenFakeInputEnd, m_inputFilter,
|
||||
new TMethodEventJob<Server>(this, &Server::handleFakeInputEndEvent)
|
||||
[this](const auto &) { handleScreensaverDeactivatedEvent(); }
|
||||
);
|
||||
m_events->addHandler(EventTypes::ServerSwitchToScreen, m_inputFilter, [this](const auto &e) {
|
||||
handleSwitchToScreenEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ServerSwitchInDirection, m_inputFilter, [this](const auto &e) {
|
||||
handleSwitchInDirectionEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ServerKeyboardBroadcast, m_inputFilter, [this](const auto &e) {
|
||||
handleKeyboardBroadcastEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ServerLockCursorToScreen, m_inputFilter, [this](const auto &e) {
|
||||
handleLockCursorToScreenEvent(e);
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenFakeInputBegin, m_inputFilter, [this](const auto &) {
|
||||
handleFakeInputBeginEvent();
|
||||
});
|
||||
m_events->addHandler(EventTypes::PrimaryScreenFakeInputEnd, m_inputFilter, [this](const auto &) {
|
||||
handleFakeInputEndEvent();
|
||||
});
|
||||
|
||||
// add connection
|
||||
addClient(m_primaryClient);
|
||||
@ -237,10 +225,9 @@ void Server::adoptClient(BaseClientProxy *client)
|
||||
assert(client != nullptr);
|
||||
|
||||
// watch for client disconnection
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClientProxyDisconnected, client,
|
||||
new TMethodEventJob<Server>(this, &Server::handleClientDisconnected, client)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ClientProxyDisconnected, client, [this, client](const auto &e) {
|
||||
handleClientDisconnected(client);
|
||||
});
|
||||
|
||||
// name must be in our configuration
|
||||
if (!m_config->isScreen(client->getName())) {
|
||||
@ -1128,10 +1115,8 @@ void Server::processOptions()
|
||||
m_relativeMoves = newRelativeMoves;
|
||||
}
|
||||
|
||||
void Server::handleShapeChanged(const Event &, void *vclient)
|
||||
void Server::handleShapeChanged(BaseClientProxy *client)
|
||||
{
|
||||
// ignore events from unknown clients
|
||||
auto *client = static_cast<BaseClientProxy *>(vclient);
|
||||
if (m_clientSet.count(client) == 0) {
|
||||
return;
|
||||
}
|
||||
@ -1160,14 +1145,13 @@ void Server::handleShapeChanged(const Event &, void *vclient)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleClipboardGrabbed(const Event &event, void *vclient)
|
||||
void Server::handleClipboardGrabbed(const Event &event, BaseClientProxy *grabber)
|
||||
{
|
||||
if (!m_enableClipboard || (m_maximumClipboardSize == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore events from unknown clients
|
||||
auto *grabber = static_cast<BaseClientProxy *>(vclient);
|
||||
if (m_clientSet.count(grabber) == 0) {
|
||||
return;
|
||||
}
|
||||
@ -1216,78 +1200,77 @@ void Server::handleClipboardGrabbed(const Event &event, void *vclient)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleClipboardChanged(const Event &event, void *vclient)
|
||||
void Server::handleClipboardChanged(const Event &event, BaseClientProxy *client)
|
||||
{
|
||||
// ignore events from unknown clients
|
||||
auto *sender = static_cast<BaseClientProxy *>(vclient);
|
||||
if (m_clientSet.count(sender) == 0) {
|
||||
if (m_clientSet.count(client) == 0) {
|
||||
return;
|
||||
}
|
||||
const auto *info = static_cast<const IScreen::ClipboardInfo *>(event.getData());
|
||||
onClipboardChanged(sender, info->m_id, info->m_sequenceNumber);
|
||||
onClipboardChanged(client, info->m_id, info->m_sequenceNumber);
|
||||
}
|
||||
|
||||
void Server::handleKeyDownEvent(const Event &event, void *)
|
||||
void Server::handleKeyDownEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::KeyInfo *>(event.getData());
|
||||
auto lang = AppUtil::instance().getCurrentLanguageCode();
|
||||
onKeyDown(info->m_key, info->m_mask, info->m_button, lang, info->m_screens);
|
||||
}
|
||||
|
||||
void Server::handleKeyUpEvent(const Event &event, void *)
|
||||
void Server::handleKeyUpEvent(const Event &event)
|
||||
{
|
||||
auto *info = static_cast<IPlatformScreen::KeyInfo *>(event.getData());
|
||||
onKeyUp(info->m_key, info->m_mask, info->m_button, info->m_screens);
|
||||
}
|
||||
|
||||
void Server::handleKeyRepeatEvent(const Event &event, void *)
|
||||
void Server::handleKeyRepeatEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::KeyInfo *>(event.getData());
|
||||
auto lang = AppUtil::instance().getCurrentLanguageCode();
|
||||
onKeyRepeat(info->m_key, info->m_mask, info->m_count, info->m_button, lang);
|
||||
}
|
||||
|
||||
void Server::handleButtonDownEvent(const Event &event, void *)
|
||||
void Server::handleButtonDownEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::ButtonInfo *>(event.getData());
|
||||
onMouseDown(info->m_button);
|
||||
}
|
||||
|
||||
void Server::handleButtonUpEvent(const Event &event, void *)
|
||||
void Server::handleButtonUpEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::ButtonInfo *>(event.getData());
|
||||
onMouseUp(info->m_button);
|
||||
}
|
||||
|
||||
void Server::handleMotionPrimaryEvent(const Event &event, void *)
|
||||
void Server::handleMotionPrimaryEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
|
||||
onMouseMovePrimary(info->m_x, info->m_y);
|
||||
}
|
||||
|
||||
void Server::handleMotionSecondaryEvent(const Event &event, void *)
|
||||
void Server::handleMotionSecondaryEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
|
||||
onMouseMoveSecondary(info->m_x, info->m_y);
|
||||
}
|
||||
|
||||
void Server::handleWheelEvent(const Event &event, void *)
|
||||
void Server::handleWheelEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<IPlatformScreen::WheelInfo *>(event.getData());
|
||||
onMouseWheel(info->m_xDelta, info->m_yDelta);
|
||||
}
|
||||
|
||||
void Server::handleScreensaverActivatedEvent(const Event &, void *)
|
||||
void Server::handleScreensaverActivatedEvent()
|
||||
{
|
||||
onScreensaver(true);
|
||||
}
|
||||
|
||||
void Server::handleScreensaverDeactivatedEvent(const Event &, void *)
|
||||
void Server::handleScreensaverDeactivatedEvent()
|
||||
{
|
||||
onScreensaver(false);
|
||||
}
|
||||
|
||||
void Server::handleSwitchWaitTimeout(const Event &, void *)
|
||||
void Server::handleSwitchWaitTimeout()
|
||||
{
|
||||
// ignore if mouse is locked to screen
|
||||
if (isLockedToScreen()) {
|
||||
@ -1300,28 +1283,26 @@ void Server::handleSwitchWaitTimeout(const Event &, void *)
|
||||
switchScreen(m_switchScreen, m_switchWaitX, m_switchWaitY, false);
|
||||
}
|
||||
|
||||
void Server::handleClientDisconnected(const Event &, void *vclient)
|
||||
void Server::handleClientDisconnected(BaseClientProxy *client)
|
||||
{
|
||||
// client has disconnected. it might be an old client or an
|
||||
// active client. we don't care so just handle it both ways.
|
||||
auto *client = static_cast<BaseClientProxy *>(vclient);
|
||||
removeActiveClient(client);
|
||||
removeOldClient(client);
|
||||
|
||||
delete client;
|
||||
}
|
||||
|
||||
void Server::handleClientCloseTimeout(const Event &, void *vclient)
|
||||
void Server::handleClientCloseTimeout(BaseClientProxy *client)
|
||||
{
|
||||
// client took too long to disconnect. just dump it.
|
||||
auto *client = static_cast<BaseClientProxy *>(vclient);
|
||||
LOG((CLOG_NOTE "forced disconnection of client \"%s\"", getName(client).c_str()));
|
||||
removeOldClient(client);
|
||||
|
||||
delete client;
|
||||
}
|
||||
|
||||
void Server::handleSwitchToScreenEvent(const Event &event, void *)
|
||||
void Server::handleSwitchToScreenEvent(const Event &event)
|
||||
{
|
||||
auto *info = static_cast<SwitchToScreenInfo *>(event.getData());
|
||||
|
||||
@ -1333,7 +1314,7 @@ void Server::handleSwitchToScreenEvent(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleSwitchInDirectionEvent(const Event &event, void *)
|
||||
void Server::handleSwitchInDirectionEvent(const Event &event)
|
||||
{
|
||||
const auto *info = static_cast<SwitchInDirectionInfo *>(event.getData());
|
||||
|
||||
@ -1348,7 +1329,7 @@ void Server::handleSwitchInDirectionEvent(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleKeyboardBroadcastEvent(const Event &event, void *)
|
||||
void Server::handleKeyboardBroadcastEvent(const Event &event)
|
||||
{
|
||||
const auto *info = (KeyboardBroadcastInfo *)event.getData();
|
||||
|
||||
@ -1380,7 +1361,7 @@ void Server::handleKeyboardBroadcastEvent(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleLockCursorToScreenEvent(const Event &event, void *)
|
||||
void Server::handleLockCursorToScreenEvent(const Event &event)
|
||||
{
|
||||
const auto *info = (LockCursorToScreenInfo *)event.getData();
|
||||
|
||||
@ -1413,12 +1394,12 @@ void Server::handleLockCursorToScreenEvent(const Event &event, void *)
|
||||
}
|
||||
}
|
||||
|
||||
void Server::handleFakeInputBeginEvent(const Event &, void *)
|
||||
void Server::handleFakeInputBeginEvent()
|
||||
{
|
||||
m_primaryClient->fakeInputBegin();
|
||||
}
|
||||
|
||||
void Server::handleFakeInputEndEvent(const Event &, void *)
|
||||
void Server::handleFakeInputEndEvent()
|
||||
{
|
||||
m_primaryClient->fakeInputEnd();
|
||||
}
|
||||
@ -1884,18 +1865,15 @@ bool Server::addClient(BaseClientProxy *client)
|
||||
}
|
||||
|
||||
// add event handlers
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ScreenShapeChanged, client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleShapeChanged, client)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClipboardGrabbed, client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleClipboardGrabbed, client)
|
||||
);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::ClipboardChanged, client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this, &Server::handleClipboardChanged, client)
|
||||
);
|
||||
m_events->addHandler(EventTypes::ScreenShapeChanged, client->getEventTarget(), [this, client](const auto &e) {
|
||||
handleShapeChanged(client);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClipboardGrabbed, client->getEventTarget(), [this, client](const auto &e) {
|
||||
handleClipboardGrabbed(e, client);
|
||||
});
|
||||
m_events->addHandler(EventTypes::ClipboardChanged, client->getEventTarget(), [this, client](const auto &e) {
|
||||
handleClipboardChanged(e, client);
|
||||
});
|
||||
|
||||
// add to list
|
||||
m_clientSet.insert(client);
|
||||
@ -1950,14 +1928,13 @@ void Server::closeClient(BaseClientProxy *client, const char *msg)
|
||||
|
||||
// send message
|
||||
// FIXME -- avoid type cast (kinda hard, though)
|
||||
((ClientProxy *)client)->close(msg);
|
||||
auto clientProxy = static_cast<ClientProxy *>(client);
|
||||
clientProxy->close(msg);
|
||||
|
||||
// install timer. wait timeout seconds for client to close.
|
||||
double timeout = 5.0;
|
||||
EventQueueTimer *timer = m_events->newOneShotTimer(timeout, nullptr);
|
||||
m_events->adoptHandler(
|
||||
EventTypes::Timer, timer, new TMethodEventJob<Server>(this, &Server::handleClientCloseTimeout, client)
|
||||
);
|
||||
m_events->addHandler(EventTypes::Timer, timer, [this, client](const auto &e) { handleClientCloseTimeout(client); });
|
||||
|
||||
// move client to closing list
|
||||
removeClient(client);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -289,28 +290,28 @@ private:
|
||||
void processOptions();
|
||||
|
||||
// event handlers
|
||||
void handleShapeChanged(const Event &, void *);
|
||||
void handleClipboardGrabbed(const Event &, void *);
|
||||
void handleClipboardChanged(const Event &, void *);
|
||||
void handleKeyDownEvent(const Event &, void *);
|
||||
void handleKeyUpEvent(const Event &, void *);
|
||||
void handleKeyRepeatEvent(const Event &, void *);
|
||||
void handleButtonDownEvent(const Event &, void *);
|
||||
void handleButtonUpEvent(const Event &, void *);
|
||||
void handleMotionPrimaryEvent(const Event &, void *);
|
||||
void handleMotionSecondaryEvent(const Event &, void *);
|
||||
void handleWheelEvent(const Event &, void *);
|
||||
void handleScreensaverActivatedEvent(const Event &, void *);
|
||||
void handleScreensaverDeactivatedEvent(const Event &, void *);
|
||||
void handleSwitchWaitTimeout(const Event &, void *);
|
||||
void handleClientDisconnected(const Event &, void *);
|
||||
void handleClientCloseTimeout(const Event &, void *);
|
||||
void handleSwitchToScreenEvent(const Event &, void *);
|
||||
void handleSwitchInDirectionEvent(const Event &, void *);
|
||||
void handleKeyboardBroadcastEvent(const Event &, void *);
|
||||
void handleLockCursorToScreenEvent(const Event &, void *);
|
||||
void handleFakeInputBeginEvent(const Event &, void *);
|
||||
void handleFakeInputEndEvent(const Event &, void *);
|
||||
void handleShapeChanged(BaseClientProxy *client);
|
||||
void handleClipboardGrabbed(const Event &event, BaseClientProxy *client);
|
||||
void handleClipboardChanged(const Event &event, BaseClientProxy *client);
|
||||
void handleKeyDownEvent(const Event &event);
|
||||
void handleKeyUpEvent(const Event &event);
|
||||
void handleKeyRepeatEvent(const Event &event);
|
||||
void handleButtonDownEvent(const Event &event);
|
||||
void handleButtonUpEvent(const Event &event);
|
||||
void handleMotionPrimaryEvent(const Event &event);
|
||||
void handleMotionSecondaryEvent(const Event &event);
|
||||
void handleWheelEvent(const Event &event);
|
||||
void handleScreensaverActivatedEvent();
|
||||
void handleScreensaverDeactivatedEvent();
|
||||
void handleSwitchWaitTimeout();
|
||||
void handleClientDisconnected(BaseClientProxy *client);
|
||||
void handleClientCloseTimeout(BaseClientProxy *client);
|
||||
void handleSwitchToScreenEvent(const Event &event);
|
||||
void handleSwitchInDirectionEvent(const Event &event);
|
||||
void handleKeyboardBroadcastEvent(const Event &event);
|
||||
void handleLockCursorToScreenEvent(const Event &event);
|
||||
void handleFakeInputBeginEvent();
|
||||
void handleFakeInputEndEvent();
|
||||
|
||||
// event processing
|
||||
void onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, uint32_t seqNum);
|
||||
|
||||
@ -22,11 +22,10 @@ public:
|
||||
MOCK_METHOD(void, removeHandlers, (void *), (override));
|
||||
MOCK_METHOD(EventTypes, registerType, (const char *));
|
||||
MOCK_METHOD(bool, isEmpty, (), (const, override));
|
||||
MOCK_METHOD(void, adoptHandler, (EventTypes, void *, IEventJob *), (override));
|
||||
MOCK_METHOD(void, addHandler, (EventTypes, void *, const EventHandler &), (override));
|
||||
MOCK_METHOD(void, addEvent, (const Event &), (override));
|
||||
MOCK_METHOD(void, removeHandler, (EventTypes, void *), (override));
|
||||
MOCK_METHOD(bool, dispatchEvent, (const Event &), (override));
|
||||
MOCK_METHOD(IEventJob *, getHandler, (EventTypes, void *), (const, override));
|
||||
MOCK_METHOD(void, deleteTimer, (EventQueueTimer *), (override));
|
||||
MOCK_METHOD(void *, getSystemTarget, (), (override));
|
||||
MOCK_METHOD(void, waitForReady, (), (const, override));
|
||||
|
||||
Reference in New Issue
Block a user