14 const BoxConstraints& constraints,
15 bool is_sized_to_content,
19 get_position_callback_(get_position_callback),
22 view_alive_(std::make_shared<int>(0)) {
26 auto const initial_width =
27 static_cast<double>(constraints.smallest().width());
28 auto const initial_height =
29 static_cast<double>(constraints.smallest().height());
33 .window_style = WS_POPUP,
34 .extended_window_style = WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW,
35 .box_constraints = constraints,
36 .initial_window_rect = {{0, 0}, {initial_width, initial_height}},
38 .owner_window = parent,
39 .nCmdShow = SW_SHOWNOACTIVATE,
40 .sizing_delegate =
this,
41 .is_sized_to_content = is_sized_to_content});
43 reinterpret_cast<LONG_PTR
>(parent_));
46 void HostWindowTooltip::DidUpdateViewSize(int32_t width, int32_t height) {
48 std::weak_ptr<int> weak_view_alive = view_alive_;
50 auto const view_alive = weak_view_alive.lock();
54 if (width_ == width && height_ == height) {
68 WindowRect HostWindowTooltip::GetWorkArea()
const {
69 constexpr int32_t kDefaultWorkAreaSize = 10000;
70 WindowRect work_area = {0, 0, kDefaultWorkAreaSize, kDefaultWorkAreaSize};
71 HMONITOR monitor = MonitorFromWindow(parent_, MONITOR_DEFAULTTONEAREST);
73 MONITORINFO monitor_info = {0};
74 monitor_info.cbSize =
sizeof(monitor_info);
75 if (GetMonitorInfo(monitor, &monitor_info)) {
76 work_area.left = monitor_info.rcWork.left;
77 work_area.top = monitor_info.rcWork.top;
78 work_area.width = monitor_info.rcWork.right - monitor_info.rcWork.left;
79 work_area.height = monitor_info.rcWork.bottom - monitor_info.rcWork.top;
86 RECT parent_client_rect;
87 GetClientRect(parent_, &parent_client_rect);
90 POINT parent_top_left = {parent_client_rect.left, parent_client_rect.top};
91 POINT parent_bottom_right = {parent_client_rect.right,
92 parent_client_rect.bottom};
94 ClientToScreen(parent_, &parent_top_left);
95 ClientToScreen(parent_, &parent_bottom_right);
98 HMONITOR monitor = MonitorFromWindow(parent_, MONITOR_DEFAULTTONEAREST);
102 auto rect = get_position_callback_(
104 WindowRect{parent_top_left.x, parent_top_left.y,
105 parent_bottom_right.x - parent_top_left.x,
106 parent_bottom_right.y - parent_top_left.y},
108 SetWindowPos(
window_handle_,
nullptr, rect->left, rect->top, rect->width,
109 rect->height, SWP_NOACTIVATE | SWP_NOOWNERZORDER);
114 if (rect->width < width_ || rect->height < height_) {
125 case WM_MOUSEACTIVATE:
127 return MA_NOACTIVATE;
135 if (LOWORD(wparam) != WA_INACTIVE) {
136 HWND hFocus = GetFocus();
TaskRunner * task_runner()
void InitializeFlutterView(HostWindowInitializationParams const ¶ms)
std::unique_ptr< FlutterWindowsViewController > view_controller_
FlutterWindowsEngine * engine_
virtual LRESULT HandleMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void PostTask(TaskClosure task)
WindowRect *(* GetWindowPositionCallback)(const WindowSize &child_size, const WindowRect &parent_rect, const WindowRect &output_rect)
WindowArchetype archetype