Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
Loading...
Searching...
No Matches
host_window_sized.h
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
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_HOST_WINDOW_SIZED_H_
6
#define FLUTTER_SHELL_PLATFORM_WINDOWS_HOST_WINDOW_SIZED_H_
7
8
#include <memory>
9
10
#include "
host_window.h
"
11
#include "
shell/platform/windows/flutter_windows_view.h
"
12
13
namespace
flutter
{
14
15
// Base class for the sized-to-content archetypes: HostWindowRegular,
16
// HostWindowDialog, HostWindowPopup, and HostWindowTooltip.
17
//
18
// Provides the shared sized-to-content implementation used by these
19
// archetypes: tracking the last rendered content size and reacting to it after
20
// each frame. The default reaction resizes the window in place and optionally
21
// disables content-size tracking once the user resizes the window.
22
// HostWindowPopup and HostWindowTooltip override ApplyContentSize() to instead
23
// reposition themselves relative to a parent window whenever their content
24
// size changes.
25
class
HostWindowSized
:
public
HostWindow
,
26
private
FlutterWindowsViewSizingDelegate
{
27
protected
:
28
HostWindowSized
(
WindowManager
* window_manager,
29
FlutterWindowsEngine
*
engine
,
30
bool
resizable);
31
32
// Pure virtual to make HostWindowSized abstract: only the concrete
33
// archetypes (HostWindowRegular, HostWindowDialog, HostWindowPopup,
34
// HostWindowTooltip) may be instantiated.
35
//
36
// Each derived class must reset |view_controller_| at the very start of its
37
// own destructor, while the most-derived object is still fully alive.
38
//
39
// When sized to content, this object is the view's
40
// FlutterWindowsViewSizingDelegate, and the view (owned by
41
// |view_controller_|, a member of the HostWindow base class) drives sizing
42
// from the raster thread via DidUpdateViewSize -> ApplyContentSize /
43
// GetWorkArea. Several of these entry points are overridden by derived
44
// classes. If the view were destroyed by the HostWindow base destructor
45
// instead, it would run *after* the derived destructor: by then the derived
46
// subobject (and its vtable overrides) is gone, so an in-flight raster-thread
47
// sizing call could land in a destroyed object and crash. Resetting
48
// |view_controller_| in the derived destructor triggers
49
// FlutterWindowsEngine::RemoveView, which guarantees the raster thread no
50
// longer presents to (or sizes) this view before any subobject is torn down.
51
//
52
// The base destructor asserts that |view_controller_| has already been reset.
53
~HostWindowSized
()
override
= 0;
54
55
// Returns a pointer to this as a FlutterWindowsViewSizingDelegate, for use
56
// as HostWindowInitializationParams::sizing_delegate. This is necessary
57
// because FlutterWindowsViewSizingDelegate is a private base of this class
58
// and the conversion is therefore inaccessible to derived classes.
59
FlutterWindowsViewSizingDelegate
*
AsSizingDelegate
() {
return
this
; }
60
61
// Called on the platform thread after the rendered content size has changed
62
// to |physical_width| x |physical_height| (in physical pixels). The base
63
// implementation resizes the window in place to fit the content and, for
64
// resizable windows, stops tracking content size after the initial frame.
65
// Subclasses that position themselves relative to a parent override this.
66
virtual
void
ApplyContentSize
(int32_t physical_width,
67
int32_t physical_height);
68
69
// Whether the user can manually resize this window.
70
const
bool
resizable_
;
71
72
// Used to track whether the view is still alive in tasks posted from the
73
// raster thread.
74
std::shared_ptr<int>
view_alive_
;
75
76
// The last physical-pixel size reported to DidUpdateViewSize.
77
int
physical_width_
= 0;
78
int
physical_height_
= 0;
79
80
private
:
81
// FlutterWindowsViewSizingDelegate:
82
void
DidUpdateViewSize(int32_t
width
, int32_t
height
)
override
;
83
WindowRect
GetWorkArea()
const override
;
84
};
85
86
}
// namespace flutter
87
88
#endif
// FLUTTER_SHELL_PLATFORM_WINDOWS_HOST_WINDOW_SIZED_H_
flutter::FlutterWindowsEngine
Definition
flutter_windows_engine.h:92
flutter::FlutterWindowsViewSizingDelegate
Definition
flutter_windows_view.h:35
flutter::HostWindow
Definition
host_window.h:29
flutter::HostWindowSized
Definition
host_window_sized.h:26
flutter::HostWindowSized::view_alive_
std::shared_ptr< int > view_alive_
Definition
host_window_sized.h:74
flutter::HostWindowSized::resizable_
const bool resizable_
Definition
host_window_sized.h:70
flutter::HostWindowSized::ApplyContentSize
virtual void ApplyContentSize(int32_t physical_width, int32_t physical_height)
Definition
host_window_sized.cc:52
flutter::HostWindowSized::~HostWindowSized
~HostWindowSized() override=0
Definition
host_window_sized.cc:20
flutter::HostWindowSized::physical_width_
int physical_width_
Definition
host_window_sized.h:77
flutter::HostWindowSized::AsSizingDelegate
FlutterWindowsViewSizingDelegate * AsSizingDelegate()
Definition
host_window_sized.h:59
flutter::HostWindowSized::physical_height_
int physical_height_
Definition
host_window_sized.h:78
flutter::WindowManager
Definition
window_manager.h:118
engine
FlutterEngine engine
Definition
main.cc:84
flutter_windows_view.h
host_window.h
flutter
Definition
asset_manager.cc:10
height
int32_t height
Definition
serialization_callbacks.cc:1
width
int32_t width
Definition
serialization_callbacks.cc:0
flutter::WindowRect
Definition
window_manager.h:42
shell
platform
windows
host_window_sized.h
Generated on Sun Jul 5 2026 07:45:21 for Flutter Engine Uber Docs by
1.9.8