1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

Ladybird/AppKit: Handle input events through LibWebView

The AppKit chrome currently handles all input events before selectively
forwarding those events to WebContent. This means that WebContent does
not see events like cmd+c.

Here, we make use of LibWebView's input handling and wait for LibWebView
to inform the chrome that it should handle the event itself.
This commit is contained in:
Timothy Flynn 2024-03-05 16:11:22 -05:00 committed by Andreas Kling
parent c1476c3405
commit 2c31ef11bc
5 changed files with 130 additions and 98 deletions

View file

@ -6,30 +6,17 @@
#pragma once
// FIXME: These should not be included outside of Serenity.
#include <Kernel/API/KeyCode.h>
#include <LibGUI/Event.h>
#include <LibWeb/Page/InputEvent.h>
#import <System/Cocoa.h>
namespace Ladybird {
struct MouseEvent {
Gfx::IntPoint position {};
Gfx::IntPoint screen_position {};
GUI::MouseButton button { GUI::MouseButton::Primary };
KeyModifier modifiers { KeyModifier::Mod_None };
};
MouseEvent ns_event_to_mouse_event(NSEvent*, NSView*, GUI::MouseButton);
Web::MouseEvent ns_event_to_mouse_event(Web::MouseEvent::Type, NSEvent*, NSView*, NSScrollView*, GUI::MouseButton);
Web::KeyEvent ns_event_to_key_event(Web::KeyEvent::Type, NSEvent*);
NSEvent* key_event_to_ns_event(Web::KeyEvent const&);
NSEvent* create_context_menu_mouse_event(NSView*, Gfx::IntPoint);
NSEvent* create_context_menu_mouse_event(NSView*, NSPoint);
struct KeyEvent {
KeyCode key_code { KeyCode::Key_Invalid };
KeyModifier modifiers { KeyModifier::Mod_None };
u32 code_point { 0 };
};
KeyEvent ns_event_to_key_event(NSEvent*);
}