/* * Copyright (c) 2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include // FIXME: These should not be included outside of Serenity. This FIXME appears in several locations across the Ladybird // chromes. The classes in this file provide a good opportunity to remove LibGUI and Kernel types from LibWeb. #include #include namespace Web { struct ChromeInputData { virtual ~ChromeInputData() = default; }; struct KeyEvent { public: enum class Type { KeyDown, KeyUp, }; KeyEvent clone_without_chrome_data() const; Type type; KeyCode key { KeyCode::Key_Invalid }; KeyModifier modifiers { KeyModifier::Mod_None }; u32 code_point { 0 }; OwnPtr chrome_data; }; struct MouseEvent { public: enum class Type { MouseDown, MouseUp, MouseMove, MouseWheel, DoubleClick, }; MouseEvent clone_without_chrome_data() const; Type type; Web::DevicePixelPoint position; Web::DevicePixelPoint screen_position; GUI::MouseButton button { GUI::MouseButton::None }; GUI::MouseButton buttons { GUI::MouseButton::None }; KeyModifier modifiers { KeyModifier::Mod_None }; int wheel_delta_x { 0 }; int wheel_delta_y { 0 }; OwnPtr chrome_data; }; using InputEvent = Variant; } namespace IPC { template<> ErrorOr encode(Encoder&, Web::KeyEvent const&); template<> ErrorOr decode(Decoder&); template<> ErrorOr encode(Encoder&, Web::MouseEvent const&); template<> ErrorOr decode(Decoder&); }