[GTK] Ensure generated events have given modifiers GDK understands
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Feb 2014 12:42:40 +0000 (12:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Feb 2014 12:42:40 +0000 (12:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128171

Patch by Carlos Garnacho <carlosg@gnome.org> on 2014-02-04
Reviewed by Carlos Garcia Campos.

* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::webkitModifiersToGDKModifiers): Move around
(WTR::EventSenderProxy::createMouseButtonEvent):
(WTR::EventSenderProxy::keyDown): Use webkitModifiersToGDKModifiers to
translate WKEventModifiers.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163373 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp

index d86bdcc..d118a81 100644 (file)
@@ -1,3 +1,16 @@
+2014-02-04  Carlos Garnacho  <carlosg@gnome.org>
+
+        [GTK] Ensure generated events have given modifiers GDK understands
+        https://bugs.webkit.org/show_bug.cgi?id=128171
+
+        Reviewed by Carlos Garcia Campos.
+
+        * WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
+        (WTR::webkitModifiersToGDKModifiers): Move around
+        (WTR::EventSenderProxy::createMouseButtonEvent):
+        (WTR::EventSenderProxy::keyDown): Use webkitModifiersToGDKModifiers to
+        translate WKEventModifiers.
+
 2014-02-04  Gabor Rapcsanyi  <rgabor@webkit.org>
 
         Fine tuning the ARM EFL bots
index 380438c..40f659e 100644 (file)
@@ -109,6 +109,22 @@ static unsigned eventSenderButtonToGDKButton(unsigned button)
     return mouseButton;
 }
 
+static guint webkitModifiersToGDKModifiers(WKEventModifiers wkModifiers)
+{
+    guint modifiers = 0;
+
+    if (wkModifiers & kWKEventModifiersControlKey)
+        modifiers |= GDK_CONTROL_MASK;
+    if (wkModifiers & kWKEventModifiersShiftKey)
+        modifiers |= GDK_SHIFT_MASK;
+    if (wkModifiers & kWKEventModifiersAltKey)
+        modifiers |= GDK_MOD1_MASK;
+    if (wkModifiers & kWKEventModifiersMetaKey)
+        modifiers |= GDK_META_MASK;
+
+    return modifiers;
+}
+
 GdkEvent* EventSenderProxy::createMouseButtonEvent(GdkEventType eventType, unsigned button, WKEventModifiers modifiers)
 {
     GdkEvent* mouseEvent = gdk_event_new(eventType);
@@ -119,7 +135,7 @@ GdkEvent* EventSenderProxy::createMouseButtonEvent(GdkEventType eventType, unsig
     mouseEvent->button.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView()));
     g_object_ref(mouseEvent->button.window);
     gdk_event_set_device(mouseEvent, gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(mouseEvent->button.window))));
-    mouseEvent->button.state = modifiers | getMouseButtonModifiers(mouseEvent->button.button);
+    mouseEvent->button.state = webkitModifiersToGDKModifiers(modifiers) | getMouseButtonModifiers(mouseEvent->button.button);
     mouseEvent->button.time = GDK_CURRENT_TIME;
     mouseEvent->button.axes = 0;
 
@@ -173,22 +189,6 @@ void EventSenderProxy::sendOrQueueEvent(GdkEvent* event)
     replaySavedEvents();
 }
 
-static guint webkitModifiersToGDKModifiers(WKEventModifiers wkModifiers)
-{
-    guint modifiers = 0;
-
-    if (wkModifiers & kWKEventModifiersControlKey)
-        modifiers |= GDK_CONTROL_MASK;
-    if (wkModifiers & kWKEventModifiersShiftKey)
-        modifiers |= GDK_SHIFT_MASK;
-    if (wkModifiers & kWKEventModifiersAltKey)
-        modifiers |= GDK_MOD1_MASK;
-    if (wkModifiers & kWKEventModifiersMetaKey)
-        modifiers |= GDK_META_MASK;
-
-    return modifiers;
-}
-
 int getGDKKeySymForKeyRef(WKStringRef keyRef, unsigned location, guint* modifiers)
 {
     if (location == DOMKeyLocationNumpad) {
@@ -290,7 +290,7 @@ void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers,
 
     GdkEvent* pressEvent = gdk_event_new(GDK_KEY_PRESS);
     pressEvent->key.keyval = gdkKeySym;
-    pressEvent->key.state = modifiers;
+    pressEvent->key.state = webkitModifiersToGDKModifiers(modifiers);
     pressEvent->key.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformWindow()));
     g_object_ref(pressEvent->key.window);
     gdk_event_set_device(pressEvent, gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(pressEvent->key.window))));