mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Merge 67d3ce465d
into 8d086b9fe5
This commit is contained in:
commit
987cefeeb9
1 changed files with 42 additions and 14 deletions
|
@ -72,6 +72,9 @@ pub struct Window {
|
||||||
/// The `RenderingContext` of Servo itself. This is used to render Servo results
|
/// The `RenderingContext` of Servo itself. This is used to render Servo results
|
||||||
/// temporarily until they can be blitted into the egui scene.
|
/// temporarily until they can be blitted into the egui scene.
|
||||||
rendering_context: Rc<OffscreenRenderingContext>,
|
rendering_context: Rc<OffscreenRenderingContext>,
|
||||||
|
|
||||||
|
/// Mark if Composition is active
|
||||||
|
composition_active: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -155,6 +158,7 @@ impl Window {
|
||||||
toolbar_height: Cell::new(Default::default()),
|
toolbar_height: Cell::new(Default::default()),
|
||||||
window_rendering_context,
|
window_rendering_context,
|
||||||
rendering_context,
|
rendering_context,
|
||||||
|
composition_active: Cell::new(Default::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,21 +636,32 @@ impl WindowPortsMethods for Window {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
WindowEvent::Ime(ime) => match ime {
|
WindowEvent::Ime(ime) => match ime {
|
||||||
Ime::Enabled => {
|
|
||||||
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
|
||||||
servo::CompositionEvent {
|
|
||||||
state: servo::CompositionState::Start,
|
|
||||||
data: String::new(),
|
|
||||||
},
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
Ime::Preedit(text, _) => {
|
Ime::Preedit(text, _) => {
|
||||||
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
if !self.composition_active.get() && !text.is_empty() {
|
||||||
servo::CompositionEvent {
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
||||||
state: servo::CompositionState::Update,
|
servo::CompositionEvent {
|
||||||
data: text,
|
state: servo::CompositionState::Start,
|
||||||
},
|
data: String::new(),
|
||||||
)));
|
},
|
||||||
|
)));
|
||||||
|
self.composition_active.set(true);
|
||||||
|
}
|
||||||
|
if self.composition_active.get() && text.is_empty() {
|
||||||
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
||||||
|
servo::CompositionEvent {
|
||||||
|
state: servo::CompositionState::End,
|
||||||
|
data: text,
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
self.composition_active.set(false);
|
||||||
|
} else if self.composition_active.get() {
|
||||||
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
||||||
|
servo::CompositionEvent {
|
||||||
|
state: servo::CompositionState::Update,
|
||||||
|
data: text,
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Ime::Commit(text) => {
|
Ime::Commit(text) => {
|
||||||
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
||||||
|
@ -655,10 +670,23 @@ impl WindowPortsMethods for Window {
|
||||||
data: text,
|
data: text,
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
self.composition_active.set(false);
|
||||||
},
|
},
|
||||||
Ime::Disabled => {
|
Ime::Disabled => {
|
||||||
|
if self.composition_active.get() {
|
||||||
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Composition(
|
||||||
|
servo::CompositionEvent {
|
||||||
|
state: servo::CompositionState::End,
|
||||||
|
data: String::new(),
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
self.composition_active.set(false);
|
||||||
|
}
|
||||||
webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
|
webview.notify_input_event(InputEvent::Ime(ImeEvent::Dismissed));
|
||||||
},
|
},
|
||||||
|
Ime::Enabled => {
|
||||||
|
// Do nothing
|
||||||
|
},
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue