barrier/src/lib/base/Event.cpp

101 lines
1.7 KiB
C++
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* synergy -- mouse and keyboard sharing utility
2016-09-07 14:24:00 +00:00
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
2012-06-10 16:50:54 +00:00
*
* 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 LICENSE that should have accompanied this file.
2012-06-10 16:50:54 +00:00
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/Event.h"
#include "base/EventQueue.h"
2012-06-10 16:50:54 +00:00
//
2014-11-11 13:51:47 +00:00
// Event
2012-06-10 16:50:54 +00:00
//
2014-11-11 13:51:47 +00:00
Event::Event() :
2012-06-10 16:50:54 +00:00
m_type(kUnknown),
m_target(NULL),
m_data(NULL),
m_flags(0),
m_dataObject(nullptr)
2012-06-10 16:50:54 +00:00
{
// do nothing
}
2014-11-11 13:51:47 +00:00
Event::Event(Type type, void* target, void* data, Flags flags) :
2012-06-10 16:50:54 +00:00
m_type(type),
m_target(target),
m_data(data),
m_flags(flags),
m_dataObject(nullptr)
2012-06-10 16:50:54 +00:00
{
// do nothing
}
2014-11-11 13:51:47 +00:00
Event::Type
Event::getType() const
2012-06-10 16:50:54 +00:00
{
return m_type;
}
void*
2014-11-11 13:51:47 +00:00
Event::getTarget() const
2012-06-10 16:50:54 +00:00
{
return m_target;
}
void*
2014-11-11 13:51:47 +00:00
Event::getData() const
2012-06-10 16:50:54 +00:00
{
return m_data;
}
2014-11-11 13:51:47 +00:00
EventData*
Event::getDataObject() const
{
return m_dataObject;
}
2014-11-11 13:51:47 +00:00
Event::Flags
Event::getFlags() const
2012-06-10 16:50:54 +00:00
{
return m_flags;
}
void
2014-11-11 13:51:47 +00:00
Event::deleteData(const Event& event)
2012-06-10 16:50:54 +00:00
{
switch (event.getType()) {
case kUnknown:
case kQuit:
case kSystem:
case kTimer:
break;
default:
if ((event.getFlags() & kDontFreeData) == 0) {
free(event.getData());
delete event.getDataObject();
2012-06-10 16:50:54 +00:00
}
break;
}
}
void
2014-11-11 13:51:47 +00:00
Event::setDataObject(EventData* dataObject)
{
assert(m_dataObject == nullptr);
m_dataObject = dataObject;
}