Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
host_window_regular.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
9
10namespace flutter {
11
12namespace {
13
14// Returns the Win32 window style for a regular window.
15//
16// If |resizable| is false, the resize border (WS_THICKFRAME) and maximize
17// button (WS_MAXIMIZEBOX) are omitted.
18DWORD GetWindowStyleForRegular(bool resizable) {
19 DWORD style = WS_OVERLAPPEDWINDOW;
20 if (!resizable) {
21 style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
22 }
23 return style;
24}
25
26} // namespace
27
30 const WindowSizeRequest& preferred_size,
31 const BoxConstraints& constraints,
32 LPCWSTR title,
34 bool resizable)
35 : HostWindowSized(window_manager, engine, resizable) {
37 DWORD const window_style = GetWindowStyleForRegular(resizable);
40 .window_style = window_style,
41 .extended_window_style = 0,
42 .box_constraints = constraints,
43 .initial_window_rect = GetInitialRect(engine, preferred_size, constraints,
44 sized_to_content, resizable),
45 .title = title,
46 .owner_window = std::optional<HWND>(),
47 .sizing_delegate = sized_to_content ? AsSizingDelegate() : nullptr,
48 .is_sized_to_content = sized_to_content,
49 });
50}
51
53 // Reset the view while this most-derived object is still fully alive, to stop
54 // the raster thread from sizing it before any subobject is torn down. See the
55 // destructor comment in host_window_sized.h for the rationale.
56 view_controller_.reset();
57}
58
59Rect HostWindowRegular::GetInitialRect(FlutterWindowsEngine* engine,
60 const WindowSizeRequest& preferred_size,
61 const BoxConstraints& constraints,
63 bool resizable) {
64 double client_width;
65 double client_height;
66 if (sized_to_content) {
67 // Use the minimum constraint as the initial window size. The window will
68 // be resized to match the rendered content after the first frame.
69 client_width = std::max(1.0, constraints.smallest().width());
70 client_height = std::max(1.0, constraints.smallest().height());
71 } else {
72 client_width = preferred_size.preferred_view_width;
73 client_height = preferred_size.preferred_view_height;
74 }
75
76 std::optional<Size> const window_size =
78 *engine->windows_proc_table(), Size(client_width, client_height),
79 constraints.smallest(), constraints.biggest(),
80 GetWindowStyleForRegular(resizable), 0, nullptr);
81 return {{CW_USEDEFAULT, CW_USEDEFAULT},
82 window_size ? *window_size : Size{CW_USEDEFAULT, CW_USEDEFAULT}};
83}
84
85} // namespace flutter
Size smallest() const
Definition geometry.h:94
Size biggest() const
Definition geometry.h:93
void InitializeFlutterView(HostWindowInitializationParams const &params)
std::unique_ptr< FlutterWindowsViewController > view_controller_
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)
HostWindowRegular(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const BoxConstraints &constraints, LPCWSTR title, bool sized_to_content, bool resizable)
FlutterWindowsViewSizingDelegate * AsSizingDelegate()
double height() const
Definition geometry.h:45
double width() const
Definition geometry.h:44
FlutterEngine engine
Definition main.cc:84
G_BEGIN_DECLS gboolean sized_to_content
#define FML_CHECK(condition)
Definition logging.h:104
TSize< Scalar > Size
Definition size.h:159
unsigned long DWORD