summaryrefslogtreecommitdiff
path: root/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Shared/gtk/WebEventFactory.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebKit2/Shared/gtk/WebEventFactory.cpp')
-rw-r--r--Source/WebKit2/Shared/gtk/WebEventFactory.cpp104
1 files changed, 31 insertions, 73 deletions
diff --git a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
index 462b11b89..afb5f8451 100644
--- a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
+++ b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp
@@ -63,6 +63,8 @@ static inline WebEvent::Modifiers modifiersForEvent(const GdkEvent* event)
modifiers |= WebEvent::AltKey;
if (state & GDK_META_MASK)
modifiers |= WebEvent::MetaKey;
+ if (PlatformKeyboardEvent::modifiersContainCapsLock(state))
+ modifiers |= WebEvent::CapsLockKey;
return static_cast<WebEvent::Modifiers>(modifiers);
}
@@ -72,15 +74,20 @@ static inline WebMouseEvent::Button buttonForEvent(const GdkEvent* event)
unsigned button = 0;
switch (event->type) {
- case GDK_MOTION_NOTIFY:
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ case GDK_MOTION_NOTIFY: {
button = WebMouseEvent::NoButton;
- if (event->motion.state & GDK_BUTTON1_MASK)
+ GdkModifierType state;
+ gdk_event_get_state(event, &state);
+ if (state & GDK_BUTTON1_MASK)
button = WebMouseEvent::LeftButton;
- else if (event->motion.state & GDK_BUTTON2_MASK)
+ else if (state & GDK_BUTTON2_MASK)
button = WebMouseEvent::MiddleButton;
- else if (event->motion.state & GDK_BUTTON3_MASK)
+ else if (state & GDK_BUTTON3_MASK)
button = WebMouseEvent::RightButton;
break;
+ }
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
@@ -108,6 +115,8 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int cu
WebEvent::Type type = static_cast<WebEvent::Type>(0);
switch (event->type) {
case GDK_MOTION_NOTIFY:
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
type = WebEvent::MouseMove;
break;
case GDK_BUTTON_PRESS:
@@ -181,69 +190,28 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event)
gdk_event_get_time(event));
}
-WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults)
-{
- unsigned int keyValue = event->key.keyval;
- String text = compositionResults.simpleString.length() ?
- compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(keyValue);
-
- int windowsVirtualKeyCode = compositionResults.compositionUpdated() ?
- VK_PROCESSKEY : PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval);
-
- return WebKeyboardEvent((event->type == GDK_KEY_RELEASE) ? WebEvent::KeyUp : WebEvent::KeyDown,
- text,
- text,
- PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyValue),
- windowsVirtualKeyCode,
- static_cast<int>(keyValue),
- 0 /* macCharCode */,
- false /* isAutoRepeat */,
- isGdkKeyCodeFromKeyPad(keyValue),
- false /* isSystemKey */,
- modifiersForEvent(event),
- gdk_event_get_time(event));
-}
-
-#ifndef GTK_API_VERSION_2
-static WebPlatformTouchPoint::TouchPointState touchPhaseFromEvents(const GdkEvent* current, const GdkEvent* event)
-{
- if (gdk_event_get_event_sequence(current) != gdk_event_get_event_sequence(event))
- return WebPlatformTouchPoint::TouchStationary;
-
- switch (current->type) {
- case GDK_TOUCH_UPDATE:
- return WebPlatformTouchPoint::TouchMoved;
- case GDK_TOUCH_BEGIN:
- return WebPlatformTouchPoint::TouchPressed;
- case GDK_TOUCH_END:
- return WebPlatformTouchPoint::TouchReleased;
- default:
- return WebPlatformTouchPoint::TouchStationary;
- }
-}
-
-static void appendTouchEvent(Vector<WebPlatformTouchPoint>& touchPointList, const GdkEvent* event, WebPlatformTouchPoint::TouchPointState state)
+WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(const GdkEvent* event, const WebCore::CompositionResults& compositionResults, Vector<String>&& commands)
{
- uint32_t identifier = GPOINTER_TO_UINT(gdk_event_get_event_sequence(event));
-
- gdouble x, y;
- gdk_event_get_coords(event, &x, &y);
-
- gdouble xRoot, yRoot;
- gdk_event_get_root_coords(event, &xRoot, &yRoot);
-
- WebPlatformTouchPoint touchPoint(identifier, state, IntPoint(xRoot, yRoot), IntPoint(x, y));
- touchPointList.uncheckedAppend(touchPoint);
+ return WebKeyboardEvent(
+ event->type == GDK_KEY_RELEASE ? WebEvent::KeyUp : WebEvent::KeyDown,
+ compositionResults.simpleString.length() ? compositionResults.simpleString : PlatformKeyboardEvent::singleCharacterString(event->key.keyval),
+ PlatformKeyboardEvent::keyValueForGdkKeyCode(event->key.keyval),
+ PlatformKeyboardEvent::keyCodeForHardwareKeyCode(event->key.hardware_keycode),
+ PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(event->key.keyval),
+ PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(event->key.keyval),
+ static_cast<int>(event->key.keyval),
+ compositionResults.compositionUpdated(),
+ WTFMove(commands),
+ isGdkKeyCodeFromKeyPad(event->key.keyval),
+ modifiersForEvent(event),
+ gdk_event_get_time(event));
}
-#endif // GTK_API_VERSION_2
-WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, const WebCore::GtkTouchContextHelper& touchContext)
+#if ENABLE(TOUCH_EVENTS)
+WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, Vector<WebPlatformTouchPoint>&& touchPoints)
{
#ifndef GTK_API_VERSION_2
WebEvent::Type type = WebEvent::NoType;
- const auto& touchEvents = touchContext.touchEvents();
- int numEvents = touchEvents.size();
-
switch (event->type) {
case GDK_TOUCH_BEGIN:
type = WebEvent::TouchStart;
@@ -253,26 +221,16 @@ WebTouchEvent WebEventFactory::createWebTouchEvent(const GdkEvent* event, const
break;
case GDK_TOUCH_END:
type = WebEvent::TouchEnd;
- ++numEvents;
break;
default:
ASSERT_NOT_REACHED();
}
- Vector<WebPlatformTouchPoint> touchPointList;
- touchPointList.reserveInitialCapacity(numEvents);
-
- for (auto it = touchEvents.begin(); it != touchEvents.end(); ++it)
- appendTouchEvent(touchPointList, it->value.get(), touchPhaseFromEvents(it->value.get(), event));
-
- // Touch was already removed from the GtkTouchContextHelper, add it here.
- if (event->type == GDK_TOUCH_END)
- appendTouchEvent(touchPointList, event, WebPlatformTouchPoint::TouchReleased);
-
- return WebTouchEvent(type, touchPointList, modifiersForEvent(event), gdk_event_get_time(event));
+ return WebTouchEvent(type, WTFMove(touchPoints), modifiersForEvent(event), gdk_event_get_time(event));
#else
return WebTouchEvent();
#endif // GTK_API_VERSION_2
}
+#endif
} // namespace WebKit