mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-25 12:06:26 +03:00
Refactored clipboard event into ClipboardEvent #4601
This commit is contained in:
parent
a6dfbbe021
commit
49ac320f97
@ -46,6 +46,7 @@ EVENT_TYPE_ACCESSOR(ServerApp)
|
||||
EVENT_TYPE_ACCESSOR(IKeyState)
|
||||
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
||||
EVENT_TYPE_ACCESSOR(IScreen)
|
||||
EVENT_TYPE_ACCESSOR(Clipboard)
|
||||
|
||||
// interrupt handler. this just adds a quit event to the queue.
|
||||
static
|
||||
@ -82,6 +83,7 @@ EventQueue::EventQueue() :
|
||||
m_typesForIKeyState(NULL),
|
||||
m_typesForIPrimaryScreen(NULL),
|
||||
m_typesForIScreen(NULL),
|
||||
m_typesForClipboard(NULL),
|
||||
m_readyMutex(new Mutex),
|
||||
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
||||
{
|
||||
|
@ -157,6 +157,7 @@ public:
|
||||
IKeyStateEvents& forIKeyState();
|
||||
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||
IScreenEvents& forIScreen();
|
||||
ClipboardEvents& forClipboard();
|
||||
|
||||
private:
|
||||
ClientEvents* m_typesForClient;
|
||||
@ -177,6 +178,7 @@ private:
|
||||
IKeyStateEvents* m_typesForIKeyState;
|
||||
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||
IScreenEvents* m_typesForIScreen;
|
||||
ClipboardEvents* m_typesForClipboard;
|
||||
Mutex* m_readyMutex;
|
||||
CondVar<bool>* m_readyCondVar;
|
||||
std::queue<Event> m_pending;
|
||||
|
@ -115,8 +115,6 @@ REGISTER_EVENT(ClientListener, connected)
|
||||
|
||||
REGISTER_EVENT(ClientProxy, ready)
|
||||
REGISTER_EVENT(ClientProxy, disconnected)
|
||||
REGISTER_EVENT(ClientProxy, clipboardChanged)
|
||||
REGISTER_EVENT(ClientProxy, clipboardSending)
|
||||
|
||||
//
|
||||
// ClientProxyUnknown
|
||||
@ -176,7 +174,6 @@ REGISTER_EVENT(IPrimaryScreen, fakeInputEnd)
|
||||
|
||||
REGISTER_EVENT(IScreen, error)
|
||||
REGISTER_EVENT(IScreen, shapeChanged)
|
||||
REGISTER_EVENT(IScreen, clipboardGrabbed)
|
||||
REGISTER_EVENT(IScreen, suspend)
|
||||
REGISTER_EVENT(IScreen, resume)
|
||||
REGISTER_EVENT(IScreen, fileChunkSending)
|
||||
@ -188,3 +185,11 @@ REGISTER_EVENT(IScreen, fileRecieveCompleted)
|
||||
|
||||
REGISTER_EVENT(IpcServer, clientConnected)
|
||||
REGISTER_EVENT(IpcServer, messageReceived)
|
||||
|
||||
//
|
||||
// Clipboard
|
||||
//
|
||||
|
||||
REGISTER_EVENT(Clipboard, clipboardGrabbed)
|
||||
REGISTER_EVENT(Clipboard, clipboardChanged)
|
||||
REGISTER_EVENT(Clipboard, clipboardSending)
|
@ -350,9 +350,7 @@ class ClientProxyEvents : public EventTypes {
|
||||
public:
|
||||
ClientProxyEvents() :
|
||||
m_ready(Event::kUnknown),
|
||||
m_disconnected(Event::kUnknown),
|
||||
m_clipboardChanged(Event::kUnknown),
|
||||
m_clipboardSending(Event::kUnknown) { }
|
||||
m_disconnected(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
@ -372,28 +370,11 @@ public:
|
||||
*/
|
||||
Event::Type disconnected();
|
||||
|
||||
//! Get clipboard changed event type
|
||||
/*!
|
||||
Returns the clipboard changed event type. This is sent whenever the
|
||||
contents of the clipboard has changed. The data is a pointer to a
|
||||
IScreen::ClipboardInfo.
|
||||
*/
|
||||
Event::Type clipboardChanged();
|
||||
|
||||
//! Clipboard sending event type
|
||||
/*!
|
||||
Returns the clipboard sending event type. This is used to send
|
||||
clipboard chunks.
|
||||
*/
|
||||
Event::Type clipboardSending();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
Event::Type m_ready;
|
||||
Event::Type m_disconnected;
|
||||
Event::Type m_clipboardChanged;
|
||||
Event::Type m_clipboardSending;
|
||||
};
|
||||
|
||||
class ClientProxyUnknownEvents : public EventTypes {
|
||||
@ -643,7 +624,6 @@ public:
|
||||
IScreenEvents() :
|
||||
m_error(Event::kUnknown),
|
||||
m_shapeChanged(Event::kUnknown),
|
||||
m_clipboardGrabbed(Event::kUnknown),
|
||||
m_suspend(Event::kUnknown),
|
||||
m_resume(Event::kUnknown),
|
||||
m_fileChunkSending(Event::kUnknown),
|
||||
@ -666,14 +646,6 @@ public:
|
||||
*/
|
||||
Event::Type shapeChanged();
|
||||
|
||||
//! Get clipboard grabbed event type
|
||||
/*!
|
||||
Returns the clipboard grabbed event type. This is sent whenever the
|
||||
clipboard is grabbed by some other application so we don't own it
|
||||
anymore. The data is a pointer to a ClipboardInfo.
|
||||
*/
|
||||
Event::Type clipboardGrabbed();
|
||||
|
||||
//! Get suspend event type
|
||||
/*!
|
||||
Returns the suspend event type. This is sent whenever the system goes
|
||||
@ -699,9 +671,49 @@ public:
|
||||
private:
|
||||
Event::Type m_error;
|
||||
Event::Type m_shapeChanged;
|
||||
Event::Type m_clipboardGrabbed;
|
||||
Event::Type m_suspend;
|
||||
Event::Type m_resume;
|
||||
Event::Type m_fileChunkSending;
|
||||
Event::Type m_fileRecieveCompleted;
|
||||
};
|
||||
|
||||
class ClipboardEvents : public EventTypes {
|
||||
public:
|
||||
ClipboardEvents() :
|
||||
m_clipboardGrabbed(Event::kUnknown),
|
||||
m_clipboardChanged(Event::kUnknown),
|
||||
m_clipboardSending(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Get clipboard grabbed event type
|
||||
/*!
|
||||
Returns the clipboard grabbed event type. This is sent whenever the
|
||||
clipboard is grabbed by some other application so we don't own it
|
||||
anymore. The data is a pointer to a ClipboardInfo.
|
||||
*/
|
||||
Event::Type clipboardGrabbed();
|
||||
|
||||
//! Get clipboard changed event type
|
||||
/*!
|
||||
Returns the clipboard changed event type. This is sent whenever the
|
||||
contents of the clipboard has changed. The data is a pointer to a
|
||||
IScreen::ClipboardInfo.
|
||||
*/
|
||||
Event::Type clipboardChanged();
|
||||
|
||||
//! Clipboard sending event type
|
||||
/*!
|
||||
Returns the clipboard sending event type. This is used to send
|
||||
clipboard chunks.
|
||||
*/
|
||||
Event::Type clipboardSending();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
Event::Type m_clipboardGrabbed;
|
||||
Event::Type m_clipboardChanged;
|
||||
Event::Type m_clipboardSending;
|
||||
};
|
||||
|
@ -48,6 +48,7 @@ class ServerAppEvents;
|
||||
class IKeyStateEvents;
|
||||
class IPrimaryScreenEvents;
|
||||
class IScreenEvents;
|
||||
class ClipboardEvents;
|
||||
|
||||
//! Event queue interface
|
||||
/*!
|
||||
@ -244,4 +245,5 @@ public:
|
||||
virtual IKeyStateEvents& forIKeyState() = 0;
|
||||
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||
virtual IScreenEvents& forIScreen() = 0;
|
||||
virtual ClipboardEvents& forClipboard() = 0;
|
||||
};
|
||||
|
@ -488,7 +488,7 @@ Client::setupScreen()
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleShapeChanged));
|
||||
m_events->adoptHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||
m_events->adoptHandler(m_events->forClipboard().clipboardGrabbed(),
|
||||
getEventTarget(),
|
||||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleClipboardGrabbed));
|
||||
@ -546,7 +546,7 @@ Client::cleanupScreen()
|
||||
}
|
||||
m_events->removeHandler(m_events->forIScreen().shapeChanged(),
|
||||
getEventTarget());
|
||||
m_events->removeHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||
m_events->removeHandler(m_events->forClipboard().clipboardGrabbed(),
|
||||
getEventTarget());
|
||||
delete m_server;
|
||||
m_server = NULL;
|
||||
|
@ -433,8 +433,8 @@ MSWindowsScreen::checkClipboards()
|
||||
if (m_ownClipboard && !MSWindowsClipboard::isOwnedBySynergy()) {
|
||||
LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received"));
|
||||
m_ownClipboard = false;
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardSelection);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,8 +1501,8 @@ MSWindowsScreen::onClipboardChange()
|
||||
if (m_ownClipboard) {
|
||||
LOG((CLOG_DEBUG "clipboard changed: lost ownership"));
|
||||
m_ownClipboard = false;
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardSelection);
|
||||
}
|
||||
}
|
||||
else if (!m_ownClipboard) {
|
||||
|
@ -954,8 +954,8 @@ OSXScreen::checkClipboards()
|
||||
LOG((CLOG_DEBUG2 "checking clipboard"));
|
||||
if (m_pasteboard.synchronize()) {
|
||||
LOG((CLOG_DEBUG "clipboard changed"));
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardClipboard);
|
||||
sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), kClipboardSelection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ ClientProxy1_0::recvClipboard()
|
||||
ClipboardInfo* info = new ClipboardInfo;
|
||||
info->m_id = id;
|
||||
info->m_sequenceNumber = seqNum;
|
||||
m_events->addEvent(Event(m_events->forClientProxy().clipboardChanged(),
|
||||
m_events->addEvent(Event(m_events->forClipboard().clipboardChanged(),
|
||||
getEventTarget(), info));
|
||||
|
||||
return true;
|
||||
@ -500,7 +500,7 @@ ClientProxy1_0::recvGrabClipboard()
|
||||
ClipboardInfo* info = new ClipboardInfo;
|
||||
info->m_id = id;
|
||||
info->m_sequenceNumber = seqNum;
|
||||
m_events->addEvent(Event(m_events->forIScreen().clipboardGrabbed(),
|
||||
m_events->addEvent(Event(m_events->forClipboard().clipboardGrabbed(),
|
||||
getEventTarget(), info));
|
||||
|
||||
return true;
|
||||
|
@ -33,7 +33,7 @@ ClientProxy1_6::ClientProxy1_6(const String& name, synergy::IStream* stream, Ser
|
||||
ClientProxy1_5(name, stream, server, events),
|
||||
m_events(events)
|
||||
{
|
||||
m_events->adoptHandler(m_events->forClientProxy().clipboardSending(),
|
||||
m_events->adoptHandler(m_events->forClipboard().clipboardSending(),
|
||||
this,
|
||||
new TMethodEventJob<ClientProxy1_6>(this,
|
||||
&ClientProxy1_6::handleClipboardSendingEvent));
|
||||
|
@ -92,8 +92,7 @@ Server::Server(
|
||||
m_ignoreFileTransfer(false),
|
||||
m_enableDragDrop(enableDragDrop),
|
||||
m_getDragInfoThread(NULL),
|
||||
m_waitDragInfoThread(true),
|
||||
m_dataTransmissionThread(NULL)
|
||||
m_waitDragInfoThread(true)
|
||||
{
|
||||
// must have a primary client and it must have a canonical name
|
||||
assert(m_primaryClient != NULL);
|
||||
@ -506,12 +505,6 @@ Server::switchScreen(BaseClientProxy* dst,
|
||||
m_primaryClient->getToggleMask(),
|
||||
forScreensaver);
|
||||
|
||||
// send the clipboard data to new active screen
|
||||
m_dataTransmissionThread = new Thread(
|
||||
new TMethodJob<Server>(
|
||||
this, &Server::sendClipboardThread,
|
||||
NULL));
|
||||
|
||||
Server::SwitchToScreenInfo* info =
|
||||
Server::SwitchToScreenInfo::alloc(m_active->getName());
|
||||
m_events->addEvent(Event(m_events->forServer().screenSwitched(), this, info));
|
||||
@ -2079,11 +2072,11 @@ Server::addClient(BaseClientProxy* client)
|
||||
client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleShapeChanged, client));
|
||||
m_events->adoptHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||
m_events->adoptHandler(m_events->forClipboard().clipboardGrabbed(),
|
||||
client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleClipboardGrabbed, client));
|
||||
m_events->adoptHandler(m_events->forClientProxy().clipboardChanged(),
|
||||
m_events->adoptHandler(m_events->forClipboard().clipboardChanged(),
|
||||
client->getEventTarget(),
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleClipboardChanged, client));
|
||||
@ -2115,9 +2108,9 @@ Server::removeClient(BaseClientProxy* client)
|
||||
// remove event handlers
|
||||
m_events->removeHandler(m_events->forIScreen().shapeChanged(),
|
||||
client->getEventTarget());
|
||||
m_events->removeHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||
m_events->removeHandler(m_events->forClipboard().clipboardGrabbed(),
|
||||
client->getEventTarget());
|
||||
m_events->removeHandler(m_events->forClientProxy().clipboardChanged(),
|
||||
m_events->removeHandler(m_events->forClipboard().clipboardChanged(),
|
||||
client->getEventTarget());
|
||||
|
||||
// remove from list
|
||||
|
@ -112,7 +112,7 @@ StreamChunker::sendClipboard(
|
||||
String dataSize = synergy::string::sizeTypeToString(size);
|
||||
ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
|
||||
|
||||
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, sizeMessage));
|
||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
|
||||
|
||||
// send clipboard chunk with a fixed size
|
||||
// TODO: 4096 fails and this shouldn't a magic number
|
||||
@ -130,7 +130,7 @@ StreamChunker::sendClipboard(
|
||||
String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
|
||||
ClipboardChunk* dataChunk = ClipboardChunk::data(id, sequence, chunk);
|
||||
|
||||
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, dataChunk));
|
||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
|
||||
|
||||
sentLength += chunkSize;
|
||||
|
||||
@ -145,5 +145,5 @@ StreamChunker::sendClipboard(
|
||||
// send last message
|
||||
ClipboardChunk* end = ClipboardChunk::end(id, sequence);
|
||||
|
||||
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, end));
|
||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, end));
|
||||
}
|
||||
|
@ -61,5 +61,6 @@ public:
|
||||
MOCK_METHOD0(forIKeyState, IKeyStateEvents&());
|
||||
MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&());
|
||||
MOCK_METHOD0(forIScreen, IScreenEvents&());
|
||||
MOCK_METHOD0(forClipboard, ClipboardEvents&());
|
||||
MOCK_CONST_METHOD0(waitForReady, void());
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user