@@ -59,19 +59,37 @@ static bool IsASCIIPrintableKey(char c) {
59
59
void TextInputChannel::CommitCallback (void * data, Ecore_IMF_Context* ctx,
60
60
void * event_info) {
61
61
TextInputChannel* self = (TextInputChannel*)data;
62
+ if (!self) {
63
+ return ;
64
+ }
62
65
char * str = (char *)event_info;
66
+ if (self->engine_ && self->engine_ ->platform_view_channel &&
67
+ self->engine_ ->platform_view_channel ->CurrentFocusedViewId () > -1 ) {
68
+ self->engine_ ->platform_view_channel ->DispatchCompositionEndEvent (str);
69
+ return ;
70
+ }
71
+
63
72
self->OnCommit (str);
64
73
}
65
74
66
75
void TextInputChannel::PreeditCallback (void * data, Ecore_IMF_Context* ctx,
67
76
void * event_info) {
68
77
TextInputChannel* self = (TextInputChannel*)data;
69
- char * preedit_string = nullptr ;
78
+ if (!self) {
79
+ return ;
80
+ }
81
+
82
+ char * str = nullptr ;
70
83
int cursor_pos;
71
- ecore_imf_context_preedit_string_get (ctx, &preedit_string, &cursor_pos);
72
- if (preedit_string) {
73
- self->OnPreedit (preedit_string, cursor_pos);
74
- free (preedit_string);
84
+ ecore_imf_context_preedit_string_get (ctx, &str, &cursor_pos);
85
+ if (str) {
86
+ if (self->engine_ && self->engine_ ->platform_view_channel &&
87
+ self->engine_ ->platform_view_channel ->CurrentFocusedViewId () > -1 ) {
88
+ self->OnPreeditForPlatformView (str, cursor_pos);
89
+ } else {
90
+ self->OnPreedit (str, cursor_pos);
91
+ }
92
+ free (str);
75
93
}
76
94
}
77
95
@@ -99,6 +117,7 @@ void TextInputChannel::InputPanelStateChangedCallback(
99
117
TextInputChannel* self = (TextInputChannel*)data;
100
118
switch (value) {
101
119
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
120
+ self->SetSoftwareKeyboardShowing ();
102
121
break ;
103
122
case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
104
123
self->HideSoftwareKeyboard (); // FIXME: Fallback for HW back-key
@@ -275,7 +294,7 @@ TextInputChannel::~TextInputChannel() {
275
294
}
276
295
277
296
void TextInputChannel::OnKeyDown (Ecore_Event_Key* key) {
278
- if (active_model_ && !FilterEvent (key) && !have_preedit_) {
297
+ if (!FilterEvent (key) && !have_preedit_) {
279
298
NonIMFFallback (key);
280
299
}
281
300
}
@@ -431,6 +450,8 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* keyDownEvent) {
431
450
if (isIME) {
432
451
if (!strcmp (keyDownEvent->key , " Left" ) ||
433
452
!strcmp (keyDownEvent->key , " Right" ) ||
453
+ !strcmp (keyDownEvent->key , " Up" ) ||
454
+ !strcmp (keyDownEvent->key , " Down" ) ||
434
455
!strcmp (keyDownEvent->key , " End" ) ||
435
456
!strcmp (keyDownEvent->key , " Home" ) ||
436
457
!strcmp (keyDownEvent->key , " BackSpace" ) ||
@@ -481,35 +502,49 @@ void TextInputChannel::NonIMFFallback(Ecore_Event_Key* keyDownEvent) {
481
502
}
482
503
483
504
bool select = !strcmp (keyDownEvent->key , " Select" );
505
+ bool is_filtered = true ;
484
506
if (!strcmp (keyDownEvent->key , " Left" )) {
485
- if (active_model_->MoveCursorBack ()) {
507
+ if (active_model_ && active_model_ ->MoveCursorBack ()) {
486
508
SendStateUpdate (*active_model_);
487
509
}
488
510
} else if (!strcmp (keyDownEvent->key , " Right" )) {
489
- if (active_model_->MoveCursorForward ()) {
511
+ if (active_model_ && active_model_ ->MoveCursorForward ()) {
490
512
SendStateUpdate (*active_model_);
491
513
}
492
514
} else if (!strcmp (keyDownEvent->key , " End" )) {
493
- active_model_->MoveCursorToEnd ();
494
- SendStateUpdate (*active_model_);
515
+ if (active_model_) {
516
+ active_model_->MoveCursorToEnd ();
517
+ SendStateUpdate (*active_model_);
518
+ }
495
519
} else if (!strcmp (keyDownEvent->key , " Home" )) {
496
- active_model_->MoveCursorToBeginning ();
497
- SendStateUpdate (*active_model_);
520
+ if (active_model_) {
521
+ active_model_->MoveCursorToBeginning ();
522
+ SendStateUpdate (*active_model_);
523
+ }
498
524
} else if (!strcmp (keyDownEvent->key , " BackSpace" )) {
499
- if (active_model_->Backspace ()) {
525
+ if (active_model_ && active_model_ ->Backspace ()) {
500
526
SendStateUpdate (*active_model_);
501
527
}
502
528
} else if (!strcmp (keyDownEvent->key , " Delete" )) {
503
- if (active_model_->Delete ()) {
529
+ if (active_model_ && active_model_ ->Delete ()) {
504
530
SendStateUpdate (*active_model_);
505
531
}
506
532
} else if (!strcmp (keyDownEvent->key , " Return" ) ||
507
533
(select && !in_select_mode_)) {
508
- EnterPressed (active_model_.get (), select );
534
+ if (active_model_) {
535
+ EnterPressed (active_model_.get (), select );
536
+ }
509
537
} else if (keyDownEvent->string && strlen (keyDownEvent->string ) == 1 &&
510
538
IsASCIIPrintableKey (keyDownEvent->string [0 ])) {
511
- active_model_->AddCodePoint (keyDownEvent->string [0 ]);
512
- SendStateUpdate (*active_model_);
539
+ if (active_model_) {
540
+ active_model_->AddCodePoint (keyDownEvent->string [0 ]);
541
+ SendStateUpdate (*active_model_);
542
+ }
543
+ } else {
544
+ is_filtered = false ;
545
+ }
546
+ if (!active_model_ && is_filtered) {
547
+ engine_->platform_view_channel ->SendKeyEvent (keyDownEvent, true );
513
548
}
514
549
SetEditStatus (EditStatus::kNone );
515
550
}
@@ -570,6 +605,30 @@ void TextInputChannel::OnPreedit(std::string str, int cursor_pos) {
570
605
preedit_end_pos_);
571
606
}
572
607
}
608
+ void TextInputChannel::OnPreeditForPlatformView (std::string str,
609
+ int cursor_pos) {
610
+ FT_LOGD (" OnPreeditForPlatformView str[%s], cursor_pos[%d]" , str.data (),
611
+ cursor_pos);
612
+
613
+ SetEditStatus (EditStatus::kPreeditStart );
614
+ if (str.compare (" " ) == 0 ) {
615
+ SetEditStatus (EditStatus::kPreeditEnd );
616
+ }
617
+
618
+ if (edit_status_ == EditStatus::kPreeditStart ||
619
+ (edit_status_ == EditStatus::kPreeditEnd &&
620
+ // For tv, fix me
621
+ last_handled_ecore_event_keyname_.compare (" Return" ) != 0 )) {
622
+ FT_LOGD (" last_handled_ecore_event_keyname_[%s]" ,
623
+ last_handled_ecore_event_keyname_.data ());
624
+ last_handled_ecore_event_keyname_ = " " ;
625
+ }
626
+
627
+ have_preedit_ = false ;
628
+ if (edit_status_ == EditStatus::kPreeditStart ) {
629
+ engine_->platform_view_channel ->DispatchCompositionUpdateEvent (str);
630
+ }
631
+ }
573
632
574
633
void TextInputChannel::ShowSoftwareKeyboard () {
575
634
FT_LOGD (" Show input panel" );
0 commit comments