ewk_touch_event.cpp [plain text]
#include "config.h"
#if ENABLE(TOUCH_EVENTS)
#include "PlatformTouchPoint.h"
#include "ewk_touch_event_private.h"
#include <Ecore_Input.h>
#include <wtf/CurrentTime.h>
class WebKitPlatformTouchPoint : public WebCore::PlatformTouchPoint {
public:
WebKitPlatformTouchPoint(unsigned id, const WebCore::IntPoint& windowPos, WebCore::PlatformTouchPoint::State state)
{
m_id = id;
m_state = state;
m_screenPos = windowPos;
m_pos = windowPos;
}
};
class WebKitPlatformTouchEvent : public WebCore::PlatformTouchEvent {
public:
WebKitPlatformTouchEvent(const Eina_List* points, const WebCore::IntPoint& pos, Ewk_Touch_Event_Type action, unsigned modifiers)
{
switch (action) {
case EWK_TOUCH_START:
m_type = WebCore::PlatformEvent::TouchStart;
break;
case EWK_TOUCH_MOVE:
m_type = WebCore::PlatformEvent::TouchMove;
break;
case EWK_TOUCH_END:
m_type = WebCore::PlatformEvent::TouchEnd;
break;
case EWK_TOUCH_CANCEL:
m_type = WebCore::PlatformEvent::TouchCancel;
break;
default:
ASSERT_NOT_REACHED();
break;
}
if (modifiers & ECORE_EVENT_MODIFIER_ALT)
m_modifiers |= WebCore::PlatformEvent::AltKey;
if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
m_modifiers |= WebCore::PlatformEvent::CtrlKey;
if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
m_modifiers |= WebCore::PlatformEvent::ShiftKey;
if (modifiers & ECORE_EVENT_MODIFIER_WIN)
m_modifiers |= WebCore::PlatformEvent::MetaKey;
m_timestamp = currentTime();
const Eina_List* list;
void* item;
EINA_LIST_FOREACH(points, list, item) {
Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
WebCore::IntPoint pnt = WebCore::IntPoint(point->x - pos.x(), point->y - pos.y());
m_touchPoints.append(WebKitPlatformTouchPoint(point->id, pnt, static_cast<WebCore::PlatformTouchPoint::State>(point->state)));
}
}
};
namespace EWKPrivate {
WebCore::PlatformTouchEvent platformTouchEvent(Evas_Coord x, Evas_Coord y, Eina_List* points, Ewk_Touch_Event_Type action, unsigned modifiers)
{
return WebKitPlatformTouchEvent(points, WebCore::IntPoint(x, y), action, modifiers);
}
}
#endif // ENABLE(TOUCH_EVENTS)