File tree 4 files changed +24
-18
lines changed
4 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ pub enum InputMethod<T = String> {
11
11
/// No input method is allowed.
12
12
Disabled ,
13
13
/// Input methods are allowed, but not open yet.
14
- Allowed ,
14
+ Allowed {
15
+ /// The position at which the input method dialog should be placed.
16
+ position : Point ,
17
+ } ,
15
18
/// Input method is open.
16
19
Open {
17
20
/// The position at which the input method dialog should be placed.
@@ -117,7 +120,7 @@ impl InputMethod {
117
120
match ( & self , other) {
118
121
( InputMethod :: Open { .. } , _)
119
122
| (
120
- InputMethod :: Allowed ,
123
+ InputMethod :: Allowed { .. } ,
121
124
InputMethod :: None | InputMethod :: Disabled ,
122
125
)
123
126
| ( InputMethod :: Disabled , InputMethod :: None ) => { }
@@ -142,7 +145,9 @@ impl<T> InputMethod<T> {
142
145
match self {
143
146
Self :: None => InputMethod :: None ,
144
147
Self :: Disabled => InputMethod :: Disabled ,
145
- Self :: Allowed => InputMethod :: Allowed ,
148
+ Self :: Allowed { position } => InputMethod :: Allowed {
149
+ position : * position,
150
+ } ,
146
151
Self :: Open {
147
152
position,
148
153
purpose,
Original file line number Diff line number Diff line change @@ -339,10 +339,6 @@ where
339
339
return InputMethod :: Disabled ;
340
340
} ;
341
341
342
- let Some ( preedit) = & state. preedit else {
343
- return InputMethod :: Allowed ;
344
- } ;
345
-
346
342
let bounds = layout. bounds ( ) ;
347
343
let internal = self . content . 0 . borrow_mut ( ) ;
348
344
@@ -363,6 +359,10 @@ where
363
359
let position =
364
360
cursor + translation + Vector :: new ( 0.0 , f32:: from ( line_height) ) ;
365
361
362
+ let Some ( preedit) = & state. preedit else {
363
+ return InputMethod :: Allowed { position } ;
364
+ } ;
365
+
366
366
InputMethod :: Open {
367
367
position,
368
368
purpose : input_method:: Purpose :: Normal ,
Original file line number Diff line number Diff line change @@ -406,10 +406,6 @@ where
406
406
return InputMethod :: Disabled ;
407
407
} ;
408
408
409
- let Some ( preedit) = & state. is_ime_open else {
410
- return InputMethod :: Allowed ;
411
- } ;
412
-
413
409
let secure_value = self . is_secure . then ( || value. secure ( ) ) ;
414
410
let value = secure_value. as_ref ( ) . unwrap_or ( value) ;
415
411
@@ -432,9 +428,14 @@ where
432
428
433
429
let x = ( text_bounds. x + cursor_x) . floor ( ) - scroll_offset
434
430
+ alignment_offset;
431
+ let position = Point :: new ( x, text_bounds. y + text_bounds. height ) ;
432
+
433
+ let Some ( preedit) = & state. is_ime_open else {
434
+ return InputMethod :: Allowed { position } ;
435
+ } ;
435
436
436
437
InputMethod :: Open {
437
- position : Point :: new ( x , text_bounds . y + text_bounds . height ) ,
438
+ position,
438
439
purpose : if self . is_secure {
439
440
input_method:: Purpose :: Secure
440
441
} else {
Original file line number Diff line number Diff line change @@ -210,8 +210,13 @@ where
210
210
InputMethod :: Disabled => {
211
211
self . raw . set_ime_allowed ( false ) ;
212
212
}
213
- InputMethod :: Allowed | InputMethod :: Open { .. } => {
213
+ InputMethod :: Allowed { position }
214
+ | InputMethod :: Open { position, .. } => {
214
215
self . raw . set_ime_allowed ( true ) ;
216
+ self . raw . set_ime_cursor_area (
217
+ LogicalPosition :: new ( position. x , position. y ) ,
218
+ LogicalSize :: new ( 10 , 10 ) , // TODO?
219
+ ) ;
215
220
}
216
221
}
217
222
@@ -221,11 +226,6 @@ where
221
226
preedit,
222
227
} = input_method
223
228
{
224
- self . raw . set_ime_cursor_area (
225
- LogicalPosition :: new ( position. x , position. y ) ,
226
- LogicalSize :: new ( 10 , 10 ) , // TODO?
227
- ) ;
228
-
229
229
self . raw . set_ime_purpose ( conversion:: ime_purpose ( purpose) ) ;
230
230
231
231
if let Some ( preedit) = preedit {
You can’t perform that action at this time.
0 commit comments