Plug three holes in Servo input forwarding
1. Scroll no longer wipes keyboard focus. Servo holds DOM focus across wheel events; the shell was clearing keyboard_focus and typed_texts on every scroll, so a focused input went deaf the moment the user scrolled. Scroll still drops the buffered click point because that coordinate is captured against the pre-scroll viewport. 2. Mouse-down hands focus to the shell's root focus handle (in addition to mouse-up's existing click forwarding). The user can now start typing the moment they press the page, instead of having to first complete a click round-trip to escape the omnibar's focus. 3. Sidecar hover() honors the requesting webview_id instead of defaulting to the first webview in the map, so multi-tab sidecars no longer pipe every hover into tab #1.
This commit is contained in:
@@ -137,9 +137,13 @@ impl WebSurfaceStore {
|
||||
.entry(tab_id.clone())
|
||||
.and_modify(|current| *current = current.combined_with(delta))
|
||||
.or_insert(delta);
|
||||
// Drop any buffered click — its viewport coordinates were
|
||||
// captured against the pre-scroll page, so applying it after
|
||||
// the scroll would land on the wrong DOM element. Keep
|
||||
// `keyboard_focus` and `typed_texts` though: Servo maintains
|
||||
// its own DOM focus across scrolls, so a focused input keeps
|
||||
// accepting the user's keystrokes after they wheel-scroll.
|
||||
self.click_points.remove(tab_id);
|
||||
self.typed_texts.remove(tab_id);
|
||||
self.keyboard_focus = None;
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,14 @@ impl ElyShell {
|
||||
}
|
||||
}
|
||||
|
||||
/// Hand focus to the shell's root focus handle so subsequent
|
||||
/// keystrokes route to the web surface. Called on the very first
|
||||
/// mouse-down inside an external page so the user can start
|
||||
/// typing without waiting for the click to fully resolve.
|
||||
pub(super) fn focus_web_surface(&self, window: &mut gpui::Window) {
|
||||
self.focus_handle.focus(window);
|
||||
}
|
||||
|
||||
pub(super) fn type_text_in_external_web_viewport(
|
||||
&mut self,
|
||||
tab_id: TabId,
|
||||
|
||||
@@ -90,6 +90,7 @@ fn render_input_overlay(
|
||||
url: String,
|
||||
state_entity: Entity<ElyShell>,
|
||||
) -> impl IntoElement {
|
||||
let down_entity = state_entity.clone();
|
||||
let click_tab_id = tab_id.clone();
|
||||
let click_url = url.clone();
|
||||
let click_entity = state_entity.clone();
|
||||
@@ -103,6 +104,16 @@ fn render_input_overlay(
|
||||
.absolute()
|
||||
.size_full()
|
||||
.occlude()
|
||||
// Mouse-down hands focus to the shell's root focus handle so
|
||||
// subsequent keystrokes route to the web surface instead of
|
||||
// the omnibar Input. Doing this on mouse-down (not mouse-up)
|
||||
// lets the user start typing as soon as they press, matching
|
||||
// native browser focus semantics.
|
||||
.on_mouse_down(MouseButton::Left, move |_event, window, cx| {
|
||||
down_entity.update(cx, |shell, _cx| {
|
||||
shell.focus_web_surface(window);
|
||||
});
|
||||
})
|
||||
.capture_any_mouse_up(move |event, window, cx| {
|
||||
if event.button != MouseButton::Left {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user