Skip to content

Commit 57927ab

Browse files
author
Chun-Heng Tai
committed
added windows system fonts listener
1 parent 3d18411 commit 57927ab

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

example/windows/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t *command_line,
7777

7878
// Create a top-level win32 window to host the Flutter view.
7979
Win32Window window;
80-
if (!window.CreateAndShow(kFlutterWindowTitle, origin, size)) {
80+
if (!window.CreateAndShow(kFlutterWindowTitle, origin, size, &flutter_controller)) {
8181
return EXIT_FAILURE;
8282
}
8383

example/windows/win32_window.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Win32Window::Win32Window() {}
2828
Win32Window::~Win32Window() { Destroy(); }
2929

3030
bool Win32Window::CreateAndShow(const std::wstring &title, const Point &origin,
31-
const Size &size) {
31+
const Size &size, flutter::FlutterViewController *controller) {
3232
Destroy();
3333

3434
WNDCLASS window_class = RegisterWindowClass();
@@ -40,6 +40,8 @@ bool Win32Window::CreateAndShow(const std::wstring &title, const Point &origin,
4040

4141
double scale_factor = static_cast<double>(dpi_x) / kBaseDpi;
4242

43+
controller_ = controller;
44+
4345
HWND window = CreateWindow(
4446
window_class.lpszClassName, title.c_str(),
4547
WS_OVERLAPPEDWINDOW | WS_VISIBLE, Scale(origin.x, scale_factor),
@@ -114,6 +116,9 @@ Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam,
114116
SetFocus(child_content_);
115117
}
116118
return 0;
119+
case WM_FONTCHANGE:
120+
controller_->OnFontChange();
121+
return 0;
117122
}
118123

119124
return DefWindowProc(window_handle_, message, wparam, lparam);

example/windows/win32_window.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <memory>
1313
#include <string>
1414

15+
#include <flutter/flutter_view_controller.h>
16+
1517
// A class abstraction for a high DPI-aware Win32 Window. Intended to be
1618
// inherited from by classes that wish to specialize with custom
1719
// rendering and input handling
@@ -40,7 +42,7 @@ class Win32Window {
4042
// as logical pixels and scale to appropriate for the default monitor. Returns
4143
// true if the window was created successfully.
4244
bool CreateAndShow(const std::wstring &title, const Point &origin,
43-
const Size &size);
45+
const Size &size, flutter::FlutterViewController *controller);
4446

4547
// Release OS resources asociated with window.
4648
void Destroy();
@@ -81,6 +83,8 @@ class Win32Window {
8183
// should message loop keep running
8284
bool messageloop_running_ = true;
8385

86+
flutter::FlutterViewController *controller_;
87+
8488
// Retrieves a class instance pointer for |window|
8589
static Win32Window *GetThisFromHandle(HWND const window) noexcept;
8690

0 commit comments

Comments
 (0)