config: allow configuring the simple IM
This commit is contained in:
parent
58b9830aaa
commit
2f22a61710
15 changed files with 367 additions and 7 deletions
|
|
@ -239,6 +239,7 @@ pub struct WlSeatGlobal {
|
|||
modifiers_listener: EventListener<dyn LedsListener>,
|
||||
modifiers_forward: EventSource<dyn LedsListener>,
|
||||
simple_im: CloneCell<Option<Rc<SimpleIm>>>,
|
||||
simple_im_enabled: Cell<bool>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
@ -330,6 +331,7 @@ impl WlSeatGlobal {
|
|||
modifiers_listener: EventListener::new(slf.clone()),
|
||||
modifiers_forward: Default::default(),
|
||||
simple_im: CloneCell::new(simple_im),
|
||||
simple_im_enabled: Cell::new(true),
|
||||
});
|
||||
slf.pointer_cursor.set_owner(slf.clone());
|
||||
slf.modifiers_listener
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ use {
|
|||
crate::{
|
||||
backend::KeyState,
|
||||
ifs::{
|
||||
wl_seat::{WlSeatGlobal, text_input::zwp_text_input_v3::ZwpTextInputV3},
|
||||
wl_seat::{
|
||||
WlSeatGlobal,
|
||||
text_input::{simple_im::SimpleIm, zwp_text_input_v3::ZwpTextInputV3},
|
||||
},
|
||||
wl_surface::{WlSurface, zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2},
|
||||
},
|
||||
keyboard::KeyboardState,
|
||||
|
|
@ -61,6 +64,42 @@ pub enum TextDisconnectReason {
|
|||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
pub fn set_simple_im_enabled(self: &Rc<Self>, enabled: bool) {
|
||||
if self.simple_im_enabled.replace(enabled) == enabled {
|
||||
return;
|
||||
}
|
||||
if enabled {
|
||||
if self.input_method.is_none()
|
||||
&& let Some(im) = self.simple_im.get()
|
||||
{
|
||||
self.set_input_method(im);
|
||||
}
|
||||
} else {
|
||||
if let Some(im) = self.input_method.get()
|
||||
&& im.is_simple()
|
||||
{
|
||||
self.input_method.take();
|
||||
im.cancel_simple(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simple_im_enabled(&self) -> bool {
|
||||
self.simple_im_enabled.get()
|
||||
}
|
||||
|
||||
pub fn reload_simple_im(self: &Rc<Self>) {
|
||||
let im = SimpleIm::new(&self.state.kb_ctx.ctx);
|
||||
self.simple_im.set(im.clone());
|
||||
if self.simple_im_enabled.get() && self.can_set_new_im() {
|
||||
if let Some(im) = im {
|
||||
self.set_input_method(im);
|
||||
} else if let Some(old) = self.input_method.take() {
|
||||
old.cancel_simple(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn can_set_new_im(&self) -> bool {
|
||||
match self.input_method.get() {
|
||||
None => true,
|
||||
|
|
@ -82,7 +121,9 @@ impl WlSeatGlobal {
|
|||
|
||||
fn remove_input_method(self: &Rc<Self>) {
|
||||
self.input_method.take();
|
||||
if let Some(im) = self.simple_im.get() {
|
||||
if self.simple_im_enabled.get()
|
||||
&& let Some(im) = self.simple_im.get()
|
||||
{
|
||||
self.set_input_method(im);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue