Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
4 changes: 4 additions & 0 deletions shell/platform/windows/flutter_window_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ void FlutterWindowWin32::OnComposeBegin() {
binding_handler_delegate_->OnComposeBegin();
}

void FlutterWindowWin32::OnComposeCommit() {
binding_handler_delegate_->OnComposeCommit();
}

void FlutterWindowWin32::OnComposeEnd() {
binding_handler_delegate_->OnComposeEnd();
}
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/windows/flutter_window_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler {
// |WindowWin32|
void OnComposeBegin() override;

// |WindowWin32|
void OnComposeCommit() override;

// |WindowWin32|
void OnComposeEnd() override;

Expand Down
2 changes: 2 additions & 0 deletions shell/platform/windows/flutter_window_win32_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class SpyKeyboardKeyHandler : public KeyboardHandlerBase {
MOCK_METHOD2(TextHook,
void(FlutterWindowsView* window, const std::u16string& text));
MOCK_METHOD0(ComposeBeginHook, void());
MOCK_METHOD0(ComposeCommitHook, void());
MOCK_METHOD0(ComposeEndHook, void());
MOCK_METHOD2(ComposeChangeHook,
void(const std::u16string& text, int cursor_pos));
Expand Down Expand Up @@ -112,6 +113,7 @@ class SpyTextInputPlugin : public KeyboardHandlerBase,
MOCK_METHOD2(TextHook,
void(FlutterWindowsView* window, const std::u16string& text));
MOCK_METHOD0(ComposeBeginHook, void());
MOCK_METHOD0(ComposeCommitHook, void());
MOCK_METHOD0(ComposeEndHook, void());
MOCK_METHOD2(ComposeChangeHook,
void(const std::u16string& text, int cursor_pos));
Expand Down
10 changes: 10 additions & 0 deletions shell/platform/windows/flutter_windows_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ void FlutterWindowsView::OnComposeBegin() {
SendComposeBegin();
}

void FlutterWindowsView::OnComposeCommit() {
SendComposeCommit();
}

void FlutterWindowsView::OnComposeEnd() {
SendComposeEnd();
}
Expand Down Expand Up @@ -329,6 +333,12 @@ void FlutterWindowsView::SendComposeBegin() {
}
}

void FlutterWindowsView::SendComposeCommit() {
for (const auto& handler : keyboard_handlers_) {
handler->ComposeCommitHook();
}
}

void FlutterWindowsView::SendComposeEnd() {
for (const auto& handler : keyboard_handlers_) {
handler->ComposeEndHook();
Expand Down
10 changes: 10 additions & 0 deletions shell/platform/windows/flutter_windows_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate,
// |WindowBindingHandlerDelegate|
void OnComposeBegin() override;

// |WindowBindingHandlerDelegate|
void OnComposeCommit() override;

// |WindowBindingHandlerDelegate|
void OnComposeEnd() override;

Expand Down Expand Up @@ -202,6 +205,13 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate,
// input method such as in CJK text input.
void SendComposeBegin();

// Reports an IME compose commit event.
//
// Triggered when the user commits the current composing text while using a
// multi-step input method such as in CJK text input. Composing continues with
// the next keypress.
void SendComposeCommit();

// Reports an IME compose end event.
//
// Triggered when the user commits the composing text while using a multi-step
Expand Down
11 changes: 9 additions & 2 deletions shell/platform/windows/keyboard_handler_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ class KeyboardHandlerBase {
// input method such as in CJK text input.
virtual void ComposeBeginHook() = 0;

// Handler for IME compose commit events.
//
// Triggered when the user commits the current composing text while using a
// multi-step input method such as in CJK text input. Composing continues with
// the next keypress.
virtual void ComposeCommitHook() = 0;

// Handler for IME compose end events.
//
// Triggered when the user commits the composing text while using a multi-step
// input method such as in CJK text input.
// Triggered when the user ends editing composing text while using a
// multi-step input method such as in CJK text input.
virtual void ComposeEndHook() = 0;

// Handler for IME compose change events.
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/windows/keyboard_key_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ void KeyboardKeyHandler::ComposeBeginHook() {
// Ignore.
}

void KeyboardKeyHandler::ComposeCommitHook() {
// Ignore.
}

void KeyboardKeyHandler::ComposeEndHook() {
// Ignore.
}
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/windows/keyboard_key_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class KeyboardKeyHandler : public KeyboardHandlerBase {
// |KeyboardHandlerBase|
void ComposeBeginHook() override;

// |KeyboardHandlerBase|
void ComposeCommitHook() override;

// |KeyboardHandlerBase|
void ComposeEndHook() override;

Expand Down
1 change: 1 addition & 0 deletions shell/platform/windows/testing/mock_window_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MockWin32Window : public WindowWin32 {
MOCK_METHOD6(OnKey, bool(int, int, int, char32_t, bool, bool));
MOCK_METHOD2(OnScroll, void(double, double));
MOCK_METHOD0(OnComposeBegin, void());
MOCK_METHOD0(OnComposeCommit, void());
MOCK_METHOD0(OnComposeEnd, void());
MOCK_METHOD2(OnComposeChange, void(const std::u16string&, int));
MOCK_METHOD4(DefaultWindowProc, LRESULT(HWND, UINT, WPARAM, LPARAM));
Expand Down
8 changes: 8 additions & 0 deletions shell/platform/windows/text_input_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ void TextInputPlugin::ComposeBeginHook() {
SendStateUpdate(*active_model_);
}

void TextInputPlugin::ComposeCommitHook() {
if (active_model_ == nullptr) {
return;
}
active_model_->CommitComposing();
SendStateUpdate(*active_model_);
}

void TextInputPlugin::ComposeEndHook() {
if (active_model_ == nullptr) {
return;
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/windows/text_input_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class TextInputPlugin : public KeyboardHandlerBase {
// |KeyboardHandlerBase|
void ComposeBeginHook() override;

// |KeyboardHandlerBase|
void ComposeCommitHook() override;

// |KeyboardHandlerBase|
void ComposeEndHook() override;

Expand Down
7 changes: 7 additions & 0 deletions shell/platform/windows/window_binding_handler_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class WindowBindingHandlerDelegate {
// input method such as in CJK text input.
virtual void OnComposeBegin() = 0;

// Notifies the delegate that IME composing region have been committed.
//
// Triggered when the user commits the current composing text while using a
// multi-step input method such as in CJK text input. Composing continues with
// the next keypress.
virtual void OnComposeCommit() = 0;

// Notifies the delegate that IME composing mode has ended.
//
// Triggered when the user commits the composing text while using a multi-step
Expand Down
9 changes: 2 additions & 7 deletions shell/platform/windows/window_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,13 @@ void WindowWin32::OnImeComposition(UINT const message,
OnComposeChange(text.value(), pos);
}
} else if (lparam & GCS_RESULTSTR) {
// Commit but don't end composing.
// Read the committed composing string.
long pos = text_input_manager_.GetComposingCursorPosition();
std::optional<std::u16string> text = text_input_manager_.GetResultString();
if (text) {
OnComposeChange(text.value(), pos);
}
// Next, try reading the composing string. Some Japanese IMEs send a message
// containing both a GCS_RESULTSTR and a GCS_COMPSTR when one composition is
// committed and another immediately started.
text = text_input_manager_.GetResultString();
if (text) {
OnComposeChange(text.value(), pos);
OnComposeCommit();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/windows/window_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class WindowWin32 {
// Called when IME composing begins.
virtual void OnComposeBegin() = 0;

// Called when IME composing text is committed.
virtual void OnComposeCommit() = 0;

// Called when IME composing ends.
virtual void OnComposeEnd() = 0;

Expand Down