149 if (RemoveRedispatchedMessage(
action, wparam, lparam)) {
158 Win32Message{.
action =
action, .wparam = wparam, .lparam = lparam};
159 current_session_.push_back(
message);
167 const Win32Message* last_message =
168 current_session_.size() <= 1
170 : ¤t_session_[current_session_.size() - 2];
171 if (last_message ==
nullptr || !last_message->IsHighSurrogate()) {
177 CodePointFromSurrogatePair(last_message->wparam,
message.
wparam);
187 if (current_session_.front().IsGeneralKeyDown()) {
188 const Win32Message first_message = current_session_.front();
189 const uint8_t
scancode = (lparam >> 16) & 0xff;
190 const uint16_t key_code = first_message.wparam;
191 const bool extended = ((lparam >> 24) & 0x01) == 0x01;
192 const bool was_down = lparam & 0x40000000;
197 if (
action == WM_DEADCHAR ||
action == WM_SYSDEADCHAR) {
204 character = IsPrintable(code_point) ? code_point : 0;
206 auto event = std::make_unique<PendingEvent>(PendingEvent{
209 .action =
static_cast<UINT
>(
action == WM_SYSCHAR ? WM_SYSKEYDOWN
214 .session = std::move(current_session_),
217 pending_events_.push_back(std::move(event));
222 return !IsSysAction(
action);
233 auto event = std::make_unique<PendingEvent>(PendingEvent{
235 .character = code_point,
236 .session = std::move(current_session_),
238 pending_events_.push_back(std::move(event));
248 if (wparam == VK_PACKET) {
252 const uint8_t
scancode = (lparam >> 16) & 0xff;
253 const bool extended = ((lparam >> 24) & 0x01) == 0x01;
256 const bool was_down = lparam & 0x40000000;
261 if (last_key_is_ctrl_left_down) {
262 should_synthesize_ctrl_left_up =
true;
265 if (IsKeyDownCtrlLeft(
action, key_code)) {
266 last_key_is_ctrl_left_down =
true;
268 should_synthesize_ctrl_left_up =
false;
270 last_key_is_ctrl_left_down =
false;
273 if (should_synthesize_ctrl_left_up) {
274 should_synthesize_ctrl_left_up =
false;
275 const LPARAM lParam =
276 (1 << 0) | (ctrl_left_scancode << 16) |
277 (0 << 24) | (1 << 30) |
283 current_session_.clear();
284 current_session_.push_back(
285 Win32Message{.action =
action, .wparam = wparam, .lparam = lparam});
286 const bool is_keydown_message =
294 UINT next_key_action = PeekNextMessageType(WM_KEYFIRST, WM_KEYLAST);
295 bool has_char_action =
296 (next_key_action == WM_DEADCHAR ||
297 next_key_action == WM_SYSDEADCHAR || next_key_action == WM_CHAR ||
298 next_key_action == WM_SYSCHAR);
299 if (
character > 0 && is_keydown_message && has_char_action) {
309 auto event = std::make_unique<PendingEvent>(PendingEvent{
316 .session = std::move(current_session_),
318 pending_events_.push_back(std::move(event));
322 return !IsSysAction(
action);
325 FML_LOG(FATAL) <<
"No event handler for keyboard event with action "