2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2012-09-04 02:09:56 +00:00
|
|
|
* Copyright (C) 2012 Bolton Software 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 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#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),
|
2012-07-10 01:51:51 +00:00
|
|
|
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),
|
2012-07-10 01:51:51 +00:00
|
|
|
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
|
2012-07-10 01:51:51 +00:00
|
|
|
{
|
|
|
|
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());
|
2012-07-10 01:51:51 +00:00
|
|
|
delete event.getDataObject();
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-10 01:51:51 +00:00
|
|
|
|
|
|
|
void
|
2014-11-11 13:51:47 +00:00
|
|
|
Event::setDataObject(EventData* dataObject)
|
2012-07-10 01:51:51 +00:00
|
|
|
{
|
|
|
|
assert(m_dataObject == nullptr);
|
|
|
|
m_dataObject = dataObject;
|
|
|
|
}
|