ohos: Add basic IME and keyboard support (#34188)

* ohos: Add basic IME and keyboard support

- Add extremely basic support for keyboard events
- Add basic IME support
   - Showing and hiding the IME
   - inserting text
   - deleting characters
   - very basic configuration of the IME

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Apply suggestions from code review

Improve the log message

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>

* Update ports/servoshell/egl/ohos.rs

Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>

* ohos: Bump the minimum required SDK version to 5.0

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* ohos: Remove pub from callbacks

The callbacks don't need to be public, as we will be registering them.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Rename composition event

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* ohos: clippy in log

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* ohos: address some clippy warnings

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* ohos: Raise Error in mach if unsupported SDK version is used.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Add keyboard-types dependency for android

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

---------

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
This commit is contained in:
Jonathan Schwender 2024-11-15 16:04:48 +01:00 committed by GitHub
parent c64d5e9d30
commit 538ac61a82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 320 additions and 63 deletions

View file

@ -10,7 +10,7 @@ use std::time::Duration;
use base::id::{PipelineId, TopLevelBrowsingContextId};
use embedder_traits::EventLoopWaker;
use euclid::Scale;
use keyboard_types::KeyboardEvent;
use keyboard_types::{CompositionEvent, KeyboardEvent};
use libc::c_void;
use net::protocols::ProtocolRegistry;
use script_traits::{
@ -83,6 +83,8 @@ pub enum EmbedderEvent {
ExitFullScreen(TopLevelBrowsingContextId),
/// Sent when a key input state changes
Keyboard(KeyboardEvent),
/// Sent for IME composition updates
IMEComposition(CompositionEvent),
/// Sent when Ctr+R/Apple+R is called to reload the current page.
Reload(TopLevelBrowsingContextId),
/// Create a new top-level browsing context.
@ -139,6 +141,7 @@ impl Debug for EmbedderEvent {
EmbedderEvent::Refresh => write!(f, "Refresh"),
EmbedderEvent::WindowResize => write!(f, "Resize"),
EmbedderEvent::Keyboard(..) => write!(f, "Keyboard"),
EmbedderEvent::IMEComposition(..) => write!(f, "IMEComposition"),
EmbedderEvent::AllowNavigationResponse(..) => write!(f, "AllowNavigationResponse"),
EmbedderEvent::LoadUrl(..) => write!(f, "LoadUrl"),
EmbedderEvent::MouseWindowEventClass(..) => write!(f, "Mouse"),