Flutter Windows Embedder
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 
10 namespace flutter {
11 
12 namespace {
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.
18 DWORD 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 
29  FlutterWindowsEngine* engine,
30  const WindowSizeRequest& preferred_size,
31  const BoxConstraints& constraints,
32  LPCWSTR title,
33  bool sized_to_content,
34  bool resizable)
35  : HostWindowSized(window_manager, engine, resizable) {
36  FML_CHECK(sized_to_content || preferred_size.has_preferred_view_size);
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 
59 Rect HostWindowRegular::GetInitialRect(FlutterWindowsEngine* engine,
60  const WindowSizeRequest& preferred_size,
61  const BoxConstraints& constraints,
62  bool sized_to_content,
63  bool resizable) {
64  std::optional<Size> const window_size = GetInitialWindowSize(
65  engine, preferred_size, constraints, GetWindowStyleForRegular(resizable),
66  /*extended_window_style=*/0, /*owner_window=*/std::nullopt,
67  sized_to_content);
68  return {{CW_USEDEFAULT, CW_USEDEFAULT},
69  window_size ? *window_size : Size{CW_USEDEFAULT, CW_USEDEFAULT}};
70 }
71 
72 } // namespace flutter
void InitializeFlutterView(HostWindowInitializationParams const &params)
Definition: host_window.cc:249
std::unique_ptr< FlutterWindowsViewController > view_controller_
Definition: host_window.h:314
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)
Definition: host_window.cc:852
HostWindowRegular(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const BoxConstraints &constraints, LPCWSTR title, bool sized_to_content, bool resizable)
FlutterWindowsViewSizingDelegate * AsSizingDelegate()