void EventSenderProxy::mouseScrollBy(int horizontal, int vertical) { GdkEvent* event = gdk_event_new(GDK_SCROLL); event->scroll.x = m_position.x; event->scroll.y = m_position.y; event->scroll.time = GDK_CURRENT_TIME; event->scroll.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView())); g_object_ref(event->scroll.window); gdk_event_set_device(event, gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(event->scroll.window)))); // For more than one tick in a scroll, we need smooth scroll event if ((horizontal && vertical) || horizontal > 1 || horizontal < -1 || vertical > 1 || vertical < -1) { event->scroll.direction = GDK_SCROLL_SMOOTH; event->scroll.delta_x = -horizontal; event->scroll.delta_y = -vertical; sendOrQueueEvent(event); return; } if (horizontal < 0) event->scroll.direction = GDK_SCROLL_RIGHT; else if (horizontal > 0) event->scroll.direction = GDK_SCROLL_LEFT; else if (vertical < 0) event->scroll.direction = GDK_SCROLL_DOWN; else if (vertical > 0) event->scroll.direction = GDK_SCROLL_UP; else g_assert_not_reached(); sendOrQueueEvent(event); }
void EventSender::continuousMouseScrollBy(int x, int y) { // continuousMouseScrollBy() mimics devices that send fine-grained scroll events where the 'delta' specified is not the usual // multiple of 120. See http://doc.qt.nokia.com/4.6/qwheelevent.html#delta for a good explanation of this. // A wheel delta of 120 (in 1/8 degrees) corresponds to one wheel tick, and we scroll tickStep pixels per wheel tick. const int tickStep = QApplication::wheelScrollLines() * 20; if (x) { QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, (x * 120) / tickStep, Qt::NoModifier, Qt::Horizontal); } else event = new QWheelEvent(m_mousePos, m_mousePos, (x * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Horizontal); sendOrQueueEvent(event); } if (y) { QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, (y * 120) / tickStep, Qt::NoModifier, Qt::Vertical); } else event = new QWheelEvent(m_mousePos, m_mousePos, (y * 120) / tickStep, m_mouseButtons, Qt::NoModifier, Qt::Vertical); sendOrQueueEvent(event); } }
void EventSender::continuousMouseScrollBy(int x, int y) { // continuousMouseScrollBy() mimics devices that send fine-grained scroll events where the 'delta' specified is not the usual // multiple of 120. See http://doc.qt.nokia.com/4.6/qwheelevent.html#delta for a good explanation of this. if (x) { QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, x, Qt::NoModifier, Qt::Horizontal); } else event = new QWheelEvent(m_mousePos, m_mousePos, x, m_mouseButtons, Qt::NoModifier, Qt::Horizontal); sendOrQueueEvent(event); } if (y) { QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel, m_mousePos, m_mousePos, y, Qt::NoModifier, Qt::Vertical); } else event = new QWheelEvent(m_mousePos, m_mousePos, y, m_mouseButtons, Qt::NoModifier, Qt::Vertical); sendOrQueueEvent(event); } }
static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { GdkEvent event; if (!prepareMouseButtonEvent(&event, 3)) return JSValueMakeUndefined(context); event.type = GDK_BUTTON_PRESS; sendOrQueueEvent(event); event.type = GDK_BUTTON_RELEASE; sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { GdkEvent* pressEvent = gdk_event_new(GDK_BUTTON_PRESS); if (!prepareMouseButtonEvent(pressEvent, 2, 0)) return JSValueMakeUndefined(context); GdkEvent* releaseEvent = gdk_event_copy(pressEvent); sendOrQueueEvent(pressEvent); releaseEvent->type = GDK_BUTTON_RELEASE; sendOrQueueEvent(releaseEvent); return JSValueMakeUndefined(context); }
void EventSenderProxy::mouseMoveTo(double x, double y) { m_position.x = x; m_position.y = y; sendOrQueueEvent(WTREvent(WTREventTypeMouseMove, 0, 0, kWKEventMouseButtonNoButton)); }
static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); if (!view) return JSValueMakeUndefined(context); if (argumentCount < 2) return JSValueMakeUndefined(context); lastMousePositionX = (int)JSValueToNumber(context, arguments[0], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); lastMousePositionY = (int)JSValueToNumber(context, arguments[1], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); event->motion.x = lastMousePositionX; event->motion.y = lastMousePositionY; event->motion.time = GDK_CURRENT_TIME; event->motion.window = gtk_widget_get_window(GTK_WIDGET(view)); g_object_ref(event->motion.window); event->button.device = getDefaultGDKPointerDevice(event->motion.window); event->motion.state = getStateFlags(); event->motion.axes = 0; int xRoot, yRoot; gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(view)), lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); event->motion.x_root = xRoot; event->motion.y_root = yRoot; sendOrQueueEvent(event, false); return JSValueMakeUndefined(context); }
static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int button = 1; if (argumentCount == 1) { button = static_cast<int>(JSValueToNumber(context, arguments[0], exception)) + 1; g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); } GdkEvent event; if (!prepareMouseButtonEvent(&event, button)) return JSValueMakeUndefined(context); buttonCurrentlyDown = event.button.button; // Normally GDK will send both GDK_BUTTON_PRESS and GDK_2BUTTON_PRESS for // the second button press during double-clicks. WebKit GTK+ selectively // ignores the first GDK_BUTTON_PRESS of that pair using gdk_event_peek. // Since our events aren't ever going onto the GDK event queue, WebKit won't // be able to filter out the first GDK_BUTTON_PRESS, so we just don't send // it here. Eventually this code should probably figure out a way to get all // appropriate events onto the event queue and this work-around should be // removed. updateClickCount(event.button.button); if (clickCount == 2) event.type = GDK_2BUTTON_PRESS; else if (clickCount == 3) event.type = GDK_3BUTTON_PRESS; else event.type = GDK_BUTTON_PRESS; sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
void EventSender::mouseMoveTo(int x, int y) { // qDebug() << "EventSender::mouseMoveTo" << x << y; m_mousePos = QPoint(x, y); QMouseEvent* event = new QMouseEvent(QEvent::MouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); sendOrQueueEvent(event); }
void EventSender::mouseUp(int button) { Qt::MouseButton mouseButton; switch (button) { case 0: mouseButton = Qt::LeftButton; break; case 1: mouseButton = Qt::MidButton; break; case 2: mouseButton = Qt::RightButton; break; case 3: // fast/events/mouse-click-events expects the 4th button to be treated as the middle button mouseButton = Qt::MidButton; break; default: mouseButton = Qt::LeftButton; break; } m_mouseButtons &= ~mouseButton; // qDebug() << "EventSender::mouseUp" << frame; QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonRelease, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier); sendOrQueueEvent(event); }
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers) { // If the same mouse button is already in the down position don't // send another event as it may confuse Xvfb. unsigned gdkButton = eventSenderButtonToGDKButton(button); if (m_mouseButtonCurrentlyDown == gdkButton) return; m_mouseButtonCurrentlyDown = gdkButton; // Normally GDK will send both GDK_BUTTON_PRESS and GDK_2BUTTON_PRESS for // the second button press during double-clicks. WebKit GTK+ selectively // ignores the first GDK_BUTTON_PRESS of that pair using gdk_event_peek. // Since our events aren't ever going onto the GDK event queue, WebKit won't // be able to filter out the first GDK_BUTTON_PRESS, so we just don't send // it here. Eventually this code should probably figure out a way to get all // appropriate events onto the event queue and this work-around should be // removed. updateClickCountForButton(button); GdkEventType eventType; if (m_clickCount == 2) eventType = GDK_2BUTTON_PRESS; else if (m_clickCount == 3) eventType = GDK_3BUTTON_PRESS; else eventType = GDK_BUTTON_PRESS; GdkEvent* event = createMouseButtonEvent(eventType, button, wkModifiers); sendOrQueueEvent(event); }
void EventSenderProxy::mouseScrollBy(int horizontal, int vertical) { WTREvent event(WTREventTypeMouseScrollBy, 0, 0, kWKEventMouseButtonNoButton); // We need to invert scrolling values since in EFL negative z value means that // canvas is scrolling down event.horizontal = -horizontal; event.vertical = -vertical; sendOrQueueEvent(event); }
void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers) { sendOrQueueEvent(WTREvent(WTREventTypeMouseUp, 0, wkModifiers, evasMouseButton(button))); if (m_mouseButton == button) m_mouseButton = kWKEventMouseButtonNoButton; m_clickPosition = m_position; m_clickTime = ecore_time_get(); }
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers) { if (m_mouseButton == button) return; m_mouseButton = button; updateClickCountForButton(button); sendOrQueueEvent(WTREvent(WTREventTypeMouseDown, 0, wkModifiers, evasMouseButton(button))); }
void EventSenderProxy::mouseMoveTo(double x, double y) { m_position.x = x; m_position.y = y; QPoint mousePos(m_position.x, m_position.y); QMouseEvent* event = new QMouseEvent(QEvent::MouseMove, mousePos, mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); sendOrQueueEvent(event); }
void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers) { Qt::MouseButton mouseButton = getMouseButton(button); m_mouseButtons &= ~mouseButton; QPoint mousePos(m_position.x, m_position.y); QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonRelease, mousePos, mousePos, mouseButton, m_mouseButtons, Qt::NoModifier); sendOrQueueEvent(event); }
void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers) { m_clickButton = kWKEventMouseButtonNoButton; GdkEvent* event = createMouseButtonEvent(GDK_BUTTON_RELEASE, button, wkModifiers); sendOrQueueEvent(event); if (m_mouseButtonCurrentlyDown == event->button.button) m_mouseButtonCurrentlyDown = 0; m_clickPosition = m_position; m_clickTime = GDK_CURRENT_TIME; }
void EventSender::mouseDown(int button, const QStringList& modifiers) { Qt::KeyboardModifiers modifs = getModifiers(modifiers); Qt::MouseButton mouseButton; switch (button) { case 0: mouseButton = Qt::LeftButton; break; case 1: mouseButton = Qt::MidButton; break; case 2: mouseButton = Qt::RightButton; break; case 3: // fast/events/mouse-click-events expects the 4th button to be treated as the middle button mouseButton = Qt::MidButton; break; default: mouseButton = Qt::LeftButton; break; } // only consider a click to count, an event originated by the // same previous button and at the same position. if (m_currentButton == button && m_mousePos == m_clickPos && m_clickTimer.isActive()) m_clickCount++; else m_clickCount = 1; m_currentButton = button; m_clickPos = m_mousePos; m_mouseButtons |= mouseButton; // qDebug() << "EventSender::mouseDown" << frame; QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneMouseEvent((m_clickCount == 2) ? QEvent::GraphicsSceneMouseDoubleClick : QEvent::GraphicsSceneMousePress, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, modifs); } else { event = new QMouseEvent((m_clickCount == 2) ? QEvent::MouseButtonDblClick : QEvent::MouseButtonPress, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, modifs); } sendOrQueueEvent(event); m_clickTimer.start(QApplication::doubleClickInterval(), this); }
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers) { Qt::KeyboardModifiers modifiers = getModifiers(wkModifiers); Qt::MouseButton mouseButton = getMouseButton(button); updateClickCountForButton(button); m_mouseButtons |= mouseButton; QPoint mousePos(m_position.x, m_position.y); QMouseEvent* event = new QMouseEvent((m_clickCount == 2) ? QEvent::MouseButtonDblClick : QEvent::MouseButtonPress, mousePos, mousePos, mouseButton, m_mouseButtons, modifiers); sendOrQueueEvent(event); }
void EventSender::mouseMoveTo(int x, int y) { // qDebug() << "EventSender::mouseMoveTo" << x << y; m_mousePos = QPoint(x, y); QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); } else { event = new QMouseEvent(QEvent::MouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); } sendOrQueueEvent(event); }
void EventSender::mouseUp(int button) { Qt::MouseButton mouseButton; switch (button) { case 0: mouseButton = Qt::LeftButton; break; case 1: mouseButton = Qt::MidButton; break; case 2: mouseButton = Qt::RightButton; break; case 3: // fast/events/mouse-click-events expects the 4th button to be treated as the middle button mouseButton = Qt::MidButton; break; default: mouseButton = Qt::LeftButton; break; } m_mouseButtons &= ~mouseButton; // qDebug() << "EventSender::mouseUp" << frame; QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseRelease, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier); } else { event = new QMouseEvent(QEvent::MouseButtonRelease, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier); } sendOrQueueEvent(event); if (m_currentDragData.urls().isEmpty()) return; event = new QDropEvent(m_mousePos, m_currentDragActionsAllowed, &m_currentDragData, m_mouseButtons, Qt::NoModifier); sendEvent(m_page, event); m_currentDragData.clear(); }
void EventSenderProxy::continuousMouseScrollBy(int horizontal, int vertical, bool paged) { // Gtk+ does not support paged scroll events. g_return_if_fail(!paged); GdkEvent* event = gdk_event_new(GDK_SCROLL); event->scroll.x = m_position.x; event->scroll.y = m_position.y; event->scroll.time = GDK_CURRENT_TIME; event->scroll.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView())); g_object_ref(event->scroll.window); gdk_event_set_device(event, gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(event->scroll.window)))); event->scroll.direction = GDK_SCROLL_SMOOTH; event->scroll.delta_x = -horizontal / pixelsPerScrollTick; event->scroll.delta_y = -vertical / pixelsPerScrollTick; sendOrQueueEvent(event); }
static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int button = 1; if (argumentCount == 1) { button = static_cast<int>(JSValueToNumber(context, arguments[0], exception)) + 1; g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); } GdkEvent event; if (!prepareMouseButtonEvent(&event, button)) return JSValueMakeUndefined(context); lastClickPositionX = lastMousePositionX; lastClickPositionY = lastMousePositionY; lastClickButton = buttonCurrentlyDown; lastClickTimeOffset = timeOffset; buttonCurrentlyDown = 0; event.type = GDK_BUTTON_RELEASE; sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int button = 0; if (argumentCount == 1) { button = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); } guint modifiers = argumentCount >= 2 ? gdkModifersFromJSValue(context, arguments[1]) : 0; GdkEvent* event = gdk_event_new(GDK_BUTTON_RELEASE); if (!prepareMouseButtonEvent(event, button, modifiers)) return JSValueMakeUndefined(context); lastClickPositionX = lastMousePositionX; lastClickPositionY = lastMousePositionY; lastClickButton = buttonCurrentlyDown; lastClickTimeOffset = timeOffset; buttonCurrentlyDown = 0; sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
static JSValueRef mouseWheelToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); if (!view) return JSValueMakeUndefined(context); if (argumentCount < 2) return JSValueMakeUndefined(context); int horizontal = (int)JSValueToNumber(context, arguments[0], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); int vertical = (int)JSValueToNumber(context, arguments[1], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); // GTK+ doesn't support multiple direction scrolls in the same event! g_return_val_if_fail((!vertical || !horizontal), JSValueMakeUndefined(context)); GdkEvent event; event.type = GDK_SCROLL; event.scroll.x = lastMousePositionX; event.scroll.y = lastMousePositionY; event.scroll.time = GDK_CURRENT_TIME; event.scroll.window = GTK_WIDGET(view)->window; if (horizontal < 0) event.scroll.direction = GDK_SCROLL_LEFT; else if (horizontal > 0) event.scroll.direction = GDK_SCROLL_RIGHT; else if (vertical < 0) event.scroll.direction = GDK_SCROLL_UP; else if (vertical > 0) event.scroll.direction = GDK_SCROLL_DOWN; else g_assert_not_reached(); sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
void EventSenderProxy::mouseMoveTo(double x, double y) { m_position.x = x; m_position.y = y; GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); event->motion.x = m_position.x; event->motion.y = m_position.y; event->motion.time = GDK_CURRENT_TIME; event->motion.window = gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView())); g_object_ref(event->motion.window); gdk_event_set_device(event, gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_window_get_display(event->motion.window)))); event->motion.state = 0 | getMouseButtonModifiers(m_mouseButtonCurrentlyDown); event->motion.axes = 0; int xRoot, yRoot; gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(m_testController->mainWebView()->platformView())), m_position.x, m_position.y , &xRoot, &yRoot); event->motion.x_root = xRoot; event->motion.y_root = yRoot; sendOrQueueEvent(event); }
void EventSender::mouseMoveTo(int x, int y) { // qDebug() << "EventSender::mouseMoveTo" << x << y; m_mousePos = QPoint(x, y); QEvent* event; if (isGraphicsBased()) { event = createGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); } else { event = new QMouseEvent(QEvent::MouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier); } sendOrQueueEvent(event); if (m_currentDragData.urls().isEmpty()) return; Qt::MouseButtons mouseButtons = m_mouseButtons | Qt::LeftButton; event = new QDragMoveEvent(m_mousePos, m_currentDragActionsAllowed, &m_currentDragData, mouseButtons, Qt::NoModifier); sendEvent(m_page, event); }
static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); if (!view) return JSValueMakeUndefined(context); if (argumentCount < 2) return JSValueMakeUndefined(context); lastMousePositionX = (int)JSValueToNumber(context, arguments[0], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); lastMousePositionY = (int)JSValueToNumber(context, arguments[1], exception); g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); GdkEvent event; memset(&event, 0, sizeof(event)); event.type = GDK_MOTION_NOTIFY; event.motion.x = lastMousePositionX; event.motion.y = lastMousePositionY; event.motion.time = GDK_CURRENT_TIME; event.motion.window = GTK_WIDGET(view)->window; event.motion.device = gdk_device_get_core_pointer(); event.motion.state = getStateFlags(); int xRoot, yRoot; #if GTK_CHECK_VERSION(2,17,3) gdk_window_get_root_coords(GTK_WIDGET(view)->window, lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); #else getRootCoords(GTK_WIDGET(view), &xRoot, &yRoot); #endif event.motion.x_root = xRoot; event.motion.y_root = yRoot; sendOrQueueEvent(event); return JSValueMakeUndefined(context); }
void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers modifiersRef, unsigned location) { const QString key = WKStringCopyQString(keyRef); QString keyText = key; Qt::KeyboardModifiers modifiers = getModifiers(modifiersRef); if (location == 3) modifiers |= Qt::KeypadModifier; int code = 0; if (key.length() == 1) { code = key.unicode()->unicode(); // map special keycodes used by the tests to something that works for Qt/X11 if (code == '\r') { code = Qt::Key_Return; } else if (code == '\t') { code = Qt::Key_Tab; if (modifiers == Qt::ShiftModifier) code = Qt::Key_Backtab; keyText = QString(); } else if (code == KEYCODE_DEL || code == KEYCODE_BACKSPACE) { code = Qt::Key_Backspace; if (modifiers == Qt::AltModifier) modifiers = Qt::ControlModifier; keyText = QString(); } else if (code == 'o' && modifiers == Qt::ControlModifier) { // Mimic the emacs ctrl-o binding on Mac by inserting a paragraph // separator and then putting the cursor back to its original // position. Allows us to pass emacs-ctrl-o.html keyText = QLatin1String("\n"); code = '\n'; modifiers = 0; QKeyEvent event(QEvent::KeyPress, code, modifiers, keyText); m_testController->mainWebView()->sendEvent(&event); QKeyEvent event2(QEvent::KeyRelease, code, modifiers, keyText); m_testController->mainWebView()->sendEvent(&event2); keyText = QString(); code = Qt::Key_Left; } else if (code == 'y' && modifiers == Qt::ControlModifier) { keyText = QLatin1String("c"); code = 'c'; } else if (code == 'k' && modifiers == Qt::ControlModifier) { keyText = QLatin1String("x"); code = 'x'; } else if (code == 'a' && modifiers == Qt::ControlModifier) { keyText = QString(); code = Qt::Key_Home; modifiers = 0; } else if (code == KEYCODE_LEFTARROW) { keyText = QString(); code = Qt::Key_Left; if (modifiers & Qt::MetaModifier) { code = Qt::Key_Home; modifiers &= ~Qt::MetaModifier; } } else if (code == KEYCODE_RIGHTARROW) { keyText = QString(); code = Qt::Key_Right; if (modifiers & Qt::MetaModifier) { code = Qt::Key_End; modifiers &= ~Qt::MetaModifier; } } else if (code == KEYCODE_UPARROW) { keyText = QString(); code = Qt::Key_Up; if (modifiers & Qt::MetaModifier) { code = Qt::Key_PageUp; modifiers &= ~Qt::MetaModifier; } } else if (code == KEYCODE_DOWNARROW) { keyText = QString(); code = Qt::Key_Down; if (modifiers & Qt::MetaModifier) { code = Qt::Key_PageDown; modifiers &= ~Qt::MetaModifier; } } else if (code == 'a' && modifiers == Qt::ControlModifier) { keyText = QString(); code = Qt::Key_Home; modifiers = 0; } else code = key.unicode()->toUpper().unicode(); } else { if (key.startsWith(QLatin1Char('F')) && key.count() <= 3) { keyText = keyText.mid(1); int functionKey = keyText.toInt(); Q_ASSERT(functionKey >= 1 && functionKey <= 35); code = Qt::Key_F1 + (functionKey - 1); // map special keycode strings used by the tests to something that works for Qt/X11 } else if (key == QLatin1String("leftArrow")) { keyText = QString(); code = Qt::Key_Left; } else if (key == QLatin1String("rightArrow")) { keyText = QString(); code = Qt::Key_Right; } else if (key == QLatin1String("upArrow")) { keyText = QString(); code = Qt::Key_Up; } else if (key == QLatin1String("downArrow")) { keyText = QString(); code = Qt::Key_Down; } else if (key == QLatin1String("pageUp")) { keyText = QString(); code = Qt::Key_PageUp; } else if (key == QLatin1String("pageDown")) { keyText = QString(); code = Qt::Key_PageDown; } else if (key == QLatin1String("home")) { keyText = QString(); code = Qt::Key_Home; } else if (key == QLatin1String("end")) { keyText = QString(); code = Qt::Key_End; } else if (key == QLatin1String("insert")) { keyText = QString(); code = Qt::Key_Insert; } else if (key == QLatin1String("delete")) { keyText = QString(); code = Qt::Key_Delete; } else if (key == QLatin1String("printScreen")) { keyText = QString(); code = Qt::Key_Print; } else if (key == QLatin1String("menu")) { keyText = QString(); code = Qt::Key_Menu; } } QKeyEvent* pressEvent = new QKeyEvent(QEvent::KeyPress, code, modifiers, keyText); sendOrQueueEvent(pressEvent); QKeyEvent* releaseEvent = new QKeyEvent(QEvent::KeyRelease, code, modifiers, keyText); sendOrQueueEvent(releaseEvent); }