deskflow/src/lib/base/Event.cpp

98 lines
2 KiB
C++
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- 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
//
Event::Event() : m_type(kUnknown), m_target(NULL), m_data(NULL), m_flags(0), m_dataObject(nullptr)
{
// do nothing
2012-06-10 16:50:54 +00:00
}
Event::Event(Type type, void *target, void *data, Flags flags)
: m_type(type),
m_target(target),
m_data(data),
m_flags(flags),
m_dataObject(nullptr)
{
// do nothing
2012-06-10 16:50:54 +00:00
}
Event::Event(Type type, void *target, EventData *dataObject)
: m_type(type),
m_target(target),
m_data(nullptr),
m_flags(kNone),
m_dataObject(dataObject)
{
}
Event::Type Event::getType() const
{
return m_type;
}
void *Event::getTarget() const
{
return m_target;
}
2012-06-10 16:50:54 +00:00
void *Event::getData() const
{
return m_data;
}
2012-06-10 16:50:54 +00:00
EventData *Event::getDataObject() const
{
return m_dataObject;
}
Event::Flags Event::getFlags() const
{
return m_flags;
}
2012-06-10 16:50:54 +00:00
void Event::deleteData(const Event &event)
{
switch (event.getType()) {
case kUnknown:
case kQuit:
case kSystem:
case kTimer:
break;
2012-06-10 16:50:54 +00:00
default:
if ((event.getFlags() & kDontFreeData) == 0) {
free(event.getData());
delete event.getDataObject();
}
break;
}
2012-06-10 16:50:54 +00:00
}
void Event::setDataObject(EventData *dataObject)
{
assert(m_dataObject == nullptr);
m_dataObject = dataObject;
}