fcitx5_dbus/
input_context.rs

1// The following code is low-level.
2// High-level api is developing...(see `src/utils`)
3
4use crate::utils::{
5    key_event::{KeyState, KeyVal},
6    CapabilityFlag,
7};
8use zbus::proxy;
9
10#[proxy(
11    interface = "org.fcitx.Fcitx.InputContext1",
12    default_service = "org.fcitx.Fcitx5",
13    default_path = "/org/freedesktop/portal/inputcontext/1"
14)]
15pub trait InputContext {
16    /// DestroyIC method
17    #[zbus(name = "DestroyIC")]
18    fn destroy_ic(&self) -> zbus::Result<()>;
19
20    /// FocusIn method
21    fn focus_in(&self) -> zbus::Result<()>;
22
23    /// FocusOut method
24    fn focus_out(&self) -> zbus::Result<()>;
25
26    /// HideVirtualKeyboard method
27    fn hide_virtual_keyboard(&self) -> zbus::Result<()>;
28
29    /// InvokeAction method
30    fn invoke_action(&self, action: u32, cursor: i32) -> zbus::Result<()>;
31
32    /// IsVirtualKeyboardVisible method
33    fn is_virtual_keyboard_visible(&self) -> zbus::Result<bool>;
34
35    /// NextPage method
36    fn next_page(&self) -> zbus::Result<()>;
37
38    /// PrevPage method
39    fn prev_page(&self) -> zbus::Result<()>;
40
41    /// ProcessKeyEvent method
42    fn process_key_event(
43        &self,
44        key_val: KeyVal,
45        key_code: u32,
46        key_state: KeyState,
47        is_release: bool,
48        time: u32,
49    ) -> zbus::Result<bool>;
50
51    /// ProcessKeyEventBatch method
52    #[allow(clippy::too_many_arguments)]
53    fn process_key_event_batch(
54        &self,
55        key_val: u32,
56        key_code: u32,
57        key_state: u32,
58        is_release: bool,
59        time: u32,
60    ) -> zbus::Result<(Vec<(u32, zbus::zvariant::OwnedValue)>, bool)>;
61
62    /// Reset method
63    fn reset(&self) -> zbus::Result<()>;
64
65    /// SelectCandidate method
66    fn select_candidate(&self, idx: i32) -> zbus::Result<()>;
67
68    /// SetCapability method
69    fn set_capability(&self, cap: CapabilityFlag) -> zbus::Result<()>;
70
71    /// SetCursorRect method
72    fn set_cursor_rect(&self, x: i32, y: i32, w: i32, h: i32) -> zbus::Result<()>;
73
74    /// SetCursorRectV2 method
75    fn set_cursor_rect_v2(&self, x: i32, y: i32, w: i32, h: i32, scale: i32) -> zbus::Result<()>;
76
77    /// SetSupportedCapability method
78    fn set_supported_capability(&self, cap: CapabilityFlag) -> zbus::Result<()>;
79
80    /// SetSurroundingText method
81    fn set_surrounding_text(&self, text: &str, cursor: u32, anchor: u32) -> zbus::Result<()>;
82
83    /// SetSurroundingTextPosition method
84    fn set_surrounding_text_position(&self, cursor: u32, anchor: u32) -> zbus::Result<()>;
85
86    /// ShowVirtualKeyboard method
87    fn show_virtual_keyboard(&self) -> zbus::Result<()>;
88
89    /// CommitString signal
90    #[zbus(signal)]
91    fn commit_string(&self, text: &str) -> zbus::Result<()>;
92
93    /// CurrentIM signal
94    #[zbus(signal, name = "CurrentIM")]
95    fn current_im(&self, name: &str, unique_name: &str, language_code: &str) -> zbus::Result<()>;
96
97    /// DeleteSurroundingText signal
98    #[zbus(signal)]
99    fn delete_surrounding_text(&self, offset: i32, size: u32) -> zbus::Result<()>;
100
101    /// ForwardKey signal
102    #[zbus(signal)]
103    fn forward_key(&self, sym: u32, states: u32, is_release: bool) -> zbus::Result<()>;
104
105    /// NotifyFocusOut signal
106    #[zbus(signal)]
107    fn notify_focus_out(&self) -> zbus::Result<()>;
108
109    /// UpdateClientSideUI signal
110    #[zbus(signal, name = "UpdateClientSideUI")]
111    fn update_client_side_ui(
112        &self,
113        preedit_strs: Vec<(&str, i32)>,
114        preedit_cursor: i32,
115        aux_up_strs: Vec<(&str, i32)>,
116        aux_down_strs: Vec<(&str, i32)>,
117        candidates: Vec<(&str, &str)>,
118        cursor_idx: i32,
119        layout_hint: i32,
120        has_prev: bool,
121        has_next: bool,
122    ) -> zbus::Result<()>;
123
124    /// UpdateFormattedPreedit signal
125    #[zbus(signal)]
126    fn update_formatted_preedit(
127        &self,
128        strs: Vec<(&str, i32)>,
129        preedit_cursor: i32,
130    ) -> zbus::Result<()>;
131
132    /// VirtualKeyboardVisibilityChanged signal
133    #[zbus(signal)]
134    fn virtual_keyboard_visibility_changed(&self, is_changed: bool) -> zbus::Result<()>;
135}