| Flutter Windows Embedder |

flutter_window.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/windows/flutter_window.h"
6
7 #include <WinUser.h>
8 #include <dwmapi.h>
9
10 #include <chrono>
11 #include <map>
12
13 #include "flutter/fml/logging.h"
14 #include "flutter/shell/platform/embedder/embedder.h"
15 #include "flutter/shell/platform/windows/display_monitor.h"
16 #include "flutter/shell/platform/windows/dpi_utils.h"
17 #include "flutter/shell/platform/windows/flutter_windows_engine.h"
18 #include "flutter/shell/platform/windows/flutter_windows_view.h"
19 #include "flutter/shell/platform/windows/keyboard_utils.h"
20
21 namespace flutter {
22
23 namespace {
24
25 // The Windows DPI system is based on this
26 // constant for machines running at 100% scaling.
27 constexpr int base_dpi = 96;
28
29 static const int kMinTouchDeviceId = 0;
30 static const int kMaxTouchDeviceId = 128;
31
32 static const int kLinesPerScrollWindowsDefault = 3;
33
34 static constexpr int32_t kDefaultPointerDeviceId = 0;
35
36 // This method is only valid during a window message related to mouse/touch
37 // input.
38 // See
39 // https://docs.microsoft.com/en-us/windows/win32/tablet/system-events-and-mouse-messages?redirectedfrom=MSDN#distinguishing-pen-input-from-mouse-and-touch.
40 static FlutterPointerDeviceKind GetFlutterPointerDeviceKind() {
41 constexpr LPARAM kTouchOrPenSignature = 0xFF515700;
42 constexpr LPARAM kTouchSignature = kTouchOrPenSignature | 0x80;
43 constexpr LPARAM kSignatureMask = 0xFFFFFF00;
44 LPARAM info = GetMessageExtraInfo();
45 if ((info & kSignatureMask) == kTouchOrPenSignature) {
46 if ((info & kTouchSignature) == kTouchSignature) {
47 return kFlutterPointerDeviceKindTouch;
48 }
49 return kFlutterPointerDeviceKindStylus;
50 }
51 return kFlutterPointerDeviceKindMouse;
52 }
53
54 // Translates button codes from Win32 API to FlutterPointerMouseButtons.
55 static uint64_t ConvertWinButtonToFlutterButton(UINT button) {
56 switch (button) {
57 case WM_LBUTTONDOWN:
58 case WM_LBUTTONUP:
59 return kFlutterPointerButtonMousePrimary;
60 case WM_RBUTTONDOWN:
61 case WM_RBUTTONUP:
62 return kFlutterPointerButtonMouseSecondary;
63 case WM_MBUTTONDOWN:
64 case WM_MBUTTONUP:
65 return kFlutterPointerButtonMouseMiddle;
66 case XBUTTON1:
67 return kFlutterPointerButtonMouseBack;
68 case XBUTTON2:
69 return kFlutterPointerButtonMouseForward;
70 }
71 FML_LOG(WARNING) << "Mouse button not recognized: " << button;
72 return 0;
73 }
74
75 } // namespace
76
77 FlutterWindow::FlutterWindow(
78 int width,
79 int height,
80 std::shared_ptr<DisplayMonitor> const& display_monitor,
81 std::shared_ptr<WindowsProcTable> windows_proc_table,
82 std::unique_ptr<TextInputManager> text_input_manager)
83 : touch_id_generator_(kMinTouchDeviceId, kMaxTouchDeviceId),
84 display_monitor_(display_monitor),
85 windows_proc_table_(std::move(windows_proc_table)),
86 text_input_manager_(std::move(text_input_manager)),
87 ax_fragment_root_(nullptr) {
88 // Get the DPI of the primary monitor as the initial DPI. If Per-Monitor V2 is
89 // supported, |current_dpi_| should be updated in the
90 // kWmDpiChangedBeforeParent message.
91 current_dpi_ = GetDpiForHWND(nullptr);
92
93 // Get initial value for wheel scroll lines
94 // TODO: Listen to changes for this value
95 // https://github.com/flutter/flutter/issues/107248
96 UpdateScrollOffsetMultiplier();
97
98 if (windows_proc_table_ == nullptr) {
99 windows_proc_table_ = std::make_unique<WindowsProcTable>();
100 }
101 if (text_input_manager_ == nullptr) {
102 text_input_manager_ = std::make_unique<TextInputManager>();
103 }
104 keyboard_manager_ = std::make_unique<KeyboardManager>(this);
105
106 InitializeChild("FLUTTERVIEW", width, height);
107 }
108
109 // Base constructor for mocks
110 FlutterWindow::FlutterWindow()
111 : touch_id_generator_(kMinTouchDeviceId, kMaxTouchDeviceId) {}
112
113 FlutterWindow::~FlutterWindow() {
114 Destroy();
115 }
116
117 void FlutterWindow::SetView(WindowBindingHandlerDelegate* window) {
118 binding_handler_delegate_ = window;
119 if (direct_manipulation_owner_) {
120 direct_manipulation_owner_->SetBindingHandlerDelegate(window);
121 }
122 if (restored_ && window) {
123 OnWindowStateEvent(WindowStateEvent::kShow);
124 }
125 if (focused_ && window) {
126 OnWindowStateEvent(WindowStateEvent::kFocus);
127 }
128 }
129
130 float FlutterWindow::GetDpiScale() {
131 return static_cast<float>(GetCurrentDPI()) / static_cast<float>(base_dpi);
132 }
133
134 PhysicalWindowBounds FlutterWindow::GetPhysicalWindowBounds() {
135 return {GetCurrentWidth(), GetCurrentHeight()};
136 }
137
138 bool FlutterWindow::Focus() {
139 auto hwnd = GetWindowHandle();
140 if (hwnd == nullptr) {
141 return false;
142 }
143
144 HWND prevFocus = ::SetFocus(hwnd);
145 if (prevFocus == nullptr) {
146 return false;
147 }
148
149 return true;
150 }
151
152 void FlutterWindow::OnDpiScale(unsigned int dpi) {};
153
154 // When DesktopWindow notifies that a WM_Size message has come in
155 // lets FlutterEngine know about the new size.
156 void FlutterWindow::OnResize(unsigned int width, unsigned int height) {
157 if (binding_handler_delegate_ != nullptr) {
158 binding_handler_delegate_->OnWindowSizeChanged(width, height);
159 }
160 }
161
162 void FlutterWindow::OnPaint() {
163 if (binding_handler_delegate_ != nullptr) {
164 binding_handler_delegate_->OnWindowRepaint();
165 }
166 }
167
168 void FlutterWindow::OnPointerMove(double x,
169 double y,
170 FlutterPointerDeviceKind device_kind,
171 int32_t device_id,
172 int modifiers_state) {
173 binding_handler_delegate_->OnPointerMove(x, y, device_kind, device_id,
174 modifiers_state);
175 }
176
177 void FlutterWindow::OnPointerDown(double x,
178 double y,
179 FlutterPointerDeviceKind device_kind,
180 int32_t device_id,
181 UINT button) {
182 uint64_t flutter_button = ConvertWinButtonToFlutterButton(button);
183 if (flutter_button != 0) {
184 binding_handler_delegate_->OnPointerDown(
185 x, y, device_kind, device_id,
186 static_cast<FlutterPointerMouseButtons>(flutter_button));
187 }
188 }
189
190 void FlutterWindow::OnPointerUp(double x,
191 double y,
192 FlutterPointerDeviceKind device_kind,
193 int32_t device_id,
194 UINT button) {
195 uint64_t flutter_button = ConvertWinButtonToFlutterButton(button);
196 if (flutter_button != 0) {
197 binding_handler_delegate_->OnPointerUp(
198 x, y, device_kind, device_id,
199 static_cast<FlutterPointerMouseButtons>(flutter_button));
200 }
201 }
202
203 void FlutterWindow::OnPointerLeave(double x,
204 double y,
205 FlutterPointerDeviceKind device_kind,
206 int32_t device_id) {
207 binding_handler_delegate_->OnPointerLeave(x, y, device_kind, device_id);
208 }
209
210 void FlutterWindow::OnText(const std::u16string& text) {
211 binding_handler_delegate_->OnText(text);
212 }
213
214 void FlutterWindow::OnKey(int key,
215 int scancode,
216 int action,
217 char32_t character,
218 bool extended,
219 bool was_down,
220 KeyEventCallback callback) {
221 binding_handler_delegate_->OnKey(key, scancode, action, character, extended,
222 was_down, std::move(callback));
223 }
224
225 void FlutterWindow::OnComposeBegin() {
226 binding_handler_delegate_->OnComposeBegin();
227 }
228
229 void FlutterWindow::OnComposeCommit() {
230 binding_handler_delegate_->OnComposeCommit();
231 }
232
233 void FlutterWindow::OnComposeEnd() {
234 binding_handler_delegate_->OnComposeEnd();
235 }
236
237 void FlutterWindow::OnComposeChange(const std::u16string& text,
238 int cursor_pos) {
239 binding_handler_delegate_->OnComposeChange(text, cursor_pos);
240 }
241
242 void FlutterWindow::OnUpdateSemanticsEnabled(bool enabled) {
243 binding_handler_delegate_->OnUpdateSemanticsEnabled(enabled);
244 }
245
246 void FlutterWindow::OnScroll(double delta_x,
247 double delta_y,
248 FlutterPointerDeviceKind device_kind,
249 int32_t device_id) {
250 POINT point;
251 GetCursorPos(&point);
252
253 ScreenToClient(GetWindowHandle(), &point);
254 binding_handler_delegate_->OnScroll(point.x, point.y, delta_x, delta_y,
255 GetScrollOffsetMultiplier(), device_kind,
256 device_id);
257 }
258
259 void FlutterWindow::OnCursorRectUpdated(const Rect& rect) {
260 // Convert the rect from Flutter logical coordinates to device coordinates.
261 auto scale = GetDpiScale();
262 Point origin(rect.left() * scale, rect.top() * scale);
263 Size size(rect.width() * scale, rect.height() * scale);
264 UpdateCursorRect(Rect(origin, size));
265 }
266
267 void FlutterWindow::OnResetImeComposing() {
268 AbortImeComposing();
269 }
270
271 bool FlutterWindow::OnBitmapSurfaceCleared() {
272 HDC dc = ::GetDC(GetWindowHandle());
273 bool result = ::PatBlt(dc, 0, 0, current_width_, current_height_, BLACKNESS);
274 ::ReleaseDC(GetWindowHandle(), dc);
275 return result;
276 }
277
278 bool FlutterWindow::OnBitmapSurfaceUpdated(const void* allocation,
279 size_t row_bytes,
280 size_t height) {
281 HDC dc = ::GetDC(GetWindowHandle());
282 BITMAPINFO bmi = {};
283 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
284 bmi.bmiHeader.biWidth = row_bytes / 4;
285 bmi.bmiHeader.biHeight = -height;
286 bmi.bmiHeader.biPlanes = 1;
287 bmi.bmiHeader.biBitCount = 32;
288 bmi.bmiHeader.biCompression = BI_RGB;
289 bmi.bmiHeader.biSizeImage = 0;
290 int ret = ::SetDIBitsToDevice(dc, 0, 0, row_bytes / 4, height, 0, 0, 0,
291 height, allocation, &bmi, DIB_RGB_COLORS);
292 ::ReleaseDC(GetWindowHandle(), dc);
293 return ret != 0;
294 }
295
296 gfx::NativeViewAccessible FlutterWindow::GetNativeViewAccessible() {
297 if (binding_handler_delegate_ == nullptr) {
298 return nullptr;
299 }
300
301 return binding_handler_delegate_->GetNativeViewAccessible();
302 }
303
304 PointerLocation FlutterWindow::GetPrimaryPointerLocation() {
305 POINT point;
306 GetCursorPos(&point);
307 ScreenToClient(GetWindowHandle(), &point);
308 return {(size_t)point.x, (size_t)point.y};
309 }
310
311 FlutterEngineDisplayId FlutterWindow::GetDisplayId() {
312 FlutterEngineDisplayId const display_id =
313 reinterpret_cast<FlutterEngineDisplayId>(
314 MonitorFromWindow(GetWindowHandle(), MONITOR_DEFAULTTONEAREST));
315 if (!display_monitor_->FindById(display_id)) {
316 FML_LOG(ERROR) << "Current monitor not found in display list.";
317 }
318 return display_id;
319 }
320
321 void FlutterWindow::OnThemeChange() {
322 binding_handler_delegate_->OnHighContrastChanged();
323 }
324
325 ui::AXFragmentRootDelegateWin* FlutterWindow::GetAxFragmentRootDelegate() {
326 return binding_handler_delegate_->GetAxFragmentRootDelegate();
327 }
328
329 AlertPlatformNodeDelegate* FlutterWindow::GetAlertDelegate() {
330 CreateAxFragmentRoot();
331 return alert_delegate_.get();
332 }
333
334 ui::AXPlatformNodeWin* FlutterWindow::GetAlert() {
335 CreateAxFragmentRoot();
336 return alert_node_.get();
337 }
338
339 void FlutterWindow::OnWindowStateEvent(WindowStateEvent event) {
340 switch (event) {
341 case WindowStateEvent::kShow:
342 restored_ = true;
343 break;
344 case WindowStateEvent::kHide:
345 restored_ = false;
346 focused_ = false;
347 break;
348 case WindowStateEvent::kFocus:
349 focused_ = true;
350 if (binding_handler_delegate_) {
351 binding_handler_delegate_->OnFocus(
352 FlutterViewFocusState::kFocused,
353 FlutterViewFocusDirection::kUndefined);
354 }
355 break;
356 case WindowStateEvent::kUnfocus:
357 focused_ = false;
358 if (binding_handler_delegate_) {
359 binding_handler_delegate_->OnFocus(
360 FlutterViewFocusState::kUnfocused,
361 FlutterViewFocusDirection::kUndefined);
362 }
363 break;
364 }
365 HWND hwnd = GetWindowHandle();
366 if (hwnd && binding_handler_delegate_) {
367 binding_handler_delegate_->OnWindowStateEvent(hwnd, event);
368 }
369 }
370
371 void FlutterWindow::TrackMouseLeaveEvent(HWND hwnd) {
372 if (!tracking_mouse_leave_) {
373 TRACKMOUSEEVENT tme;
374 tme.cbSize = sizeof(tme);
375 tme.hwndTrack = hwnd;
376 tme.dwFlags = TME_LEAVE;
377 TrackMouseEvent(&tme);
378 tracking_mouse_leave_ = true;
379 }
380 }
381
382 void FlutterWindow::HandleResize(UINT width, UINT height) {
383 current_width_ = width;
384 current_height_ = height;
385 if (direct_manipulation_owner_) {
386 direct_manipulation_owner_->ResizeViewport(width, height);
387 }
388 OnResize(width, height);
389 }
390
391 FlutterWindow* FlutterWindow::GetThisFromHandle(HWND const window) noexcept {
392 return reinterpret_cast<FlutterWindow*>(
393 GetWindowLongPtr(window, GWLP_USERDATA));
394 }
395
396 void FlutterWindow::UpdateScrollOffsetMultiplier() {
397 UINT lines_per_scroll = kLinesPerScrollWindowsDefault;
398
399 // Get lines per scroll wheel value from Windows
400 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_scroll, 0);
401
402 // This logic is based off Chromium's implementation
403 // https://source.chromium.org/chromium/chromium/src/+/main:ui/events/blink/web_input_event_builders_win.cc;l=319-331
404 scroll_offset_multiplier_ =
405 static_cast<float>(lines_per_scroll) * 100.0 / 3.0;
406 }
407
408 void FlutterWindow::InitializeChild(const char* title,
409 unsigned int width,
410 unsigned int height) {
411 Destroy();
412 std::wstring converted_title = NarrowToWide(title);
413
414 WNDCLASS window_class = RegisterWindowClass(converted_title);
415
416 auto* result = CreateWindowEx(
417 0, window_class.lpszClassName, converted_title.c_str(),
418 WS_CHILD | WS_VISIBLE, CW_DEFAULT, CW_DEFAULT, width, height,
419 HWND_MESSAGE, nullptr, window_class.hInstance, this);
420
421 if (result == nullptr) {
422 auto error = GetLastError();
423 LPWSTR message = nullptr;
424 size_t size = FormatMessageW(
425 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
426 FORMAT_MESSAGE_IGNORE_INSERTS,
427 NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
428 reinterpret_cast<LPWSTR>(&message), 0, NULL);
429 OutputDebugString(message);
430 LocalFree(message);
431 }
432 SetUserObjectInformationA(GetCurrentProcess(),
433 UOI_TIMERPROC_EXCEPTION_SUPPRESSION, FALSE, 1);
434 // SetTimer is not precise, if a 16 ms interval is requested, it will instead
435 // often fire in an interval of 32 ms. Providing a value of 14 will ensure it
436 // runs every 16 ms, which will allow for 60 Hz trackpad gesture events, which
437 // is the maximal frequency supported by SetTimer.
438 SetTimer(result, kDirectManipulationTimer, 14, nullptr);
439 direct_manipulation_owner_ = std::make_unique<DirectManipulationOwner>(this);
440 direct_manipulation_owner_->Init(width, height);
441 }
442
443 HWND FlutterWindow::GetWindowHandle() {
444 return window_handle_;
445 }
446
447 BOOL FlutterWindow::Win32PeekMessage(LPMSG lpMsg,
448 UINT wMsgFilterMin,
449 UINT wMsgFilterMax,
450 UINT wRemoveMsg) {
451 return ::PeekMessage(lpMsg, window_handle_, wMsgFilterMin, wMsgFilterMax,
452 wRemoveMsg);
453 }
454
455 uint32_t FlutterWindow::Win32MapVkToChar(uint32_t virtual_key) {
456 return ::MapVirtualKey(virtual_key, MAPVK_VK_TO_CHAR);
457 }
458
459 UINT FlutterWindow::Win32DispatchMessage(UINT Msg,
460 WPARAM wParam,
461 LPARAM lParam) {
462 return ::SendMessage(window_handle_, Msg, wParam, lParam);
463 }
464
465 std::wstring FlutterWindow::NarrowToWide(const char* source) {
466 size_t length = strlen(source);
467 size_t outlen = 0;
468 std::wstring wideTitle(length, L'#');
469 mbstowcs_s(&outlen, &wideTitle[0], length + 1, source, length);
470 return wideTitle;
471 }
472
473 WNDCLASS FlutterWindow::RegisterWindowClass(std::wstring& title) {
474 window_class_name_ = title;
475
476 WNDCLASS window_class{};
477 window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
478 window_class.lpszClassName = title.c_str();
479 window_class.style = CS_HREDRAW | CS_VREDRAW;
480 window_class.cbClsExtra = 0;
481 window_class.cbWndExtra = 0;
482 window_class.hInstance = GetModuleHandle(nullptr);
483 window_class.hIcon = nullptr;
484 window_class.hbrBackground = 0;
485 window_class.lpszMenuName = nullptr;
486 window_class.lpfnWndProc = WndProc;
487 RegisterClass(&window_class);
488 return window_class;
489 }
490
491 LRESULT CALLBACK FlutterWindow::WndProc(HWND const window,
492 UINT const message,
493 WPARAM const wparam,
494 LPARAM const lparam) noexcept {
495 if (message == WM_NCCREATE) {
496 auto cs = reinterpret_cast<CREATESTRUCT*>(lparam);
497 SetWindowLongPtr(window, GWLP_USERDATA,
498 reinterpret_cast<LONG_PTR>(cs->lpCreateParams));
499
500 auto that = static_cast<FlutterWindow*>(cs->lpCreateParams);
501 that->window_handle_ = window;
502 that->text_input_manager_->SetWindowHandle(window);
503 RegisterTouchWindow(window, 0);
504 } else if (FlutterWindow* that = GetThisFromHandle(window)) {
505 return that->HandleMessage(message, wparam, lparam);
506 }
507
508 return DefWindowProc(window, message, wparam, lparam);
509 }
510
511 LRESULT
512 FlutterWindow::HandleMessage(UINT const message,
513 WPARAM const wparam,
514 LPARAM const lparam) noexcept {
515 LPARAM result_lparam = lparam;
516 int xPos = 0, yPos = 0;
517 UINT width = 0, height = 0;
518 UINT button_pressed = 0;
519 FlutterPointerDeviceKind device_kind;
520
521 switch (message) {
522 case kWmDpiChangedBeforeParent:
523 current_dpi_ = GetDpiForHWND(window_handle_);
524 OnDpiScale(current_dpi_);
525 return 0;
526 case WM_SIZE:
527 width = LOWORD(lparam);
528 height = HIWORD(lparam);
529
530 current_width_ = width;
531 current_height_ = height;
532 HandleResize(width, height);
533
534 OnWindowStateEvent(width == 0 && height == 0 ? WindowStateEvent::kHide
535 : WindowStateEvent::kShow);
536 break;
537 case WM_PAINT:
538 OnPaint();
539 break;
540 case WM_TOUCH: {
541 UINT num_points = LOWORD(wparam);
542 touch_points_.resize(num_points);
543 auto touch_input_handle = reinterpret_cast<HTOUCHINPUT>(lparam);
544 if (GetTouchInputInfo(touch_input_handle, num_points,
545 touch_points_.data(), sizeof(TOUCHINPUT))) {
546 for (const auto& touch : touch_points_) {
547 // Generate a mapped ID for the Windows-provided touch ID
548 auto touch_id = touch_id_generator_.GetGeneratedId(touch.dwID);
549
550 POINT pt = {TOUCH_COORD_TO_PIXEL(touch.x),
551 TOUCH_COORD_TO_PIXEL(touch.y)};
552 ScreenToClient(window_handle_, &pt);
553 auto x = static_cast<double>(pt.x);
554 auto y = static_cast<double>(pt.y);
555
556 if (touch.dwFlags & TOUCHEVENTF_DOWN) {
557 OnPointerDown(x, y, kFlutterPointerDeviceKindTouch, touch_id,
558 WM_LBUTTONDOWN);
559 } else if (touch.dwFlags & TOUCHEVENTF_MOVE) {
560 OnPointerMove(x, y, kFlutterPointerDeviceKindTouch, touch_id, 0);
561 } else if (touch.dwFlags & TOUCHEVENTF_UP) {
562 OnPointerUp(x, y, kFlutterPointerDeviceKindTouch, touch_id,
563 WM_LBUTTONDOWN);
564 OnPointerLeave(x, y, kFlutterPointerDeviceKindTouch, touch_id);
565 touch_id_generator_.ReleaseNumber(touch.dwID);
566 }
567 }
568 CloseTouchInputHandle(touch_input_handle);
569 }
570 return 0;
571 }
572 case WM_MOUSEMOVE:
573 device_kind = GetFlutterPointerDeviceKind();
574 if (device_kind == kFlutterPointerDeviceKindMouse) {
575 TrackMouseLeaveEvent(window_handle_);
576
577 xPos = GET_X_LPARAM(lparam);
578 yPos = GET_Y_LPARAM(lparam);
579 mouse_x_ = static_cast<double>(xPos);
580 mouse_y_ = static_cast<double>(yPos);
581
582 int mods = 0;
583 if (wparam & MK_CONTROL) {
584 mods |= kControl;
585 }
586 if (wparam & MK_SHIFT) {
587 mods |= kShift;
588 }
589 OnPointerMove(mouse_x_, mouse_y_, device_kind, kDefaultPointerDeviceId,
590 mods);
591 }
592 break;
593 case WM_MOUSELEAVE:
594 device_kind = GetFlutterPointerDeviceKind();
595 if (device_kind == kFlutterPointerDeviceKindMouse) {
596 OnPointerLeave(mouse_x_, mouse_y_, device_kind,
597 kDefaultPointerDeviceId);
598 }
599
600 // Once the tracked event is received, the TrackMouseEvent function
601 // resets. Set to false to make sure it's called once mouse movement is
602 // detected again.
603 tracking_mouse_leave_ = false;
604 break;
605 case WM_SETCURSOR: {
606 UINT hit_test_result = LOWORD(lparam);
607 if (hit_test_result == HTCLIENT) {
608 // Halt further processing to prevent DefWindowProc from setting the
609 // cursor back to the registered class cursor.
610 return TRUE;
611 }
612 break;
613 }
614 case WM_SETFOCUS:
615 OnWindowStateEvent(WindowStateEvent::kFocus);
616 ::CreateCaret(window_handle_, nullptr, 1, 1);
617 break;
618 case WM_KILLFOCUS:
619 OnWindowStateEvent(WindowStateEvent::kUnfocus);
620 ::DestroyCaret();
621 break;
622 case WM_LBUTTONDOWN:
623 case WM_RBUTTONDOWN:
624 case WM_MBUTTONDOWN:
625 case WM_XBUTTONDOWN:
626 device_kind = GetFlutterPointerDeviceKind();
627 if (device_kind != kFlutterPointerDeviceKindMouse) {
628 break;
629 }
630
631 if (message == WM_LBUTTONDOWN) {
632 // Capture the pointer in case the user drags outside the client area.
633 // In this case, the "mouse leave" event is delayed until the user
634 // releases the button. It's only activated on left click given that
635 // it's more common for apps to handle dragging with only the left
636 // button.
637 SetCapture(window_handle_);
638 }
639 button_pressed = message;
640 if (message == WM_XBUTTONDOWN) {
641 button_pressed = GET_XBUTTON_WPARAM(wparam);
642 }
643 xPos = GET_X_LPARAM(lparam);
644 yPos = GET_Y_LPARAM(lparam);
645 OnPointerDown(static_cast<double>(xPos), static_cast<double>(yPos),
646 device_kind, kDefaultPointerDeviceId, button_pressed);
647 break;
648 case WM_LBUTTONUP:
649 case WM_RBUTTONUP:
650 case WM_MBUTTONUP:
651 case WM_XBUTTONUP:
652 device_kind = GetFlutterPointerDeviceKind();
653 if (device_kind != kFlutterPointerDeviceKindMouse) {
654 break;
655 }
656
657 if (message == WM_LBUTTONUP) {
658 ReleaseCapture();
659 }
660 button_pressed = message;
661 if (message == WM_XBUTTONUP) {
662 button_pressed = GET_XBUTTON_WPARAM(wparam);
663 }
664 xPos = GET_X_LPARAM(lparam);
665 yPos = GET_Y_LPARAM(lparam);
666 OnPointerUp(static_cast<double>(xPos), static_cast<double>(yPos),
667 device_kind, kDefaultPointerDeviceId, button_pressed);
668 break;
669 case WM_MOUSEWHEEL:
670 OnScroll(0.0,
671 -(static_cast<short>(HIWORD(wparam)) /
672 static_cast<double>(WHEEL_DELTA)),
673 kFlutterPointerDeviceKindMouse, kDefaultPointerDeviceId);
674 break;
675 case WM_MOUSEHWHEEL:
676 OnScroll((static_cast<short>(HIWORD(wparam)) /
677 static_cast<double>(WHEEL_DELTA)),
678 0.0, kFlutterPointerDeviceKindMouse, kDefaultPointerDeviceId);
679 break;
680 case WM_GETOBJECT: {
681 LRESULT lresult = OnGetObject(message, wparam, lparam);
682 if (lresult) {
683 return lresult;
684 }
685 break;
686 }
687 case WM_TIMER:
688 if (wparam == kDirectManipulationTimer) {
689 direct_manipulation_owner_->Update();
690 return 0;
691 }
692 break;
693 case DM_POINTERHITTEST: {
694 if (direct_manipulation_owner_) {
695 UINT contact_id = GET_POINTERID_WPARAM(wparam);
696 POINTER_INPUT_TYPE pointer_type;
697 if (windows_proc_table_->GetPointerType(contact_id, &pointer_type) &&
698 pointer_type == PT_TOUCHPAD) {
699 direct_manipulation_owner_->SetContact(contact_id);
700 }
701 }
702 break;
703 }
704 case WM_INPUTLANGCHANGE:
705 // TODO(cbracken): pass this to TextInputManager to aid with
706 // language-specific issues.
707 break;
708 case WM_IME_SETCONTEXT:
709 OnImeSetContext(message, wparam, lparam);
710 // Strip the ISC_SHOWUICOMPOSITIONWINDOW bit from lparam before passing it
711 // to DefWindowProc() so that the composition window is hidden since
712 // Flutter renders the composing string itself.
713 result_lparam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
714 break;
715 case WM_IME_STARTCOMPOSITION:
716 OnImeStartComposition(message, wparam, lparam);
717 // Suppress further processing by DefWindowProc() so that the default
718 // system IME style isn't used, but rather the one set in the
719 // WM_IME_SETCONTEXT handler.
720 return TRUE;
721 case WM_IME_COMPOSITION:
722 OnImeComposition(message, wparam, lparam);
723 if (lparam & GCS_RESULTSTR || lparam & GCS_COMPSTR) {
724 // Suppress further processing by DefWindowProc() since otherwise it
725 // will emit the result string as WM_CHAR messages on commit. Instead,
726 // committing the composing text to the EditableText string is handled
727 // in TextInputModel::CommitComposing, triggered by
728 // OnImeEndComposition().
729 return TRUE;
730 }
731 break;
732 case WM_IME_ENDCOMPOSITION:
733 OnImeEndComposition(message, wparam, lparam);
734 return TRUE;
735 case WM_IME_REQUEST:
736 OnImeRequest(message, wparam, lparam);
737 break;
738 case WM_UNICHAR: {
739 // Tell third-pary app, we can support Unicode.
740 if (wparam == UNICODE_NOCHAR)
741 return TRUE;
742 // DefWindowProc will send WM_CHAR for this WM_UNICHAR.
743 break;
744 }
745 case WM_THEMECHANGED:
746 OnThemeChange();
747 break;
748 case WM_DEADCHAR:
749 case WM_SYSDEADCHAR:
750 case WM_CHAR:
751 case WM_SYSCHAR:
752 case WM_KEYDOWN:
753 case WM_SYSKEYDOWN:
754 case WM_KEYUP:
755 case WM_SYSKEYUP:
756 if (keyboard_manager_->HandleMessage(message, wparam, lparam)) {
757 return 0;
758 }
759 break;
760 }
761
762 return Win32DefWindowProc(window_handle_, message, wparam, result_lparam);
763 }
764
765 LRESULT FlutterWindow::OnGetObject(UINT const message,
766 WPARAM const wparam,
767 LPARAM const lparam) {
768 LRESULT reference_result = static_cast<LRESULT>(0L);
769
770 // Only the lower 32 bits of lparam are valid when checking the object id
771 // because it sometimes gets sign-extended incorrectly (but not always).
772 DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(lparam));
773
774 bool is_uia_request = static_cast<DWORD>(UiaRootObjectId) == obj_id;
775 bool is_msaa_request = static_cast<DWORD>(OBJID_CLIENT) == obj_id;
776
777 if (is_uia_request || is_msaa_request) {
778 // On Windows, we don't get a notification that the screen reader has been
779 // enabled or disabled. There is an API to query for screen reader state,
780 // but that state isn't set by all screen readers, including by Narrator,
781 // the screen reader that ships with Windows:
782 // https://docs.microsoft.com/en-us/windows/win32/winauto/screen-reader-parameter
783 //
784 // Instead, we enable semantics in Flutter if Windows issues queries for
785 // Microsoft Active Accessibility (MSAA) COM objects.
786 OnUpdateSemanticsEnabled(true);
787 }
788
789 gfx::NativeViewAccessible root_view = GetNativeViewAccessible();
790 // TODO(schectman): UIA is currently disabled by default.
791 // https://github.com/flutter/flutter/issues/114547
792 if (root_view) {
793 CreateAxFragmentRoot();
794 if (is_uia_request) {
795 #ifdef FLUTTER_ENGINE_USE_UIA
796 // Retrieve UIA object for the root view.
797 Microsoft::WRL::ComPtr<IRawElementProviderSimple> root;
798 if (SUCCEEDED(
799 ax_fragment_root_->GetNativeViewAccessible()->QueryInterface(
800 IID_PPV_ARGS(&root)))) {
801 // Return the UIA object via UiaReturnRawElementProvider(). See:
802 // https://docs.microsoft.com/en-us/windows/win32/winauto/wm-getobject
803 reference_result = UiaReturnRawElementProvider(window_handle_, wparam,
804 lparam, root.Get());
805 } else {
806 FML_LOG(ERROR) << "Failed to query AX fragment root.";
807 }
808 #endif // FLUTTER_ENGINE_USE_UIA
809 } else if (is_msaa_request) {
810 // Create the accessibility root if it does not already exist.
811 // Return the IAccessible for the root view.
812 Microsoft::WRL::ComPtr<IAccessible> root;
813 ax_fragment_root_->GetNativeViewAccessible()->QueryInterface(
814 IID_PPV_ARGS(&root));
815 reference_result = LresultFromObject(IID_IAccessible, wparam, root.Get());
816 }
817 }
818 return reference_result;
819 }
820
821 void FlutterWindow::OnImeSetContext(UINT const message,
822 WPARAM const wparam,
823 LPARAM const lparam) {
824 if (wparam != 0) {
825 text_input_manager_->CreateImeWindow();
826 }
827 }
828
829 void FlutterWindow::OnImeStartComposition(UINT const message,
830 WPARAM const wparam,
831 LPARAM const lparam) {
832 text_input_manager_->CreateImeWindow();
833 OnComposeBegin();
834 }
835
836 void FlutterWindow::OnImeComposition(UINT const message,
837 WPARAM const wparam,
838 LPARAM const lparam) {
839 // Update the IME window position.
840 text_input_manager_->UpdateImeWindow();
841
842 if (lparam == 0) {
843 OnComposeChange(u"", 0);
844 OnComposeCommit();
845 }
846
847 // Process GCS_RESULTSTR at fisrt, because Google Japanese Input and ATOK send
848 // both GCS_RESULTSTR and GCS_COMPSTR to commit composed text and send new
849 // composing text.
850 if (lparam & GCS_RESULTSTR) {
851 // Commit but don't end composing.
852 // Read the committed composing string.
853 long pos = text_input_manager_->GetComposingCursorPosition();
854 std::optional<std::u16string> text = text_input_manager_->GetResultString();
855 if (text) {
856 OnComposeChange(text.value(), pos);
857 OnComposeCommit();
858 }
859 }
860 if (lparam & GCS_COMPSTR) {
861 // Read the in-progress composing string.
862 long pos = text_input_manager_->GetComposingCursorPosition();
863 std::optional<std::u16string> text =
864 text_input_manager_->GetComposingString();
865 if (text) {
866 OnComposeChange(text.value(), pos);
867 }
868 }
869 }
870
871 void FlutterWindow::OnImeEndComposition(UINT const message,
872 WPARAM const wparam,
873 LPARAM const lparam) {
874 text_input_manager_->DestroyImeWindow();
875 OnComposeEnd();
876 }
877
878 void FlutterWindow::OnImeRequest(UINT const message,
879 WPARAM const wparam,
880 LPARAM const lparam) {
881 // TODO(cbracken): Handle IMR_RECONVERTSTRING, IMR_DOCUMENTFEED,
882 // and IMR_QUERYCHARPOSITION messages.
883 // https://github.com/flutter/flutter/issues/74547
884 }
885
886 void FlutterWindow::AbortImeComposing() {
887 text_input_manager_->AbortComposing();
888 }
889
890 void FlutterWindow::UpdateCursorRect(const Rect& rect) {
891 text_input_manager_->UpdateCaretRect(rect);
892 }
893
894 UINT FlutterWindow::GetCurrentDPI() {
895 return current_dpi_;
896 }
897
898 UINT FlutterWindow::GetCurrentWidth() {
899 return current_width_;
900 }
901
902 UINT FlutterWindow::GetCurrentHeight() {
903 return current_height_;
904 }
905
906 float FlutterWindow::GetScrollOffsetMultiplier() {
907 return scroll_offset_multiplier_;
908 }
909
910 LRESULT FlutterWindow::Win32DefWindowProc(HWND hWnd,
911 UINT Msg,
912 WPARAM wParam,
913 LPARAM lParam) {
914 return ::DefWindowProc(hWnd, Msg, wParam, lParam);
915 }
916
917 void FlutterWindow::Destroy() {
918 if (window_handle_) {
919 text_input_manager_->SetWindowHandle(nullptr);
920 DestroyWindow(window_handle_);
921 window_handle_ = nullptr;
922 }
923
924 UnregisterClass(window_class_name_.c_str(), nullptr);
925 }
926
927 void FlutterWindow::CreateAxFragmentRoot() {
928 if (ax_fragment_root_) {
929 return;
930 }
931 ax_fragment_root_ = std::make_unique<ui::AXFragmentRootWin>(
932 window_handle_, GetAxFragmentRootDelegate());
933 alert_delegate_ =
934 std::make_unique<AlertPlatformNodeDelegate>(*ax_fragment_root_);
935 ui::AXPlatformNode* alert_node =
936 ui::AXPlatformNodeWin::Create(alert_delegate_.get());
937 alert_node_.reset(static_cast<ui::AXPlatformNodeWin*>(alert_node));
938 ax_fragment_root_->SetAlertNode(alert_node_.get());
939 }
940
941 } // namespace flutter
flutter::AlertPlatformNodeDelegate
Definition: alert_platform_node_delegate.h:18
flutter::FlutterWindow::OnCursorRectUpdated
virtual void OnCursorRectUpdated(const Rect &rect) override
Definition: flutter_window.cc:259
flutter::FlutterWindow::OnPointerLeave
virtual void OnPointerLeave(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id)
Definition: flutter_window.cc:203
flutter::FlutterWindow::FlutterWindow
FlutterWindow()
Definition: flutter_window.cc:110
flutter::FlutterWindow::GetScrollOffsetMultiplier
virtual float GetScrollOffsetMultiplier()
Definition: flutter_window.cc:906
flutter::FlutterWindow::Focus
virtual bool Focus() override
Definition: flutter_window.cc:138
flutter::FlutterWindow::GetAlert
virtual ui::AXPlatformNodeWin * GetAlert() override
Definition: flutter_window.cc:334
flutter::FlutterWindow::OnText
virtual void OnText(const std::u16string &text) override
Definition: flutter_window.cc:210
flutter::FlutterWindow::Win32DispatchMessage
virtual UINT Win32DispatchMessage(UINT Msg, WPARAM wParam, LPARAM lParam) override
Definition: flutter_window.cc:459
flutter::FlutterWindow::Win32PeekMessage
virtual BOOL Win32PeekMessage(LPMSG lpMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) override
Definition: flutter_window.cc:447
flutter::FlutterWindow::OnThemeChange
virtual void OnThemeChange()
Definition: flutter_window.cc:321
flutter::FlutterWindow::alert_delegate_
std::unique_ptr< AlertPlatformNodeDelegate > alert_delegate_
Definition: flutter_window.h:274
flutter::FlutterWindow::OnBitmapSurfaceUpdated
virtual bool OnBitmapSurfaceUpdated(const void *allocation, size_t row_bytes, size_t height) override
Definition: flutter_window.cc:278
flutter::FlutterWindow::OnImeRequest
virtual void OnImeRequest(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:878
flutter::FlutterWindow::Win32DefWindowProc
virtual LRESULT Win32DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: flutter_window.cc:910
flutter::FlutterWindow::OnImeStartComposition
virtual void OnImeStartComposition(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:829
flutter::FlutterWindow::NarrowToWide
std::wstring NarrowToWide(const char *source)
Definition: flutter_window.cc:465
flutter::FlutterWindow::GetDisplayId
virtual FlutterEngineDisplayId GetDisplayId() override
Definition: flutter_window.cc:311
flutter::FlutterWindow::GetAxFragmentRootDelegate
virtual ui::AXFragmentRootDelegateWin * GetAxFragmentRootDelegate()
Definition: flutter_window.cc:325
flutter::FlutterWindow::OnScroll
virtual void OnScroll(double delta_x, double delta_y, FlutterPointerDeviceKind device_kind, int32_t device_id)
Definition: flutter_window.cc:246
flutter::FlutterWindow::OnPointerUp
virtual void OnPointerUp(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, UINT button)
Definition: flutter_window.cc:190
flutter::FlutterWindow::InitializeChild
void InitializeChild(const char *title, unsigned int width, unsigned int height)
Definition: flutter_window.cc:408
flutter::FlutterWindow::OnPaint
virtual void OnPaint()
Definition: flutter_window.cc:162
flutter::FlutterWindow::GetAlertDelegate
virtual AlertPlatformNodeDelegate * GetAlertDelegate() override
Definition: flutter_window.cc:329
flutter::FlutterWindow::direct_manipulation_owner_
std::unique_ptr< DirectManipulationOwner > direct_manipulation_owner_
Definition: flutter_window.h:281
flutter::FlutterWindow::GetWindowHandle
virtual HWND GetWindowHandle() override
Definition: flutter_window.cc:443
flutter::FlutterWindow::OnPointerDown
virtual void OnPointerDown(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, UINT button)
Definition: flutter_window.cc:177
flutter::FlutterWindow::GetCurrentWidth
UINT GetCurrentWidth()
Definition: flutter_window.cc:898
flutter::FlutterWindow::OnComposeCommit
virtual void OnComposeCommit()
Definition: flutter_window.cc:229
flutter::FlutterWindow::UpdateCursorRect
virtual void UpdateCursorRect(const Rect &rect)
Definition: flutter_window.cc:890
flutter::FlutterWindow::GetPhysicalWindowBounds
virtual PhysicalWindowBounds GetPhysicalWindowBounds() override
Definition: flutter_window.cc:134
flutter::FlutterWindow::OnImeSetContext
virtual void OnImeSetContext(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:821
flutter::FlutterWindow::OnWindowStateEvent
virtual void OnWindowStateEvent(WindowStateEvent event)
Definition: flutter_window.cc:339
flutter::FlutterWindow::OnKey
virtual void OnKey(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback) override
Definition: flutter_window.cc:214
flutter::FlutterWindow::OnPointerMove
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, int modifiers_state)
Definition: flutter_window.cc:168
flutter::FlutterWindow::alert_node_
std::unique_ptr< ui::AXPlatformNodeWin > alert_node_
Definition: flutter_window.h:277
flutter::FlutterWindow::GetPrimaryPointerLocation
virtual PointerLocation GetPrimaryPointerLocation() override
Definition: flutter_window.cc:304
flutter::FlutterWindow::GetCurrentHeight
UINT GetCurrentHeight()
Definition: flutter_window.cc:902
flutter::FlutterWindow::OnComposeEnd
virtual void OnComposeEnd()
Definition: flutter_window.cc:233
flutter::FlutterWindow::SetView
virtual void SetView(WindowBindingHandlerDelegate *view) override
Definition: flutter_window.cc:117
flutter::FlutterWindow::~FlutterWindow
virtual ~FlutterWindow()
Definition: flutter_window.cc:113
flutter::FlutterWindow::HandleMessage
LRESULT HandleMessage(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
Definition: flutter_window.cc:512
flutter::FlutterWindow::OnComposeChange
virtual void OnComposeChange(const std::u16string &text, int cursor_pos)
Definition: flutter_window.cc:237
flutter::FlutterWindow::OnResetImeComposing
virtual void OnResetImeComposing() override
Definition: flutter_window.cc:267
flutter::FlutterWindow::Win32MapVkToChar
virtual uint32_t Win32MapVkToChar(uint32_t virtual_key) override
Definition: flutter_window.cc:455
flutter::FlutterWindow::OnImeComposition
virtual void OnImeComposition(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:836
flutter::FlutterWindow::GetCurrentDPI
UINT GetCurrentDPI()
Definition: flutter_window.cc:894
flutter::FlutterWindow::OnDpiScale
virtual void OnDpiScale(unsigned int dpi)
Definition: flutter_window.cc:152
flutter::FlutterWindow::AbortImeComposing
virtual void AbortImeComposing()
Definition: flutter_window.cc:886
flutter::FlutterWindow::GetDpiScale
virtual float GetDpiScale() override
Definition: flutter_window.cc:130
flutter::FlutterWindow::OnUpdateSemanticsEnabled
virtual void OnUpdateSemanticsEnabled(bool enabled)
Definition: flutter_window.cc:242
flutter::FlutterWindow::OnGetObject
virtual LRESULT OnGetObject(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:765
flutter::FlutterWindow::GetNativeViewAccessible
virtual gfx::NativeViewAccessible GetNativeViewAccessible()
Definition: flutter_window.cc:296
flutter::FlutterWindow::OnComposeBegin
virtual void OnComposeBegin()
Definition: flutter_window.cc:225
flutter::FlutterWindow::OnBitmapSurfaceCleared
virtual bool OnBitmapSurfaceCleared() override
Definition: flutter_window.cc:271
flutter::FlutterWindow::OnResize
virtual void OnResize(unsigned int width, unsigned int height)
Definition: flutter_window.cc:156
flutter::FlutterWindow::OnImeEndComposition
virtual void OnImeEndComposition(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: flutter_window.cc:871
flutter::KeyboardManager::WindowDelegate::KeyEventCallback
std::function< void(bool)> KeyEventCallback
Definition: keyboard_manager.h:54
flutter::Point
Definition: geometry.h:15
flutter::Rect
Definition: geometry.h:59
flutter::Rect::top
double top() const
Definition: geometry.h:67
flutter::Rect::height
double height() const
Definition: geometry.h:71
flutter::Rect::left
double left() const
Definition: geometry.h:66
flutter::Rect::width
double width() const
Definition: geometry.h:70
flutter::Size
Definition: geometry.h:35
flutter::WindowBindingHandlerDelegate
Definition: window_binding_handler_delegate.h:18
flutter::WindowBindingHandlerDelegate::OnPointerDown
virtual void OnPointerDown(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, FlutterPointerMouseButtons button)=0
flutter::WindowBindingHandlerDelegate::OnPointerMove
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, int modifiers_state)=0
flutter::WindowBindingHandlerDelegate::OnComposeChange
virtual void OnComposeChange(const std::u16string &text, int cursor_pos)=0
flutter::WindowBindingHandlerDelegate::OnHighContrastChanged
virtual void OnHighContrastChanged()=0
flutter::WindowBindingHandlerDelegate::OnText
virtual void OnText(const std::u16string &)=0
flutter::WindowBindingHandlerDelegate::OnPointerLeave
virtual void OnPointerLeave(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnKey
virtual void OnKey(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback)=0
flutter::WindowBindingHandlerDelegate::OnUpdateSemanticsEnabled
virtual void OnUpdateSemanticsEnabled(bool enabled)=0
flutter::WindowBindingHandlerDelegate::OnPointerUp
virtual void OnPointerUp(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, FlutterPointerMouseButtons button)=0
flutter::WindowBindingHandlerDelegate::OnWindowStateEvent
virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)=0
flutter::WindowBindingHandlerDelegate::GetAxFragmentRootDelegate
virtual ui::AXFragmentRootDelegateWin * GetAxFragmentRootDelegate()=0
flutter::WindowBindingHandlerDelegate::OnComposeEnd
virtual void OnComposeEnd()=0
flutter::WindowBindingHandlerDelegate::OnWindowRepaint
virtual void OnWindowRepaint()=0
flutter::WindowBindingHandlerDelegate::GetNativeViewAccessible
virtual gfx::NativeViewAccessible GetNativeViewAccessible()=0
flutter::WindowBindingHandlerDelegate::OnWindowSizeChanged
virtual bool OnWindowSizeChanged(size_t width, size_t height)=0
flutter::WindowBindingHandlerDelegate::OnComposeBegin
virtual void OnComposeBegin()=0
flutter::WindowBindingHandlerDelegate::OnFocus
virtual void OnFocus(FlutterViewFocusState focus_state, FlutterViewFocusDirection direction)=0
flutter::WindowBindingHandlerDelegate::OnScroll
virtual void OnScroll(double x, double y, double delta_x, double delta_y, int scroll_offset_multiplier, FlutterPointerDeviceKind device_kind, int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnComposeCommit
virtual void OnComposeCommit()=0
display_monitor
const DisplayMonitor * display_monitor
Definition: display_monitor.cc:18
display_monitor.h
dpi_utils.h
flutter_window.h
flutter_windows_engine.h
flutter_windows_view.h
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
key
int key
Definition: keyboard_key_handler_unittests.cc:114
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
action
int action
Definition: keyboard_key_handler_unittests.cc:116
scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
text
std::u16string text
Definition: keyboard_unittests.cc:332
message
Win32Message message
Definition: keyboard_unittests.cc:137
keyboard_utils.h
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::kShift
constexpr int kShift
Definition: keyboard_utils.h:14
flutter::GetDpiForHWND
UINT GetDpiForHWND(HWND hwnd)
Definition: dpi_utils.cc:128
flutter::WindowStateEvent
WindowStateEvent
An event representing a change in window state that may update the.
Definition: windows_lifecycle_manager.h:24
flutter::WindowStateEvent::kHide
@ kHide
flutter::WindowStateEvent::kUnfocus
@ kUnfocus
flutter::WindowStateEvent::kShow
@ kShow
flutter::WindowStateEvent::kFocus
@ kFocus
flutter::kControl
constexpr int kControl
Definition: keyboard_utils.h:15
flutter::PhysicalWindowBounds
Definition: window_binding_handler.h:28
flutter::PointerLocation
Definition: window_binding_handler.h:35