Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
windows_proc_table.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_WINDOWS_PROC_TABLE_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOWS_PROC_TABLE_H_
7
8#include <dwmapi.h>
9#include <optional>
10
11#include "flutter/fml/macros.h"
13
14namespace flutter {
15
16// Lookup table for Windows APIs that aren't available on all versions of
17// Windows, or for mocking Windows API calls.
19 public:
21
27
29 virtual ~WindowsProcTable();
30
31 // Retrieves the pointer type for a specified pointer.
32 //
33 // Used to react differently to touch or pen inputs. Returns false on failure.
34 // Available on Windows 8 and newer, otherwise returns false.
35 virtual BOOL GetPointerType(UINT32 pointer_id,
36 POINTER_INPUT_TYPE* pointer_type) const;
37
38 // Retrieves the pointer info for a specified pointer.
39 //
40 // Used to react differently to touch or pen inputs. Returns false on failure.
41 // Available on Windows 8 and newer, otherwise returns false.
42 virtual BOOL GetPointerInfo(UINT32 pointer_id,
43 POINTER_INFO* pointer_info) const;
44 // Retrieves the pointer info for a specified pointer.
45 //
46 // Used to retrieve information about the pen being used. Returns false on
47 // failure. Available on Windows 8 and newer, otherwise returns false.
48 virtual BOOL GetPointerPenInfo(UINT32 pointer_id,
49 POINTER_PEN_INFO* pointer_pen_info) const;
50 // Get the preferred languages for the thread, and optionally the process,
51 // and system, in that order, depending on the flags.
52 //
53 // See:
54 // https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getthreadpreferreduilanguages
56 PULONG count,
57 PZZWSTR languages,
58 PULONG length) const;
59
60 // Get whether high contrast is enabled.
61 //
62 // Available on Windows 8 and newer, otherwise returns false.
63 //
64 // See:
65 // https://learn.microsoft.com/windows/win32/winauto/high-contrast-parameter
66 virtual bool GetHighContrastEnabled() const;
67
68 // Get whether the system compositor, DWM, is enabled.
69 //
70 // See:
71 // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled
72 virtual bool DwmIsCompositionEnabled() const;
73
74 // Issues a flush call that blocks the caller until all of the outstanding
75 // surface updates have been made.
76 //
77 // See:
78 // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmflush
79 virtual HRESULT DwmFlush() const;
80
81 // Loads the specified cursor resource from the executable (.exe) file
82 // associated with an application instance.
83 //
84 // See:
85 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw
86 virtual HCURSOR LoadCursor(HINSTANCE instance, LPCWSTR cursor_name) const;
87
88 // Sets the cursor shape.
89 //
90 // See:
91 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursor
92 virtual HCURSOR SetCursor(HCURSOR cursor) const;
93
94 // Enables automatic display scaling of the non-client area portions of the
95 // specified top-level window.
96 //
97 // See:
98 // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enablenonclientdpiscaling
99 virtual BOOL EnableNonClientDpiScaling(HWND hwnd) const;
100
101 // Sets the current value of a specified Desktop Window Manager (DWM)
102 // attribute applied to a window.
103 //
104 // See:
105 // https://learn.microsoft.com/en-us/windows/win32/dwm/setwindowcompositionattribute
107 HWND hwnd,
109
110 // Extends the window frame into the client area.
111 //
112 // See:
113 // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea
114 virtual HRESULT DwmExtendFrameIntoClientArea(HWND hwnd,
115 const MARGINS* pMarInset) const;
116
117 // Sets the value of Desktop Window Manager (DWM) non-client rendering
118 // attributes for a window.
119 //
120 // See:
121 // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute
122 virtual HRESULT DwmSetWindowAttribute(HWND hwnd,
123 DWORD dwAttribute,
124 LPCVOID pvAttribute,
125 DWORD cbAttribute) const;
126
127 // Calculates the required size of the window rectangle, based on the desired
128 // size of the client rectangle and the provided DPI.
129 //
130 // See:
131 // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi
132 virtual BOOL AdjustWindowRectExForDpi(LPRECT lpRect,
133 DWORD dwStyle,
134 BOOL bMenu,
135 DWORD dwExStyle,
136 UINT dpi) const;
137
138 // Get the system metrics.
139 //
140 // See:
141 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getsystemmetrics
142 virtual int GetSystemMetrics(int nIndex) const;
143
144 // Enumerate display devices.
145 //
146 // See:
147 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesw
148 virtual BOOL EnumDisplayDevices(LPCWSTR lpDevice,
149 DWORD iDevNum,
150 PDISPLAY_DEVICE lpDisplayDevice,
151 DWORD dwFlags) const;
152
153 // Enumerate display settings.
154 //
155 // See:
156 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsw
157 virtual BOOL EnumDisplaySettings(LPCWSTR lpszDeviceName,
158 DWORD iModeNum,
159 DEVMODEW* lpDevMode) const;
160
161 // Get monitor info.
162 //
163 // See:
164 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmonitorinfow
165 virtual BOOL GetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi) const;
166
167 // Enumerate display monitors.
168 //
169 // See:
170 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaymonitors
171 virtual BOOL EnumDisplayMonitors(HDC hdc,
172 LPCRECT lprcClip,
173 MONITORENUMPROC lpfnEnum,
174 LPARAM dwData) const;
175
176 private:
177 using GetPointerType_ = BOOL __stdcall(UINT32 pointerId,
178 POINTER_INPUT_TYPE* pointerType);
179 using GetPointerInfo_ = BOOL __stdcall(UINT32 pointerId,
180 POINTER_INFO* pointerInfo);
181 using GetPointerPenInfo_ = BOOL __stdcall(UINT32 pointerId,
182 POINTER_PEN_INFO* penInfo);
183 using EnableNonClientDpiScaling_ = BOOL __stdcall(HWND hwnd);
184 using SetWindowCompositionAttribute_ =
185 BOOL __stdcall(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
186 using AdjustWindowRectExForDpi_ = BOOL __stdcall(LPRECT lpRect,
187 DWORD dwStyle,
188 BOOL bMenu,
189 DWORD dwExStyle,
190 UINT dpi);
191
192 // The User32.dll library, used to resolve functions at runtime.
194
195 std::optional<GetPointerType_*> get_pointer_type_;
196 std::optional<GetPointerInfo_*> get_pointer_info_;
197 std::optional<GetPointerPenInfo_*> get_pointer_pen_info_;
198 std::optional<EnableNonClientDpiScaling_*> enable_non_client_dpi_scaling_;
199 std::optional<SetWindowCompositionAttribute_*>
200 set_window_composition_attribute_;
201 std::optional<AdjustWindowRectExForDpi_*> adjust_window_rect_ext_for_dpi_;
202
204};
205
206} // namespace flutter
207
208#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOWS_PROC_TABLE_H_
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
VkInstance instance
Definition main.cc:64
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
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
void * PVOID
LONG_PTR LRESULT
unsigned int UINT
LONG_PTR LPARAM
unsigned long DWORD
ULONG_PTR SIZE_T