2
* Copyright (C) 2012 Samsung Electronics
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#if ENABLE(TOUCH_EVENTS)
30
#include "PlatformTouchPoint.h"
31
#include "ewk_touch_event_private.h"
32
#include <Ecore_Input.h>
33
#include <wtf/CurrentTime.h>
35
class WebKitPlatformTouchPoint : public WebCore::PlatformTouchPoint {
37
WebKitPlatformTouchPoint(unsigned id, const WebCore::IntPoint& windowPos, WebCore::PlatformTouchPoint::State state)
41
m_screenPos = windowPos;
46
class WebKitPlatformTouchEvent : public WebCore::PlatformTouchEvent {
48
WebKitPlatformTouchEvent(const Eina_List* points, const WebCore::IntPoint& pos, Ewk_Touch_Event_Type action, unsigned modifiers)
52
m_type = WebCore::PlatformEvent::TouchStart;
55
m_type = WebCore::PlatformEvent::TouchMove;
58
m_type = WebCore::PlatformEvent::TouchEnd;
60
case EWK_TOUCH_CANCEL:
61
m_type = WebCore::PlatformEvent::TouchCancel;
68
if (modifiers & ECORE_EVENT_MODIFIER_ALT)
69
m_modifiers |= WebCore::PlatformEvent::AltKey;
70
if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
71
m_modifiers |= WebCore::PlatformEvent::CtrlKey;
72
if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
73
m_modifiers |= WebCore::PlatformEvent::ShiftKey;
74
if (modifiers & ECORE_EVENT_MODIFIER_WIN)
75
m_modifiers |= WebCore::PlatformEvent::MetaKey;
77
m_timestamp = currentTime();
79
const Eina_List* list;
81
EINA_LIST_FOREACH(points, list, item) {
82
Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
83
WebCore::IntPoint pnt = WebCore::IntPoint(point->x - pos.x(), point->y - pos.y());
84
m_touchPoints.append(WebKitPlatformTouchPoint(point->id, pnt, static_cast<WebCore::PlatformTouchPoint::State>(point->state)));
89
namespace EWKPrivate {
91
WebCore::PlatformTouchEvent platformTouchEvent(Evas_Coord x, Evas_Coord y, Eina_List* points, Ewk_Touch_Event_Type action, unsigned modifiers)
93
return WebKitPlatformTouchEvent(points, WebCore::IntPoint(x, y), action, modifiers);
98
#endif // ENABLE(TOUCH_EVENTS)