Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::HostWindowTooltip Class Reference

#include <host_window_tooltip.h>

Inheritance diagram for flutter::HostWindowTooltip:
flutter::HostWindowSized flutter::HostWindow flutter::FlutterWindowsViewSizingDelegate

Public Member Functions

 HostWindowTooltip (WindowManager *window_manager, FlutterWindowsEngine *engine, const BoxConstraints &constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
void UpdatePosition ()
 
 ~HostWindowTooltip () override
 
- Public Member Functions inherited from flutter::HostWindow
virtual ~HostWindow ()
 
HWND GetWindowHandle () const
 
HWND GetFlutterViewWindowHandle () const
 
void SetContentSize (const WindowSizeRequest &size)
 
void SetConstraints (const WindowConstraints &constraints)
 
virtual void SetFullscreen (bool fullscreen, std::optional< FlutterEngineDisplayId > display_id)
 
virtual bool GetFullscreen () const
 
HostWindowGetOwnerWindow () const
 
void UpdateModalStateLayer ()
 

Protected Member Functions

void ApplyContentSize (int32_t physical_width, int32_t physical_height) override
 
LRESULT HandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) override
 
- Protected Member Functions inherited from flutter::HostWindowSized
 HostWindowSized (WindowManager *window_manager, FlutterWindowsEngine *engine, bool resizable)
 
 ~HostWindowSized () override=0
 
FlutterWindowsViewSizingDelegateAsSizingDelegate ()
 
- Protected Member Functions inherited from flutter::HostWindow
void InitializeFlutterView (HostWindowInitializationParams const &params)
 
 HostWindow (WindowManager *window_manager, FlutterWindowsEngine *engine)
 
void HandleWindowActivation (HWND hwnd, WPARAM wparam)
 
void EnableRecursively (bool enable)
 
HostWindowFindFirstEnabledDescendant () const
 
WindowArchetype GetArchetype () const
 
std::vector< HostWindow * > GetOwnedWindows () const
 
void DisableRecursively ()
 
 FML_DISALLOW_COPY_AND_ASSIGN (HostWindow)
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::HostWindow
static std::unique_ptr< HostWindowCreateRegularWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, bool sized_to_content, bool resizable)
 
static std::unique_ptr< HostWindowCreateDialogWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, HWND parent, bool sized_to_content, bool resizable)
 
static std::unique_ptr< HostWindowCreateTooltipWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
static std::unique_ptr< HostWindowCreatePopupWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
static HostWindowGetThisFromHandle (HWND hwnd)
 
static ActualWindowSize GetWindowContentSize (HWND hwnd)
 
- Static Protected Member Functions inherited from flutter::HostWindow
static std::optional< SizeGetWindowSizeForClientSize (WindowsProcTable const &win32, Size const &client_size, std::optional< Size > smallest, std::optional< Size > biggest, DWORD window_style, DWORD extended_window_style, std::optional< HWND > const &owner_hwnd)
 
static void FocusRootViewOf (HostWindow *window)
 
static LRESULT WndProc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 
- Protected Attributes inherited from flutter::HostWindowSized
const bool resizable_
 
std::shared_ptr< int > view_alive_
 
int physical_width_ = 0
 
int physical_height_ = 0
 
- Protected Attributes inherited from flutter::HostWindow
friend WindowManager
 
WindowManager *const window_manager_ = nullptr
 
FlutterWindowsEngineengine_
 
std::unique_ptr< FlutterWindowsViewControllerview_controller_
 
WindowArchetype archetype_ = WindowArchetype::kRegular
 
HWND window_handle_
 
BoxConstraints box_constraints_
 
bool is_being_destroyed_ = false
 
bool is_fullscreen_ = false
 
SavedWindowInfo saved_window_info_
 
Microsoft::WRL::ComPtr< ITaskbarList2 > task_bar_list_
 

Detailed Description

Definition at line 14 of file host_window_tooltip.h.

Constructor & Destructor Documentation

◆ HostWindowTooltip()

flutter::HostWindowTooltip::HostWindowTooltip ( WindowManager window_manager,
FlutterWindowsEngine engine,
const BoxConstraints constraints,
GetWindowPositionCallback  get_position_callback,
HWND  parent 
)

Definition at line 11 of file host_window_tooltip.cc.

17 : HostWindowSized(window_manager, engine, /*resizable=*/false),
18 get_position_callback_(get_position_callback),
19 parent_(parent),
20 isolate_(Isolate::Current()) {
21 // Use minimum constraints as initial size to ensure the view can be created
22 // with valid metrics.
23 auto const initial_width =
24 static_cast<double>(constraints.smallest().width());
25 auto const initial_height =
26 static_cast<double>(constraints.smallest().height());
27
28 InitializeFlutterView(HostWindowInitializationParams{
29 .archetype = WindowArchetype::kTooltip,
30 .window_style = WS_POPUP,
31 .extended_window_style = WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW,
32 .box_constraints = constraints,
33 .initial_window_rect = {{0, 0}, {initial_width, initial_height}},
34 .title = L"",
35 .owner_window = parent,
36 .nCmdShow = SW_SHOWNOACTIVATE,
37 .sizing_delegate = AsSizingDelegate(),
38 .is_sized_to_content = true});
39 SetWindowLongPtr(window_handle_, GWLP_HWNDPARENT,
40 reinterpret_cast<LONG_PTR>(parent_));
41}
void InitializeFlutterView(HostWindowInitializationParams const &params)
HostWindowSized(WindowManager *window_manager, FlutterWindowsEngine *engine, bool resizable)
FlutterWindowsViewSizingDelegate * AsSizingDelegate()
static Isolate Current()
FlutterEngine engine
Definition main.cc:84
__w64 long LONG_PTR

References flutter::HostWindow::HostWindowInitializationParams::archetype, flutter::HostWindowSized::AsSizingDelegate(), flutter::Size::height(), flutter::HostWindow::InitializeFlutterView(), flutter::kTooltip, flutter::BoxConstraints::smallest(), flutter::Size::width(), and flutter::HostWindow::window_handle_.

◆ ~HostWindowTooltip()

flutter::HostWindowTooltip::~HostWindowTooltip ( )
override

Definition at line 43 of file host_window_tooltip.cc.

43 {
44 // Reset the view while this most-derived object is still fully alive, to stop
45 // the raster thread from sizing it (via the overridden ApplyContentSize /
46 // GetWorkArea) before any subobject is torn down. See the destructor comment
47 // in host_window_sized.h for the rationale.
48 view_controller_.reset();
49}
std::unique_ptr< FlutterWindowsViewController > view_controller_

References flutter::HostWindow::view_controller_.

Member Function Documentation

◆ ApplyContentSize()

void flutter::HostWindowTooltip::ApplyContentSize ( int32_t  physical_width,
int32_t  physical_height 
)
overrideprotectedvirtual

Reimplemented from flutter::HostWindowSized.

Definition at line 51 of file host_window_tooltip.cc.

References UpdatePosition().

◆ HandleMessage()

LRESULT flutter::HostWindowTooltip::HandleMessage ( HWND  hwnd,
UINT  message,
WPARAM  wparam,
LPARAM  lparam 
)
overrideprotectedvirtual

Reimplemented from flutter::HostWindow.

Definition at line 108 of file host_window_tooltip.cc.

111 {
112 switch (message) {
113 case WM_MOUSEACTIVATE:
114 // Prevent activation when clicked
115 return MA_NOACTIVATE;
116
117 case WM_NCACTIVATE:
118 // Return TRUE to prevent visual activation changes
119 return TRUE;
120
121 case WM_ACTIVATE:
122 // Immediately deactivate if somehow activated
123 if (LOWORD(wparam) != WA_INACTIVE) {
124 HWND hFocus = GetFocus();
125 SetFocus(nullptr);
126 }
127 break;
128 }
129
130 return HostWindow::HandleMessage(hwnd, message, wparam, lparam);
131}
virtual LRESULT HandleMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
const char * message
return TRUE

References flutter::HostWindow::HandleMessage(), message, and TRUE.

◆ UpdatePosition()

void flutter::HostWindowTooltip::UpdatePosition ( )

Definition at line 73 of file host_window_tooltip.cc.

73 {
74 RECT parent_client_rect;
75 GetClientRect(parent_, &parent_client_rect);
76
77 // Convert top-left and bottom-right points to screen coordinates.
78 POINT parent_top_left = {parent_client_rect.left, parent_client_rect.top};
79 POINT parent_bottom_right = {parent_client_rect.right,
80 parent_client_rect.bottom};
81
82 ClientToScreen(parent_, &parent_top_left);
83 ClientToScreen(parent_, &parent_bottom_right);
84
85 // Get monitor from HWND and usable work area.
86 HMONITOR monitor = MonitorFromWindow(parent_, MONITOR_DEFAULTTONEAREST);
87 WindowRect work_area = GetWorkArea();
88
89 IsolateScope scope(isolate_);
90 auto rect = get_position_callback_(
92 WindowRect{parent_top_left.x, parent_top_left.y,
93 parent_bottom_right.x - parent_top_left.x,
94 parent_bottom_right.y - parent_top_left.y},
95 work_area);
96 SetWindowPos(window_handle_, nullptr, rect->left, rect->top, rect->width,
97 rect->height, SWP_NOACTIVATE | SWP_NOOWNERZORDER);
98 free(rect);
99
100 // The positioner constrained the dimensions more than current size, apply
101 // positioner constraints.
102 if (rect->width < physical_width_ || rect->height < physical_height_) {
103 auto metrics_event = view_controller_->view()->CreateWindowMetricsEvent();
104 view_controller_->engine()->SendWindowMetricsEvent(metrics_event);
105 }
106}

References flutter::HostWindowSized::physical_height_, flutter::HostWindowSized::physical_width_, flutter::HostWindow::view_controller_, and flutter::HostWindow::window_handle_.

Referenced by ApplyContentSize(), and InternalFlutterWindows_WindowManager_UpdateTooltipPosition().


The documentation for this class was generated from the following files: