Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ uint64_t GetLogicalKey(const char* key) {
return ApplyPlaneToId(0, kTizenPlane);
}

uint32_t GetFallbackScanCodeFromKey(const std::string& key) {
// Some of scan codes are 0 when key events occur from the software
// keyboard, and key_event_channel cannot handle the key events.
// To avoid this, use a valid scan code.

// The following keys can be emitted from the software keyboard and have a
// scan code with 0 value.
const std::map<std::string, uint32_t> kKeyToScanCode = {
{"BackSpace", 0x00000016}, {"Up", 0x0000006f}, {"Left", 0x00000071},
{"Right", 0x00000072}, {"Down", 0x00000074},
};

auto iter = kKeyToScanCode.find(key);
if (iter != kKeyToScanCode.end()) {
return iter->second;
}
return 0;
}

} // namespace

KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger,
Expand Down Expand Up @@ -99,6 +118,10 @@ void KeyEventChannel::SendKey(const char* key,
}
pending_events_[sequence_id] = std::make_unique<PendingEvent>(pending);

if (scan_code == 0) {
scan_code = GetFallbackScanCodeFromKey(key);
}

SendEmbedderEvent(key, string, compose, modifiers, scan_code, is_down,
sequence_id);
// The channel-based API (RawKeyEvent) is deprecated and |SendChannelEvent|
Expand Down
36 changes: 2 additions & 34 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,43 +303,11 @@ void TextInputChannel::SendStateUpdate() {
bool TextInputChannel::HandleKey(const char* key,
const char* string,
uint32_t modifires) {
bool shift = modifires & ECORE_SHIFT;
bool needs_update = false;
std::string key_str = key;

if (key_str == "Left") {
if (shift) {
TextRange selection = active_model_->selection();
needs_update = active_model_->SetSelection(
TextRange(selection.base(), selection.extent() - 1));
} else {
needs_update = active_model_->MoveCursorBack();
}
} else if (key_str == "Right") {
if (shift) {
TextRange selection = active_model_->selection();
needs_update = active_model_->SetSelection(
TextRange(selection.base(), selection.extent() + 1));
} else {
needs_update = active_model_->MoveCursorForward();
}
} else if (key_str == "End") {
if (shift) {
needs_update = active_model_->SelectToEnd();
} else {
needs_update = active_model_->MoveCursorToEnd();
}
} else if (key_str == "Home") {
if (shift) {
needs_update = active_model_->SelectToBeginning();
} else {
needs_update = active_model_->MoveCursorToBeginning();
}
} else if (key_str == "BackSpace") {
needs_update = active_model_->Backspace();
} else if (key_str == "Delete") {
needs_update = active_model_->Delete();
} else if (string && strlen(string) == 1 && IsAsciiPrintableKey(string[0])) {
if (string && strlen(string) == 1 && IsAsciiPrintableKey(string[0])) {
// This is a fallback for printable keys not handled by IMF.
active_model_->AddCodePoint(string[0]);
needs_update = true;
} else if (key_str == "Return") {
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/tizen/tizen_input_method_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,14 @@ void TizenInputMethodContext::SetInputPanelOptions() {
}

bool TizenInputMethodContext::ShouldIgnoreKey(std::string key, bool is_ime) {
// The keys below should be handled in the text_input_channel.
// The below keys should be handled by the flutter framework.
if (is_ime && (key == "Left" || key == "Right" || key == "Up" ||
key == "Down" || key == "End" || key == "Home" ||
key == "BackSpace" || key == "Delete")) {
return true;
}
#ifdef TV_PROFILE
// The Select key should be handled in the TextInputChannel.
if (is_ime && key == "Select") {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/tizen_view_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void TizenViewElementary::RegisterEventHandlers() {
if (self->view_) {
if (self->event_layer_ == object) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Down*>(event_info);
int handled = false;
bool handled = false;
key_event->event_flags =
Evas_Event_Flags(key_event->event_flags | EVAS_EVENT_FLAG_ON_HOLD);
if (self->input_method_context_->IsInputPanelShown()) {
Expand All @@ -241,7 +241,7 @@ void TizenViewElementary::RegisterEventHandlers() {
if (self->view_) {
if (self->event_layer_ == object) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Up*>(event_info);
int handled = false;
bool handled = false;
key_event->event_flags = Evas_Event_Flags(key_event->event_flags |
EVAS_EVENT_FLAG_ON_HOLD);
if (self->input_method_context_->IsInputPanelShown()) {
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/tizen_window_ecore_wl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() {
if (self->view_) {
auto* key_event = reinterpret_cast<Ecore_Event_Key*>(event);
if (key_event->window == self->GetWindowId()) {
int handled = false;
bool handled = false;
if (self->input_method_context_->IsInputPanelShown()) {
handled = self->input_method_context_->HandleEcoreEventKey(
key_event, true);
Expand All @@ -337,7 +337,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() {
if (self->view_) {
auto* key_event = reinterpret_cast<Ecore_Event_Key*>(event);
if (key_event->window == self->GetWindowId()) {
int handled = false;
bool handled = false;
if (self->input_method_context_->IsInputPanelShown()) {
handled = self->input_method_context_->HandleEcoreEventKey(
key_event, false);
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/tizen_window_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void TizenWindowElementary::RegisterEventHandlers() {
if (self->view_) {
if (self->elm_win_ == object) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Down*>(event_info);
int handled = false;
bool handled = false;
if (self->input_method_context_->IsInputPanelShown()) {
handled =
self->input_method_context_->HandleEvasEventKeyDown(key_event);
Expand All @@ -262,7 +262,7 @@ void TizenWindowElementary::RegisterEventHandlers() {
if (self->view_) {
if (self->elm_win_ == object) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Up*>(event_info);
int handled = false;
bool handled = false;
if (self->input_method_context_->IsInputPanelShown()) {
handled =
self->input_method_context_->HandleEvasEventKeyUp(key_event);
Expand Down