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::HostWindowSatellite flutter::HostWindowTooltip

Protected Member Functions

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

Static Protected Member Functions

static WindowRect GetWorkAreaForWindow (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 std::optional< Size > GetInitialWindowSize (FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const BoxConstraints &constraints, DWORD window_style, DWORD extended_window_style, std::optional< HWND > const &owner_window, bool sized_to_content)
 
static void FocusRootViewOf (HostWindow *window)
 
static LRESULT WndProc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 

Protected Attributes

const bool resizable_
 
int physical_width_ = 0
 
int physical_height_ = 0
 
- Protected Attributes inherited from flutter::HostWindow
friend WindowManager
 
WindowManager *const window_manager_ = nullptr
 
FlutterWindowsEngine * engine_
 
std::unique_ptr< FlutterWindowsViewController > view_controller_
 
std::shared_ptr< int > alive_ = std::make_shared<int>(0)
 
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
 
HostWindow * GetOwnerWindow () const
 
void UpdateModalStateLayer ()
 
- Static Public Member Functions inherited from flutter::HostWindow
static std::unique_ptr< HostWindow > CreateRegularWindow (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< HostWindow > CreateDialogWindow (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< HostWindow > CreateTooltipWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
static std::unique_ptr< HostWindow > CreatePopupWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)
 
static std::unique_ptr< HostWindow > CreateSatelliteWindow (WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent, LPCWSTR title, bool sized_to_content, bool resizable)
 
static HostWindow * GetThisFromHandle (HWND hwnd)
 
static ActualWindowSize GetWindowContentSize (HWND hwnd)
 

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), resizable_(resizable) {}
HostWindow(WindowManager *window_manager, FlutterWindowsEngine *engine)
Definition: host_window.cc:245

◆ ~HostWindowSized()

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

Definition at line 18 of file host_window_sized.cc.

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

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, flutter::HostWindowSatellite, and flutter::HostWindowPopup.

Definition at line 49 of file host_window_sized.cc.

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

Referenced by flutter::HostWindowSatellite::ApplyContentSize().

◆ AsSizingDelegate()

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

◆ GetWorkAreaForWindow()

WindowRect flutter::HostWindowSized::GetWorkAreaForWindow ( HWND  hwnd)
staticprotected

Definition at line 82 of file host_window_sized.cc.

82  {
83  constexpr int32_t kDefaultWorkAreaSize = 10000;
84  WindowRect work_area = {0, 0, kDefaultWorkAreaSize, kDefaultWorkAreaSize};
85  HMONITOR const monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
86  if (monitor) {
87  MONITORINFO monitor_info = {};
88  monitor_info.cbSize = sizeof(monitor_info);
89  if (GetMonitorInfo(monitor, &monitor_info)) {
90  work_area.left = monitor_info.rcWork.left;
91  work_area.top = monitor_info.rcWork.top;
92  work_area.width = monitor_info.rcWork.right - monitor_info.rcWork.left;
93  work_area.height = monitor_info.rcWork.bottom - monitor_info.rcWork.top;
94  }
95  }
96  return work_area;
97 }

References flutter::WindowRect::height, flutter::WindowRect::left, flutter::WindowRect::top, and flutter::WindowRect::width.

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 74 of file host_window_sized.h.

Referenced by ApplyContentSize().


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