| 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
5 #include "flutter/shell/platform/windows/host_window_regular.h"
6
7 #include "flutter/shell/platform/windows/flutter_windows_engine.h"
8
9 namespace flutter {
10 HostWindowRegular::HostWindowRegular(WindowManager* window_manager,
11 FlutterWindowsEngine* engine,
12 const WindowSizeRequest& preferred_size,
13 const BoxConstraints& constraints,
14 LPCWSTR title)
15
16 : HostWindow(window_manager, engine) {
17 // TODO(knopp): Investigate sizing the window to its content with the help of
18 // https://github.com/flutter/flutter/pull/173610.
19 FML_CHECK(preferred_size.has_preferred_view_size);
20 InitializeFlutterView(HostWindowInitializationParams{
21 .archetype = WindowArchetype::kRegular,
22 .window_style = WS_OVERLAPPEDWINDOW,
23 .extended_window_style = 0,
24 .box_constraints = constraints,
25 .initial_window_rect =
26 GetInitialRect(engine, preferred_size, constraints),
27 .title = title,
28 .owner_window = std::optional<HWND>(),
29 });
30 }
31
32 Rect HostWindowRegular::GetInitialRect(FlutterWindowsEngine* engine,
33 const WindowSizeRequest& preferred_size,
34 const BoxConstraints& constraints) {
35 std::optional<Size> const window_size =
36 HostWindow::GetWindowSizeForClientSize(
37 *engine->windows_proc_table(),
38 Size(preferred_size.preferred_view_width,
39 preferred_size.preferred_view_height),
40 constraints.smallest(), constraints.biggest(), WS_OVERLAPPEDWINDOW, 0,
41 nullptr);
42 return {{CW_USEDEFAULT, CW_USEDEFAULT},
43 window_size ? *window_size : Size{CW_USEDEFAULT, CW_USEDEFAULT}};
44 }
45
46 } // namespace flutter
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:92
flutter::FlutterWindowsEngine::windows_proc_table
std::shared_ptr< WindowsProcTable > windows_proc_table()
Definition: flutter_windows_engine.h:319
flutter::HostWindow
Definition: host_window.h:29
flutter::HostWindow::InitializeFlutterView
void InitializeFlutterView(HostWindowInitializationParams const &params)
Definition: host_window.cc:245
flutter::HostWindow::GetWindowSizeForClientSize
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:737
flutter::HostWindowRegular::HostWindowRegular
HostWindowRegular(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const BoxConstraints &constraints, LPCWSTR title)
Definition: host_window_regular.cc:10
flutter::WindowManager
Definition: window_manager.h:109
flutter_windows_engine.h
host_window_regular.h
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowArchetype::kRegular
@ kRegular
flutter::HostWindow::HostWindowInitializationParams
Definition: host_window.h:119
flutter::HostWindow::HostWindowInitializationParams::archetype
WindowArchetype archetype
Definition: host_window.h:120
flutter::WindowSizeRequest
Definition: window_manager.h:26
flutter::WindowSizeRequest::preferred_view_height
double preferred_view_height
Definition: window_manager.h:29
flutter::WindowSizeRequest::preferred_view_width
double preferred_view_width
Definition: window_manager.h:28
flutter::WindowSizeRequest::has_preferred_view_size
bool has_preferred_view_size
Definition: window_manager.h:27