mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
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:
parent
c64d5e9d30
commit
538ac61a82
14 changed files with 320 additions and 63 deletions
|
@ -125,7 +125,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
|||
use ipc_channel::router::ROUTER;
|
||||
use ipc_channel::Error as IpcError;
|
||||
use keyboard_types::webdriver::Event as WebDriverInputEvent;
|
||||
use keyboard_types::KeyboardEvent;
|
||||
use keyboard_types::{CompositionEvent, KeyboardEvent};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use media::{GLPlayerThreads, WindowGLContext};
|
||||
use net_traits::pub_domains::reg_host;
|
||||
|
@ -1334,6 +1334,9 @@ where
|
|||
FromCompositorMsg::Keyboard(key_event) => {
|
||||
self.handle_key_msg(key_event);
|
||||
},
|
||||
FromCompositorMsg::IMECompositionEvent(ime_event) => {
|
||||
self.handle_ime_msg(ime_event);
|
||||
},
|
||||
FromCompositorMsg::IMEDismissed => {
|
||||
self.handle_ime_dismissed();
|
||||
},
|
||||
|
@ -4235,6 +4238,42 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(skip_all, fields(servo_profiling = true))
|
||||
)]
|
||||
fn handle_ime_msg(&mut self, event: CompositionEvent) {
|
||||
// Send to the focused browsing contexts' current pipeline.
|
||||
let Some(focused_browsing_context_id) = self
|
||||
.webviews
|
||||
.focused_webview()
|
||||
.map(|(_, webview)| webview.focused_browsing_context_id)
|
||||
else {
|
||||
warn!("No focused browsing context! Dropping IME event {event:?}");
|
||||
return;
|
||||
};
|
||||
let event = CompositorEvent::CompositionEvent(event);
|
||||
let pipeline_id = match self.browsing_contexts.get(&focused_browsing_context_id) {
|
||||
Some(ctx) => ctx.pipeline_id,
|
||||
None => {
|
||||
return warn!(
|
||||
"{}: Got composition event for nonexistent browsing context",
|
||||
focused_browsing_context_id,
|
||||
);
|
||||
},
|
||||
};
|
||||
let msg = ConstellationControlMsg::SendEvent(pipeline_id, event);
|
||||
let result = match self.pipelines.get(&pipeline_id) {
|
||||
Some(pipeline) => pipeline.event_loop.send(msg),
|
||||
None => {
|
||||
return debug!("{}: Got composition event after closure", pipeline_id);
|
||||
},
|
||||
};
|
||||
if let Err(e) = result {
|
||||
self.handle_send_error(pipeline_id, e);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(skip_all, fields(servo_profiling = true))
|
||||
|
|
|
@ -66,6 +66,7 @@ mod from_compositor {
|
|||
},
|
||||
Self::IsReadyToSaveImage(..) => target!("IsReadyToSaveImage"),
|
||||
Self::Keyboard(..) => target!("Keyboard"),
|
||||
Self::IMECompositionEvent(..) => target!("IMECompositionEvent"),
|
||||
Self::AllowNavigationResponse(..) => target!("AllowNavigationResponse"),
|
||||
Self::LoadUrl(..) => target!("LoadUrl"),
|
||||
Self::ClearCache => target!("ClearCache"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue