mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-08 23:14:20 +08:00
Checkpointing centralized event queue stuff. Currently have:
an event queue and events, TCP sockets converted to use events, unix multithreading and network stuff converted, and an X Windows event queue subclass.
This commit is contained in:
89
lib/base/CEvent.cpp
Normal file
89
lib/base/CEvent.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2004 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file COPYING that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "CEvent.h"
|
||||
|
||||
//
|
||||
// CEvent
|
||||
//
|
||||
|
||||
CEvent::Type CEvent::s_nextType = kLast;
|
||||
|
||||
CEvent::CEvent() :
|
||||
m_type(kUnknown),
|
||||
m_target(NULL),
|
||||
m_data(NULL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CEvent::CEvent(Type type, void* target, void* data) :
|
||||
m_type(type),
|
||||
m_target(target),
|
||||
m_data(data)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void*
|
||||
CEvent::getTarget() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
void*
|
||||
CEvent::getData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::registerType()
|
||||
{
|
||||
// FIXME -- lock mutex (need a mutex)
|
||||
return s_nextType++;
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::registerTypeOnce(Type& type)
|
||||
{
|
||||
// FIXME -- lock mutex (need a mutex)
|
||||
if (type == CEvent::kUnknown) {
|
||||
type = s_nextType++;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
CEvent::deleteData(const CEvent& event)
|
||||
{
|
||||
switch (event.getType()) {
|
||||
case kUnknown:
|
||||
case kQuit:
|
||||
case kSystem:
|
||||
case kTimer:
|
||||
break;
|
||||
|
||||
default:
|
||||
// yes, really delete void*
|
||||
delete event.getData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user