aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-04-05 22:42:17 +0800
committercrupest <crupest@outlook.com>2020-04-05 22:42:17 +0800
commit37ac119b98504ba859dfc789e357718264446bb9 (patch)
tree6409f333d66fb10f03e65cea03a45d609dc16785
parentabcaa16c897678fa3fa4cda3f23660e4ca46b841 (diff)
downloadcru-37ac119b98504ba859dfc789e357718264446bb9.tar.gz
cru-37ac119b98504ba859dfc789e357718264446bb9.tar.bz2
cru-37ac119b98504ba859dfc789e357718264446bb9.zip
...
-rw-r--r--include/cru/win/native/input_method.hpp3
-rw-r--r--src/win/native/input_method.cpp9
-rw-r--r--src/win/native/window.cpp19
3 files changed, 20 insertions, 11 deletions
diff --git a/include/cru/win/native/input_method.hpp b/include/cru/win/native/input_method.hpp
index 2e09aac4..a0b18d63 100644
--- a/include/cru/win/native/input_method.hpp
+++ b/include/cru/win/native/input_method.hpp
@@ -1,3 +1,6 @@
+// Some useful information can be found from chromium code:
+// https://chromium.googlesource.com/chromium/chromium/+/refs/heads/master/ui/base/win/ime_input.h
+
#pragma once
#include "resource.hpp"
diff --git a/src/win/native/input_method.cpp b/src/win/native/input_method.cpp
index 837d0ed7..9d8b0760 100644
--- a/src/win/native/input_method.cpp
+++ b/src/win/native/input_method.cpp
@@ -88,25 +88,16 @@ void WinInputMethodContextRef::OnWindowNativeMessage(
switch (message.msg) {
case WM_IME_COMPOSITION: {
composition_text_change_event_.Raise(this->GetCompositionText());
- args.HandleWithResult(0);
break;
}
case WM_IME_STARTCOMPOSITION: {
composition_start_event_.Raise(nullptr);
- args.HandleWithResult(0);
break;
}
case WM_IME_ENDCOMPOSITION: {
composition_end_event_.Raise(nullptr);
- args.HandleWithResult(0);
break;
}
- case WM_IME_SETCONTEXT: {
- const auto new_l_param =
- message.l_param & (~static_cast<LPARAM>(ISC_SHOWUICOMPOSITIONWINDOW));
- args.HandleWithResult(::DefWindowProcW(message.hwnd, message.msg,
- message.w_param, new_l_param));
- }
}
}
} // namespace cru::platform::native::win
diff --git a/src/win/native/window.cpp b/src/win/native/window.cpp
index a0ac2f6f..542aabd2 100644
--- a/src/win/native/window.cpp
+++ b/src/win/native/window.cpp
@@ -14,6 +14,7 @@
#include "window_d2d_painter.hpp"
#include "window_manager.hpp"
+#include <imm.h>
#include <windowsx.h>
namespace cru::platform::native::win {
@@ -308,6 +309,16 @@ bool WinNativeWindow::HandleNativeWindowMessage(HWND hwnd, UINT msg,
OnDestroyInternal();
*result = 0;
return true;
+ case WM_IME_SETCONTEXT:
+ l_param &= ~ISC_SHOWUICOMPOSITIONWINDOW;
+ *result = ::DefWindowProcW(hwnd, msg, w_param, l_param);
+ return true;
+ // We must block these message from DefWindowProc or it will create
+ // an ugly composition window.
+ case WM_IME_STARTCOMPOSITION:
+ case WM_IME_COMPOSITION:
+ *result = 0;
+ return true;
default:
return false;
}
@@ -409,10 +420,14 @@ void WinNativeWindow::OnCharInternal(wchar_t c) {
return;
} else if (platform::win::IsSurrogatePairTrailing(c)) {
wchar_t s[3] = {last_wm_char_event_wparam_, c, 0};
- char_event_.Raise(platform::win::ToUtf8String(s));
+ auto str = platform::win::ToUtf8String(s);
+ char_event_.Raise(str);
+ log::Debug("WinNativeWindow: char event, charactor is {}", str);
} else {
wchar_t s[2] = {c, 0};
- char_event_.Raise(platform::win::ToUtf8String(s));
+ auto str = platform::win::ToUtf8String(s);
+ char_event_.Raise(str);
+ log::Debug("WinNativeWindow: char event, charactor is {}", str);
}
}