Flutter Windows Embedder
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 <optional>
9 
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/native_library.h"
12 
13 namespace flutter {
14 
15 // Lookup table for Windows APIs that aren't available on all versions of
16 // Windows, or for mocking Windows API calls.
18  public:
20  virtual ~WindowsProcTable();
21 
22  // Retrieves the pointer type for a specified pointer.
23  //
24  // Used to react differently to touch or pen inputs. Returns false on failure.
25  // Available on Windows 8 and newer, otherwise returns false.
26  virtual BOOL GetPointerType(UINT32 pointer_id,
27  POINTER_INPUT_TYPE* pointer_type) const;
28 
29  // Get the preferred languages for the thread, and optionally the process,
30  // and system, in that order, depending on the flags.
31  //
32  // See:
33  // https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getthreadpreferreduilanguages
34  virtual LRESULT GetThreadPreferredUILanguages(DWORD flags,
35  PULONG count,
36  PZZWSTR languages,
37  PULONG length) const;
38 
39  // Get whether high contrast is enabled.
40  //
41  // Available on Windows 8 and newer, otherwise returns false.
42  //
43  // See:
44  // https://learn.microsoft.com/windows/win32/winauto/high-contrast-parameter
45  virtual bool GetHighContrastEnabled() const;
46 
47  // Get whether the system compositor, DWM, is enabled.
48  //
49  // See:
50  // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled
51  virtual bool DwmIsCompositionEnabled() const;
52 
53  // Issues a flush call that blocks the caller until all of the outstanding
54  // surface updates have been made.
55  //
56  // See:
57  // https://learn.microsoft.com/windows/win32/api/dwmapi/nf-dwmapi-dwmflush
58  virtual HRESULT DwmFlush() const;
59 
60  // Loads the specified cursor resource from the executable (.exe) file
61  // associated with an application instance.
62  //
63  // See:
64  // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-loadcursorw
65  virtual HCURSOR LoadCursor(HINSTANCE instance, LPCWSTR cursor_name) const;
66 
67  // Sets the cursor shape.
68  //
69  // See:
70  // https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setcursor
71  virtual HCURSOR SetCursor(HCURSOR cursor) const;
72 
73  private:
74  using GetPointerType_ = BOOL __stdcall(UINT32 pointerId,
75  POINTER_INPUT_TYPE* pointerType);
76 
77  // The User32.dll library, used to resolve functions at runtime.
78  fml::RefPtr<fml::NativeLibrary> user32_;
79 
80  std::optional<GetPointerType_*> get_pointer_type_;
81 
82  FML_DISALLOW_COPY_AND_ASSIGN(WindowsProcTable);
83 };
84 
85 } // namespace flutter
86 
87 #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 HCURSOR SetCursor(HCURSOR cursor) const
virtual bool GetHighContrastEnabled() const
virtual bool DwmIsCompositionEnabled() const
virtual LRESULT GetThreadPreferredUILanguages(DWORD flags, PULONG count, PZZWSTR languages, PULONG length) const