Files
serenity/Userland/Libraries/LibWeb/Page/InputEvent.h
Andrew Kaster fa54314551 LibWeb: Use Web::UIEvents::KeyCode
This cherrypicks most of commit d90a9ab70c7ef73577775f0abed8552907899f75
It doesn't actually remove Kernel/API/KeyCode.h though, since we still
need that :^)

Patch created by running (in zsh, where the `${=foo}` syntax is needed
to tell zsh to convert space-separated strings into separate args):

    files=$(git show --name-only --pretty='' d90a9ab70c7e |
            rg -v 'CMakeLists.txt|KeyCode.h' | tr '\n' ' ')
    git show d90a9ab70c7e -- ${=files} | git apply -3 -
2024-09-29 11:13:23 -04:00

83 lines
1.7 KiB
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/OwnPtr.h>
#include <AK/Variant.h>
#include <LibGfx/Point.h>
#include <LibIPC/Forward.h>
#include <LibWeb/PixelUnits.h>
#include <LibWeb/UIEvents/KeyCode.h>
#include <LibWeb/UIEvents/MouseButton.h>
namespace Web {
struct ChromeInputData {
virtual ~ChromeInputData() = default;
};
struct KeyEvent {
public:
enum class Type {
KeyDown,
KeyUp,
};
KeyEvent clone_without_chrome_data() const;
Type type;
UIEvents::KeyCode key { UIEvents::KeyCode::Key_Invalid };
UIEvents::KeyModifier modifiers { UIEvents::KeyModifier::Mod_None };
u32 code_point { 0 };
OwnPtr<ChromeInputData> 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;
UIEvents::MouseButton button { UIEvents::MouseButton::None };
UIEvents::MouseButton buttons { UIEvents::MouseButton::None };
UIEvents::KeyModifier modifiers { UIEvents::KeyModifier::Mod_None };
int wheel_delta_x { 0 };
int wheel_delta_y { 0 };
OwnPtr<ChromeInputData> chrome_data;
};
using InputEvent = Variant<KeyEvent, MouseEvent>;
}
namespace IPC {
template<>
ErrorOr<void> encode(Encoder&, Web::KeyEvent const&);
template<>
ErrorOr<Web::KeyEvent> decode(Decoder&);
template<>
ErrorOr<void> encode(Encoder&, Web::MouseEvent const&);
template<>
ErrorOr<Web::MouseEvent> decode(Decoder&);
}