File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
#include " ../screengrab.h"
2
2
#include " ../endian.h"
3
+ #include < VersionHelpers.h>
3
4
4
5
MMRect getScaledRect (MMRect input)
5
6
{
6
- // Configure DPI awareness to fetch unscaled display size
7
- DPI_AWARENESS_CONTEXT initialDpiAwareness = SetThreadDpiAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
8
7
size_t scaledDesktopWidth = (size_t )GetSystemMetrics (SM_CXSCREEN);
9
8
size_t scaledDesktopHeight = (size_t )GetSystemMetrics (SM_CYSCREEN);
10
- // Reset DPI awareness to avoid inconsistencies on future calls to copyMMBitmapFromDisplayInRect
11
- SetThreadDpiAwarenessContext (initialDpiAwareness);
9
+ // Configure DPI awareness to fetch unscaled display size
10
+ if (IsWindows10OrGreater () && !IsWindowsServer ()) {
11
+ // Re-query desktop dimensions after setting the DPI awareness context
12
+ // Only to this on Windows 10 client platforms, since earlier versions of Windows and Windows Server do not support this call
13
+ DPI_AWARENESS_CONTEXT initialDpiAwareness = SetThreadDpiAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
14
+ scaledDesktopWidth = (size_t )GetSystemMetrics (SM_CXSCREEN);
15
+ scaledDesktopHeight = (size_t )GetSystemMetrics (SM_CYSCREEN);
16
+ // Reset DPI awareness to avoid inconsistencies on future calls to copyMMBitmapFromDisplayInRect
17
+ SetThreadDpiAwarenessContext (initialDpiAwareness);
18
+ }
12
19
size_t desktopWidth = (size_t )GetSystemMetrics (SM_CXSCREEN);
13
20
size_t desktopHeight = (size_t )GetSystemMetrics (SM_CYSCREEN);
14
21
You can’t perform that action at this time.
0 commit comments