Skip to content

Truly independent web browser

2.7 KB
Raw Blame
// Copyright (c) 2026-present, the Ladybird developers.

// NB: The IPC compiler cannot check that each struct here lists every field of its C++ type. A field left out
//     here does not cross IPC, as the browser data of the events deliberately does not.

#include <LibWebCommon/Page/InputEvent.h>

[ExistingCpp]
enum Web::KeyEvent::Type : u8 {
    KeyDown,
    KeyUp,
}

[ExistingCpp]
enum Web::MouseEvent::Type : u8 {
    MouseDown,
    MouseUp,
    MouseMove,
    MouseLeave,
    MouseCancel,
    MouseWheel,
}

[ExistingCpp]
enum Web::WheelDeltaPrecision : u8 {
    Discrete,
    Precise,
}

[ExistingCpp]
enum Web::ScrollGesturePhase : u8 {
    None,
    Ongoing,
    Momentum,
    Ended,
}

[ExistingCpp]
struct Web::WheelGestureMark {
    u64 gesture_id;
    bool lasts_until_fingers_lift;
    u64 step_number;
}

[ExistingCpp]
struct Web::KeyEvent {
    Web::KeyEvent::Type type;
    Web::UIEvents::KeyCode key;
    Web::UIEvents::KeyModifier modifiers;
    u32 code_point;
    bool repeat;
    bool should_insert_text;
    bool async_scroll_performed_default_action;
    Optional<u64> user_input_scroll_count_with_nothing_to_scroll;
    u64 id;
    Vector<Web::TextEditingCommand> editing_commands;
    bool native_editing_binding_resolved;
}

[ExistingCpp]
enum Web::PointerType : u8 {
    Mouse,
    Pen,
    Touch,
}

[ExistingCpp]
struct Web::PointerProperties {
    i32 pointer_id;
    Web::PointerType pointer_type;
    [Finite] double width;
    [Finite] double height;
    [Finite] double pressure;
    [Finite] double tangential_pressure;
    i32 tilt_x;
    i32 tilt_y;
    i32 twist;
    [Finite] double altitude_angle;
    [Finite] double azimuth_angle;
}

[ExistingCpp, Accessors]
struct Web::PointerInputData {
    Optional<Web::PointerProperties> properties;
}

[ExistingCpp]
struct Web::MouseEvent {
    Web::MouseEvent::Type type;
    Web::DevicePixelPoint position;
    Web::DevicePixelPoint screen_position;
    Web::UIEvents::MouseButton button;
    Web::UIEvents::MouseButton buttons;
    Web::UIEvents::KeyModifier modifiers;
    double wheel_delta_x;
    double wheel_delta_y;
    double wheel_tick_120ths_x;
    double wheel_tick_120ths_y;
    Web::WheelDeltaPrecision wheel_delta_precision;
    Web::ScrollGesturePhase scroll_gesture_phase;
    i32 click_count;
    bool async_scroll_performed_default_action;
    u64 id;
    Optional<Web::ScrollbarDraggedByCompositor> scrollbar_dragged_by_compositor;
    Web::PointerInputData pointer_data;
    Optional<Web::WheelGestureMark> wheel_gesture_mark;
}

[ExistingCpp]
struct Web::PinchEvent {
    Web::DevicePixelPoint position;
    Web::UIEvents::KeyModifier modifiers;
    [Finite] double scale_delta;
    bool async_zoom_performed_default_action;
    bool wheel_event_was_dispatched;
    bool continues_gesture;
    u64 id;
}