Flutter Windows Embedder
flutter::HostWindowSized Class Referenceabstract

#include <host_window_sized.h>

Inheritance diagram for flutter::HostWindowSized:
flutter::HostWindow flutter::FlutterWindowsViewSizingDelegate flutter::HostWindowDialog flutter::HostWindowPopup flutter::HostWindowRegular flutter::HostWindowTooltip

Protected Member Functions

 HostWindowSized (WindowManager *window_manager, FlutterWindowsEngine *engine, bool resizable)
 
 ~HostWindowSized () override=0
 
FlutterWindowsViewSizingDelegateAsSizingDelegate ()
 
virtual void ApplyContentSize (int32_t physical_width, int32_t physical_height)
 
- 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 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)
 

Protected Attributes

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_
 

Additional Inherited Members

- 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 ()
 
- 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< Size > GetWindowSizeForClientSize (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)
 

Detailed Description

Definition at line 25 of file host_window_sized.h.

Constructor & Destructor Documentation

◆ HostWindowSized()

flutter::HostWindowSized::HostWindowSized ( WindowManager window_manager,
FlutterWindowsEngine engine,
bool  resizable 
)
protected

Definition at line 13 of file host_window_sized.cc.

16  : HostWindow(window_manager, engine),
17  resizable_(resizable),
18  view_alive_(std::make_shared<int>(0)) {}
HostWindow(WindowManager *window_manager, FlutterWindowsEngine *engine)
Definition: host_window.cc:228
std::shared_ptr< int > view_alive_

◆ ~HostWindowSized()

flutter::HostWindowSized::~HostWindowSized ( )
overrideprotectedpure virtual

Definition at line 20 of file host_window_sized.cc.

20  {
21  // By the time the base destructor runs, the most-derived class must have
22  // already reset |view_controller_| (and therefore stopped the raster thread
23  // from sizing this object). See the destructor comment in host_window_sized.h
24  // for the rationale. If this fires, a HostWindowSized subclass is missing the
25  // required |view_controller_.reset()| at the start of its destructor.
26  FML_DCHECK(!view_controller_)
27  << "HostWindowSized subclass must reset view_controller_ in its "
28  "destructor.";
29 }
std::unique_ptr< FlutterWindowsViewController > view_controller_
Definition: host_window.h:259

References flutter::HostWindow::view_controller_.

Member Function Documentation

◆ ApplyContentSize()

void flutter::HostWindowSized::ApplyContentSize ( int32_t  physical_width,
int32_t  physical_height 
)
protectedvirtual

Reimplemented in flutter::HostWindowTooltip, and flutter::HostWindowPopup.

Definition at line 52 of file host_window_sized.cc.

53  {
54  WINDOWINFO window_info = {.cbSize = sizeof(WINDOWINFO)};
55  GetWindowInfo(window_handle_, &window_info);
56 
57  // Convert physical pixels to logical pixels.
58  UINT const dpi = GetDpiForHWND(window_handle_);
59  double const scale = static_cast<double>(dpi > 0 ? dpi : 96) / 96.0;
60  std::optional<Size> const window_size = GetWindowSizeForClientSize(
62  Size(physical_width / scale, physical_height / scale),
63  box_constraints_.smallest(), box_constraints_.biggest(),
64  window_info.dwStyle, window_info.dwExStyle, nullptr);
65 
66  if (!window_size) {
67  return;
68  }
69 
70  SetWindowPos(window_handle_, NULL, 0, 0, window_size->width(),
71  window_size->height(),
72  SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
73 
74  if (resizable_) {
75  // For resizable windows, stop tracking content size after the initial
76  // frame so subsequent user-initiated resizes are forwarded to Flutter.
77  view_controller_->view()->SetSizedToContent(false);
78  }
79 }
std::shared_ptr< WindowsProcTable > windows_proc_table()
BoxConstraints box_constraints_
Definition: host_window.h:268
FlutterWindowsEngine * engine_
Definition: host_window.h:254
static std::optional< Size > GetWindowSizeForClientSize(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)
Definition: host_window.cc:751
UINT GetDpiForHWND(HWND hwnd)
Definition: dpi_utils.cc:128

References flutter::HostWindow::box_constraints_, flutter::HostWindow::engine_, flutter::GetDpiForHWND(), flutter::HostWindow::GetWindowSizeForClientSize(), resizable_, flutter::HostWindow::view_controller_, flutter::HostWindow::window_handle_, and flutter::FlutterWindowsEngine::windows_proc_table().

◆ AsSizingDelegate()

FlutterWindowsViewSizingDelegate* flutter::HostWindowSized::AsSizingDelegate ( )
inlineprotected

Member Data Documentation

◆ physical_height_

int flutter::HostWindowSized::physical_height_ = 0
protected

◆ physical_width_

int flutter::HostWindowSized::physical_width_ = 0
protected

◆ resizable_

const bool flutter::HostWindowSized::resizable_
protected

Definition at line 70 of file host_window_sized.h.

Referenced by ApplyContentSize().

◆ view_alive_

std::shared_ptr<int> flutter::HostWindowSized::view_alive_
protected

Definition at line 74 of file host_window_sized.h.


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