Exemplo n.º 1
0
void DesktopWindowLinux::updateClickCount(const XButtonPressedEvent* event)
{
    if (m_lastClickX != event->x
        || m_lastClickY != event->y
        || m_lastClickButton != convertXEventButtonToNativeMouseButton(event->button)
        || event->time - m_lastClickTime >= DOUBLE_CLICK_INTERVAL)
        m_clickCount = 1;
    else
        ++m_clickCount;

    m_lastClickX = event->x;
    m_lastClickY = event->y;
    m_lastClickButton = convertXEventButtonToNativeMouseButton(event->button);
    m_lastClickTime = event->time;
}
Exemplo n.º 2
0
void BrowserControl::handleButtonPressEvent(const XButtonPressedEvent& event)
{
    if (event.button == 4 || event.button == 5) {
        const float pixelsPerStep = 40.0f;

        NIXWheelEvent ev;
        ev.type = kNIXInputEventTypeWheel;
        ev.modifiers = convertXEventModifiersToNativeModifiers(event.state);
        ev.timestamp = convertXEventTimeToNixTimestamp(event.time);
        ev.x = event.x;
        ev.y = event.y;
        ev.globalX = event.x_root;
        ev.globalY = event.y_root;
        ev.delta = pixelsPerStep * (event.button == 4 ? 1 : -1);
        ev.orientation = event.state & Mod1Mask ? kNIXWheelEventOrientationHorizontal : kNIXWheelEventOrientationVertical;
        m_client->handleMouseWheel(&ev);
        return;
    }
    updateClickCount(event);

    NIXMouseEvent ev;
    ev.type = kNIXInputEventTypeMouseDown;
    ev.button = convertXEventButtonToNativeMouseButton(event.button);
    ev.x = event.x;
    ev.y = event.y;
    ev.globalX = event.x_root;
    ev.globalY = event.y_root;
    ev.clickCount = m_clickCount;
    ev.modifiers = convertXEventModifiersToNativeModifiers(event.state);
    ev.timestamp = convertXEventTimeToNixTimestamp(event.time);
    m_client->handleMousePress(&ev);

    passFocusToWebView();
}
Exemplo n.º 3
0
void MiniBrowser::updateClickCount(const XButtonPressedEvent& event)
{
    if (m_lastClickX != event.x
        || m_lastClickY != event.y
        || m_lastClickButton != event.button
        || event.time - m_lastClickTime >= doubleClickInterval)
        m_clickCount = 1;
    else
        ++m_clickCount;

    m_lastClickX = event.x;
    m_lastClickY = event.y;
    m_lastClickButton = convertXEventButtonToNativeMouseButton(event.button);
    m_lastClickTime = event.time;
}
Exemplo n.º 4
0
static NIXMouseEvent convertXButtonEventToNixButtonEvent(NIXView view, const XButtonEvent& event, NIXInputEventType type, unsigned clickCount)
{
    NIXMouseEvent nixEvent;
    nixEvent.type = type;
    nixEvent.button = convertXEventButtonToNativeMouseButton(event.button);
    WKPoint contentsPoint = NIXViewUserViewportToContents(view, WKPointMake(event.x, event.y));
    nixEvent.x = contentsPoint.x;
    nixEvent.y = contentsPoint.y;
    nixEvent.globalX = event.x_root;
    nixEvent.globalY = event.y_root;
    nixEvent.clickCount = clickCount;
    nixEvent.modifiers = convertXEventModifiersToNativeModifiers(event.state);
    nixEvent.timestamp = convertXEventTimeToNixTimestamp(event.time);
    return nixEvent;
}
Exemplo n.º 5
0
void BrowserControl::handleButtonReleaseEvent(const XButtonReleasedEvent& event)
{
    if (event.button == 4 || event.button == 5)
        return;

    NIXMouseEvent ev;
    ev.type = kNIXInputEventTypeMouseUp;
    ev.button = convertXEventButtonToNativeMouseButton(event.button);
    ev.x = event.x;
    ev.y = event.y;
    ev.globalX = event.x_root;
    ev.globalY = event.y_root;
    ev.clickCount = 0;
    ev.modifiers = convertXEventModifiersToNativeModifiers(event.state);
    ev.timestamp = convertXEventModifiersToNativeModifiers(event.state);

    m_client->handleMouseRelease(&ev);
    passFocusToWebView();
}
Exemplo n.º 6
0
void DesktopWindowLinux::handleXEvent(const XEvent& event)
{
    if (event.type == ConfigureNotify) {
        updateSizeIfNeeded(event.xconfigure.width, event.xconfigure.height);
        return;
    }

    if (!m_client)
        return;

    switch (event.type) {
    case Expose:
        m_client->onWindowExpose();
        break;
    case KeyPress:
    case KeyRelease:
        sendKeyboardEventToNix(event);
        break;
    case ButtonPress: {
        const XButtonPressedEvent* xEvent = reinterpret_cast<const XButtonReleasedEvent*>(&event);

        if (xEvent->button == 4 || xEvent->button == 5) {
            // Same constant we use inside WebView to calculate the ticks. See also WebCore::Scrollbar::pixelsPerLineStep().
            const float pixelsPerStep = 40.0f;

            NIXWheelEvent ev;
            ev.type = kNIXInputEventTypeWheel;
            ev.modifiers = convertXEventModifiersToNativeModifiers(xEvent->state);
            ev.timestamp = convertXEventTimeToNixTimestamp(xEvent->time);
            ev.x = xEvent->x;
            ev.y = xEvent->y;
            ev.globalX = xEvent->x_root;
            ev.globalY = xEvent->y_root;
            ev.delta = pixelsPerStep * (xEvent->button == 4 ? 1 : -1);
            ev.orientation = xEvent->state & Mod1Mask ? kNIXWheelEventOrientationHorizontal : kNIXWheelEventOrientationVertical;
            m_client->onMouseWheel(&ev);
            break;
        }
        updateClickCount(xEvent);

        NIXMouseEvent ev;
        ev.type = kNIXInputEventTypeMouseDown;
        ev.button = convertXEventButtonToNativeMouseButton(xEvent->button);
        ev.x = xEvent->x;
        ev.y = xEvent->y;
        ev.globalX = xEvent->x_root;
        ev.globalY = xEvent->y_root;
        ev.clickCount = m_clickCount;
        ev.modifiers = convertXEventModifiersToNativeModifiers(xEvent->state);
        ev.timestamp = convertXEventTimeToNixTimestamp(xEvent->time);
        m_client->onMousePress(&ev);
        break;
    }
    case ButtonRelease: {
        const XButtonReleasedEvent* xEvent = reinterpret_cast<const XButtonReleasedEvent*>(&event);
        if (xEvent->button == 4 || xEvent->button == 5)
            break;

        NIXMouseEvent ev;
        ev.type = kNIXInputEventTypeMouseUp;
        ev.button = convertXEventButtonToNativeMouseButton(xEvent->button);
        ev.x = xEvent->x;
        ev.y = xEvent->y;
        ev.globalX = xEvent->x_root;
        ev.globalY = xEvent->y_root;
        ev.clickCount = 0;
        ev.modifiers = convertXEventModifiersToNativeModifiers(xEvent->state);
        ev.timestamp = convertXEventModifiersToNativeModifiers(xEvent->state);

        m_client->onMouseRelease(&ev);
        break;
    }
    case ClientMessage:
        if ((Atom)event.xclient.data.l[0] == wmDeleteMessageAtom)
            m_client->onWindowClose();
        break;
    case MotionNotify: {
        NIXMouseEvent ev;
        const XPointerMovedEvent* xEvent = reinterpret_cast<const XPointerMovedEvent*>(&event);
        ev.type = kNIXInputEventTypeMouseMove;
        ev.button = kWKEventMouseButtonNoButton;
        ev.x = xEvent->x;
        ev.y = xEvent->y;
        ev.globalX = xEvent->x_root;
        ev.globalY = xEvent->y_root;
        ev.clickCount = 0;
        ev.modifiers = convertXEventModifiersToNativeModifiers(xEvent->state);
        ev.timestamp = convertXEventTimeToNixTimestamp(xEvent->time);
        m_client->onMouseMove(&ev);
        break;
    }
    }
}