Flutter Engine
 
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 // Get the preferred languages for the thread, and optionally the process,
39 // and system, in that order, depending on the flags.
40 //
41 // See:
42 // https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getthreadpreferreduilanguages
44 PULONG count,
45 PZZWSTR languages,
46 PULONG length) const;
47
48 // Get whether high contrast is enabled.
49 //
50 // Available on Windows 8 and newer, otherwise returns false.
51 //
52 // See:
53 // https://learn.microsoft.com/windows/win32/winauto/high-contrast-parameter
54 virtual bool GetHighContrastEnabled() const;
55
56 // Get whether the system compositor, DWM, is enabled.
57 //
58 // See:
59 // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled
60 virtual bool DwmIsCompositionEnabled() const;
61
62 // Issues a flush call that blocks the caller until all of the outstanding
63 // surface updates have been made.
64 //
65 // See:
66 // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmflush
67 virtual HRESULT DwmFlush() const;
68
69 // Loads the specified cursor resource from the executable (.exe) file
70 // associated with an application instance.
71 //
72 // See:
73 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw
74 virtual HCURSOR LoadCursor(HINSTANCE instance, LPCWSTR cursor_name) const;
75
76 // Sets the cursor shape.
77 //
78 // See:
79 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursor
80 virtual HCURSOR SetCursor(HCURSOR cursor) const;
81
82 // Enables automatic display scaling of the non-client area portions of the
83 // specified top-level window.
84 //
85 // See:
86 // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enablenonclientdpiscaling
87 virtual BOOL EnableNonClientDpiScaling(HWND hwnd) const;
88
89 // Sets the current value of a specified Desktop Window Manager (DWM)
90 // attribute applied to a window.
91 //
92 // See:
93 // https://learn.microsoft.com/en-us/windows/win32/dwm/setwindowcompositionattribute
95 HWND hwnd,
97
98 // Extends the window frame into the client area.
99 //
100 // See:
101 // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea
102 virtual HRESULT DwmExtendFrameIntoClientArea(HWND hwnd,
103 const MARGINS* pMarInset) const;
104
105 // Sets the value of Desktop Window Manager (DWM) non-client rendering
106 // attributes for a window.
107 //
108 // See:
109 // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute
110 virtual HRESULT DwmSetWindowAttribute(HWND hwnd,
111 DWORD dwAttribute,
112 LPCVOID pvAttribute,
113 DWORD cbAttribute) const;
114
115 // Calculates the required size of the window rectangle, based on the desired
116 // size of the client rectangle and the provided DPI.
117 //
118 // See:
119 // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi
120 virtual BOOL AdjustWindowRectExForDpi(LPRECT lpRect,
121 DWORD dwStyle,
122 BOOL bMenu,
123 DWORD dwExStyle,
124 UINT dpi) const;
125
126 // Get the system metrics.
127 //
128 // See:
129 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getsystemmetrics
130 virtual int GetSystemMetrics(int nIndex) const;
131
132 // Enumerate display devices.
133 //
134 // See:
135 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesw
136 virtual BOOL EnumDisplayDevices(LPCWSTR lpDevice,
137 DWORD iDevNum,
138 PDISPLAY_DEVICE lpDisplayDevice,
139 DWORD dwFlags) const;
140
141 // Enumerate display settings.
142 //
143 // See:
144 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaysettingsw
145 virtual BOOL EnumDisplaySettings(LPCWSTR lpszDeviceName,
146 DWORD iModeNum,
147 DEVMODEW* lpDevMode) const;
148
149 // Get monitor info.
150 //
151 // See:
152 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-getmonitorinfow
153 virtual BOOL GetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi) const;
154
155 // Enumerate display monitors.
156 //
157 // See:
158 // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-enumdisplaymonitors
159 virtual BOOL EnumDisplayMonitors(HDC hdc,
160 LPCRECT lprcClip,
161 MONITORENUMPROC lpfnEnum,
162 LPARAM dwData) const;
163
164 private:
165 using GetPointerType_ = BOOL __stdcall(UINT32 pointerId,
166 POINTER_INPUT_TYPE* pointerType);
167 using EnableNonClientDpiScaling_ = BOOL __stdcall(HWND hwnd);
168 using SetWindowCompositionAttribute_ =
169 BOOL __stdcall(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
170 using AdjustWindowRectExForDpi_ = BOOL __stdcall(LPRECT lpRect,
171 DWORD dwStyle,
172 BOOL bMenu,
173 DWORD dwExStyle,
174 UINT dpi);
175
176 // The User32.dll library, used to resolve functions at runtime.
178
179 std::optional<GetPointerType_*> get_pointer_type_;
180 std::optional<EnableNonClientDpiScaling_*> enable_non_client_dpi_scaling_;
181 std::optional<SetWindowCompositionAttribute_*>
182 set_window_composition_attribute_;
183 std::optional<AdjustWindowRectExForDpi_*> adjust_window_rect_ext_for_dpi_;
184
186};
187
188} // namespace flutter
189
190#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOWS_PROC_TABLE_H_
virtual HRESULT DwmFlush() 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