• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DPI_HELPER_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_DPI_HELPER_H_
7 
8 #include <ShellScalingApi.h>
9 #include <VersionHelpers.h>
10 
11 namespace flutter {
12 
13 // A helper class for abstracting various Windows DPI related functions across
14 // Windows OS versions.
15 class Win32DpiHelper {
16  public:
17   Win32DpiHelper();
18 
19   ~Win32DpiHelper();
20 
21   // Check if Windows Per Monitor V2 DPI scaling functionality is available on
22   // current system.
23   bool IsPerMonitorV2Available();
24 
25   // Wrapper for OS functionality to turn on automatic window non-client scaling
26   BOOL EnableNonClientDpiScaling(HWND);
27 
28   // Wrapper for OS functionality to return the DPI for |HWND|
29   UINT GetDpiForWindow(HWND);
30 
31   // Sets the current process to a specified DPI awareness context.
32   BOOL SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT);
33 
34  private:
35   using EnableNonClientDpiScaling_ = BOOL __stdcall(HWND);
36   using GetDpiForWindow_ = UINT __stdcall(HWND);
37   using SetProcessDpiAwarenessContext_ = BOOL __stdcall(DPI_AWARENESS_CONTEXT);
38 
39   EnableNonClientDpiScaling_* enable_non_client_dpi_scaling_ = nullptr;
40   GetDpiForWindow_* get_dpi_for_window_ = nullptr;
41   SetProcessDpiAwarenessContext_* set_process_dpi_awareness_context_ = nullptr;
42 
43   HMODULE user32_module_ = nullptr;
44   bool permonitorv2_supported_ = false;
45 };
46 
47 }  // namespace flutter
48 
49 #endif  // FLUTTER_SHELL_PLATFORM_WINDOWS_DPI_HELPER_H_
50