147 if (RemoveRedispatchedMessage(
action, wparam, lparam)) {
156 Win32Message{.
action =
action, .wparam = wparam, .lparam = lparam};
157 current_session_.push_back(
message);
165 const Win32Message* last_message =
166 current_session_.size() <= 1
168 : ¤t_session_[current_session_.size() - 2];
169 if (last_message ==
nullptr || !last_message->IsHighSurrogate()) {
175 CodePointFromSurrogatePair(last_message->wparam,
message.
wparam);
185 if (current_session_.front().IsGeneralKeyDown()) {
186 const Win32Message first_message = current_session_.front();
187 const uint8_t
scancode = (lparam >> 16) & 0xff;
188 const uint16_t key_code = first_message.wparam;
189 const bool extended = ((lparam >> 24) & 0x01) == 0x01;
190 const bool was_down = lparam & 0x40000000;
195 if (
action == WM_DEADCHAR ||
action == WM_SYSDEADCHAR) {
202 character = IsPrintable(code_point) ? code_point : 0;
204 auto event = std::make_unique<PendingEvent>(PendingEvent{
207 .action =
static_cast<UINT
>(
action == WM_SYSCHAR ? WM_SYSKEYDOWN
212 .session = std::move(current_session_),
215 pending_events_.push_back(std::move(event));
220 return !IsSysAction(
action);
231 auto event = std::make_unique<PendingEvent>(PendingEvent{
233 .character = code_point,
234 .session = std::move(current_session_),
236 pending_events_.push_back(std::move(event));
246 if (wparam == VK_PACKET) {
250 const uint8_t
scancode = (lparam >> 16) & 0xff;
251 const bool extended = ((lparam >> 24) & 0x01) == 0x01;
254 const bool was_down = lparam & 0x40000000;
259 if (last_key_is_ctrl_left_down) {
260 should_synthesize_ctrl_left_up =
true;
263 if (IsKeyDownCtrlLeft(
action, key_code)) {
264 last_key_is_ctrl_left_down =
true;
266 should_synthesize_ctrl_left_up =
false;
268 last_key_is_ctrl_left_down =
false;
271 if (should_synthesize_ctrl_left_up) {
272 should_synthesize_ctrl_left_up =
false;
273 const LPARAM lParam =
274 (1 << 0) | (ctrl_left_scancode << 16) |
275 (0 << 24) | (1 << 30) |
281 current_session_.clear();
282 current_session_.push_back(
283 Win32Message{.action =
action, .wparam = wparam, .lparam = lparam});
284 const bool is_keydown_message =
292 UINT next_key_action = PeekNextMessageType(WM_KEYFIRST, WM_KEYLAST);
293 bool has_char_action =
294 (next_key_action == WM_DEADCHAR ||
295 next_key_action == WM_SYSDEADCHAR || next_key_action == WM_CHAR ||
296 next_key_action == WM_SYSCHAR);
297 if (
character > 0 && is_keydown_message && has_char_action) {
307 auto event = std::make_unique<PendingEvent>(PendingEvent{
314 .session = std::move(current_session_),
316 pending_events_.push_back(std::move(event));
320 return !IsSysAction(
action);
323 FML_LOG(FATAL) <<
"No event handler for keyboard event with action "