mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-09 21:25:55 +08:00
initial revision of synergy. currently semi-supports X windows
on unix, but client screens don't simulate events other than mouse move. also not supporting clipboard at all yet and the main app is just a temporary framework to test with. must clean up protocol and communication.
This commit is contained in:
80
CEventQueue.cpp
Normal file
80
CEventQueue.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "CEventQueue.h"
|
||||
|
||||
//
|
||||
// IEventQueue
|
||||
//
|
||||
|
||||
IEventQueue* IEventQueue::s_instance = NULL;
|
||||
|
||||
IEventQueue::IEventQueue()
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
IEventQueue::~IEventQueue()
|
||||
{
|
||||
s_instance = NULL;
|
||||
}
|
||||
|
||||
IEventQueue* IEventQueue::getInstance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// CEventQueue
|
||||
//
|
||||
|
||||
CEventQueue::CEventQueue()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CEventQueue::~CEventQueue()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void CEventQueue::pop(CEvent* event)
|
||||
{
|
||||
assert(event != NULL);
|
||||
|
||||
// wait for an event
|
||||
while (isEmpty())
|
||||
wait(-1.0);
|
||||
|
||||
// lock the queue, extract an event, then unlock
|
||||
lock();
|
||||
*event = m_queue.front();
|
||||
m_queue.pop_front();
|
||||
unlock();
|
||||
}
|
||||
|
||||
void CEventQueue::push(const CEvent* event)
|
||||
{
|
||||
// put the event at the end of the queue and signal that the queue
|
||||
// is not empty
|
||||
lock();
|
||||
m_queue.push_back(*event);
|
||||
signalNotEmpty();
|
||||
unlock();
|
||||
}
|
||||
|
||||
bool CEventQueue::isEmpty()
|
||||
{
|
||||
lock();
|
||||
bool e = m_queue.empty();
|
||||
unlock();
|
||||
|
||||
// if queue is empty then poll to see if more stuff is ready to go
|
||||
// on the queue and check again if the queue is empty.
|
||||
if (e) {
|
||||
wait(0.0);
|
||||
lock();
|
||||
e = m_queue.empty();
|
||||
unlock();
|
||||
}
|
||||
return e;
|
||||
}
|
||||
Reference in New Issue
Block a user