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

#include <host_window_popup.h>

Inheritance diagram for flutter::HostWindowPopup:
flutter::HostWindow flutter::FlutterWindowsViewSizingDelegate

Public Member Functions

 HostWindowPopup (WindowManager *window_manager, FlutterWindowsEngine *engine, const BoxConstraints &constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
void UpdatePosition ()
 
- 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 ()
 

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)
 
static std::unique_ptr< HostWindowCreateDialogWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, HWND parent)
 
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)
 
- Protected Member Functions inherited from flutter::HostWindow
void InitializeFlutterView (HostWindowInitializationParams const &params)
 
 HostWindow (WindowManager *window_manager, FlutterWindowsEngine *engine)
 
virtual LRESULT HandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 
void EnableRecursively (bool enable)
 
HostWindowFindFirstEnabledDescendant () const
 
WindowArchetype GetArchetype () const
 
std::vector< HostWindow * > GetOwnedWindows () const
 
void DisableRecursively ()
 
 FML_DISALLOW_COPY_AND_ASSIGN (HostWindow)
 
- 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::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_popup.h.

Constructor & Destructor Documentation

◆ HostWindowPopup()

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

Definition at line 12 of file host_window_popup.cc.

18 : HostWindow(window_manager, engine),
19 get_position_callback_(get_position_callback),
20 parent_(parent),
21 isolate_(Isolate::Current()),
22 view_alive_(std::make_shared<int>(0)) {
23 // Use minimum constraints as initial size to ensure the view can be created
24 // with valid metrics. The size will be updated when content is rendered.
25 auto const initial_width =
26 static_cast<double>(constraints.smallest().width());
27 auto const initial_height =
28 static_cast<double>(constraints.smallest().height());
29
30 InitializeFlutterView(HostWindowInitializationParams{
31 .archetype = WindowArchetype::kPopup,
32 .window_style = WS_POPUP,
33 .extended_window_style = WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW,
34 .box_constraints = constraints,
35 .initial_window_rect = {{0, 0}, {initial_width, initial_height}},
36 .title = L"",
37 .owner_window = parent,
38 .nCmdShow = SW_SHOWNOACTIVATE,
39 .sizing_delegate = this,
40 .is_sized_to_content = true});
41}
void InitializeFlutterView(HostWindowInitializationParams const &params)
HostWindow(WindowManager *window_manager, FlutterWindowsEngine *engine)
static Isolate Current()
FlutterEngine engine
Definition main.cc:84

References flutter::HostWindow::HostWindowInitializationParams::archetype, flutter::Size::height(), flutter::HostWindow::InitializeFlutterView(), flutter::kPopup, flutter::BoxConstraints::smallest(), and flutter::Size::width().

Member Function Documentation

◆ UpdatePosition()

void flutter::HostWindowPopup::UpdatePosition ( )

Definition at line 82 of file host_window_popup.cc.

82 {
83 RECT parent_client_rect;
84 GetClientRect(parent_, &parent_client_rect);
85
86 // Convert top-left and bottom-right points to screen coordinates.
87 POINT parent_top_left = {parent_client_rect.left, parent_client_rect.top};
88 POINT parent_bottom_right = {parent_client_rect.right,
89 parent_client_rect.bottom};
90
91 ClientToScreen(parent_, &parent_top_left);
92 ClientToScreen(parent_, &parent_bottom_right);
93
94 // Get monitor from HWND and usable work area.
95 HMONITOR monitor = MonitorFromWindow(parent_, MONITOR_DEFAULTTONEAREST);
96 WindowRect work_area = GetWorkArea();
97
98 IsolateScope scope(isolate_);
99
100 // Frees the memory allocated by the positioner callback.
101 // Even if the callback throws an exception, the memory will be freed when
102 // rect goes out of scope.
103 std::unique_ptr<WindowRect, decltype(&free)> rect(
104 get_position_callback_(
105 WindowSize{width_, height_},
106 WindowRect{parent_top_left.x, parent_top_left.y,
107 parent_bottom_right.x - parent_top_left.x,
108 parent_bottom_right.y - parent_top_left.y},
109 work_area),
110 free);
111 SetWindowPos(window_handle_, HWND_TOP, rect->left, rect->top, rect->width,
112 rect->height, SWP_NOACTIVATE | SWP_NOOWNERZORDER);
113
114 // The positioner constrained the dimensions more than current size, apply
115 // positioner constraints.
116 if (rect->width < width_ || rect->height < height_) {
117 auto metrics_event = view_controller_->view()->CreateWindowMetricsEvent();
118 view_controller_->engine()->SendWindowMetricsEvent(metrics_event);
119 }
120}
std::unique_ptr< FlutterWindowsViewController > view_controller_

References flutter::HostWindow::view_controller_, and flutter::HostWindow::window_handle_.

Referenced by InternalFlutterWindows_WindowManager_UpdatePopupPosition().


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