Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
windows_proc_table.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
7#include <WinUser.h>
8#include <dwmapi.h>
9
10namespace flutter {
11
13 user32_ = fml::NativeLibrary::Create("user32.dll");
14 get_pointer_type_ =
15 user32_->ResolveFunction<GetPointerType_*>("GetPointerType");
16 get_pointer_info_ =
17 user32_->ResolveFunction<GetPointerInfo_*>("GetPointerInfo");
18 get_pointer_pen_info_ =
19 user32_->ResolveFunction<GetPointerPenInfo_*>("GetPointerPenInfo");
20 enable_non_client_dpi_scaling_ =
21 user32_->ResolveFunction<EnableNonClientDpiScaling_*>(
22 "EnableNonClientDpiScaling");
23 set_window_composition_attribute_ =
24 user32_->ResolveFunction<SetWindowCompositionAttribute_*>(
25 "SetWindowCompositionAttribute");
26 adjust_window_rect_ext_for_dpi_ =
27 user32_->ResolveFunction<AdjustWindowRectExForDpi_*>(
28 "AdjustWindowRectExForDpi");
29}
30
32 user32_ = nullptr;
33}
34
36 POINTER_INPUT_TYPE* pointer_type) const {
37 if (!get_pointer_type_.has_value()) {
38 return FALSE;
39 }
40
41 return get_pointer_type_.value()(pointer_id, pointer_type);
42}
43
45 POINTER_INFO* pointer_info) const {
46 if (!get_pointer_info_.has_value()) {
47 return FALSE;
48 }
49
50 return get_pointer_info_.value()(pointer_id, pointer_info);
51}
52
54 UINT32 pointer_id,
55 POINTER_PEN_INFO* pointer_pen_info) const {
56 if (!get_pointer_pen_info_.has_value()) {
57 return FALSE;
58 }
59
60 return get_pointer_pen_info_.value()(pointer_id, pointer_pen_info);
61}
62
64 PULONG count,
65 PZZWSTR languages,
66 PULONG length) const {
67 return ::GetThreadPreferredUILanguages(flags, count, languages, length);
68}
69
71 HIGHCONTRAST high_contrast = {.cbSize = sizeof(HIGHCONTRAST)};
72 if (!::SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST),
73 &high_contrast, 0)) {
74 return false;
75 }
76
77 return high_contrast.dwFlags & HCF_HIGHCONTRASTON;
78}
79
81 BOOL composition_enabled;
82 if (SUCCEEDED(::DwmIsCompositionEnabled(&composition_enabled))) {
83 return composition_enabled;
84 }
85
86 return true;
87}
88
90 return ::DwmFlush();
91}
92
94 LPCWSTR cursor_name) const {
95 return ::LoadCursorW(instance, cursor_name);
96}
97
98HCURSOR WindowsProcTable::SetCursor(HCURSOR cursor) const {
99 return ::SetCursor(cursor);
100}
101
103 if (!enable_non_client_dpi_scaling_.has_value()) {
104 return FALSE;
105 }
106
107 return enable_non_client_dpi_scaling_.value()(hwnd);
108}
109
111 HWND hwnd,
113 if (!set_window_composition_attribute_.has_value()) {
114 return FALSE;
115 }
116
117 return set_window_composition_attribute_.value()(hwnd, data);
118}
119
121 HWND hwnd,
122 const MARGINS* pMarInset) const {
123 return ::DwmExtendFrameIntoClientArea(hwnd, pMarInset);
124}
125
127 DWORD dwAttribute,
128 LPCVOID pvAttribute,
129 DWORD cbAttribute) const {
130 return ::DwmSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute);
131}
132
134 DWORD dwStyle,
135 BOOL bMenu,
136 DWORD dwExStyle,
137 UINT dpi) const {
138 if (!adjust_window_rect_ext_for_dpi_.has_value()) {
139 return FALSE;
140 }
141
142 return adjust_window_rect_ext_for_dpi_.value()(lpRect, dwStyle, bMenu,
143 dwExStyle, dpi);
144}
145
147 return ::GetSystemMetrics(nIndex);
148}
149
151 DWORD iDevNum,
152 PDISPLAY_DEVICE lpDisplayDevice,
153 DWORD dwFlags) const {
154 return ::EnumDisplayDevices(lpDevice, iDevNum, lpDisplayDevice, dwFlags);
155}
156
158 DWORD iModeNum,
159 DEVMODEW* lpDevMode) const {
160 return ::EnumDisplaySettingsW(lpszDeviceName, iModeNum, lpDevMode);
161}
162
164 LPMONITORINFO lpmi) const {
165 return ::GetMonitorInfoW(hMonitor, lpmi);
166}
167
169 LPCRECT lprcClip,
170 MONITORENUMPROC lpfnEnum,
171 LPARAM dwData) const {
172 return ::EnumDisplayMonitors(hdc, lprcClip, lpfnEnum, dwData);
173}
174
175} // namespace flutter
virtual HRESULT DwmFlush() const
virtual BOOL GetPointerInfo(UINT32 pointer_id, POINTER_INFO *pointer_info) const
virtual BOOL GetPointerPenInfo(UINT32 pointer_id, POINTER_PEN_INFO *pointer_pen_info) const
virtual BOOL GetPointerType(UINT32 pointer_id, POINTER_INPUT_TYPE *pointer_type) const
virtual HCURSOR LoadCursor(HINSTANCE instance, LPCWSTR cursor_name) const
virtual int GetSystemMetrics(int nIndex) const
virtual HCURSOR SetCursor(HCURSOR cursor) const
virtual bool GetHighContrastEnabled() const
virtual BOOL EnumDisplayDevices(LPCWSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICE lpDisplayDevice, DWORD dwFlags) const
virtual BOOL AdjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi) const
virtual BOOL EnableNonClientDpiScaling(HWND hwnd) const
virtual HRESULT DwmExtendFrameIntoClientArea(HWND hwnd, const MARGINS *pMarInset) const
virtual bool DwmIsCompositionEnabled() const
virtual BOOL EnumDisplaySettings(LPCWSTR lpszDeviceName, DWORD iModeNum, DEVMODEW *lpDevMode) const
virtual HRESULT DwmSetWindowAttribute(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) const
virtual BOOL GetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi) const
virtual BOOL EnumDisplayMonitors(HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData) const
virtual LRESULT GetThreadPreferredUILanguages(DWORD flags, PULONG count, PZZWSTR languages, PULONG length) const
virtual BOOL SetWindowCompositionAttribute(HWND hwnd, WINDOWCOMPOSITIONATTRIBDATA *data) const
const std::optional< T > ResolveFunction(const char *symbol)
static fml::RefPtr< NativeLibrary > Create(const char *path)
VkInstance instance
Definition main.cc:64
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
int BOOL
#define SUCCEEDED(hr)
LONG_PTR LRESULT
unsigned int UINT
LONG_PTR LPARAM
unsigned long DWORD