OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 #include <cfgmgr32.h> | 8 #include <cfgmgr32.h> |
9 #include <powrprof.h> | 9 #include <powrprof.h> |
10 #include <shobjidl.h> // Must be before propkey. | 10 #include <shobjidl.h> // Must be before propkey. |
11 #include <initguid.h> | 11 #include <initguid.h> |
12 #include <inspectable.h> | 12 #include <inspectable.h> |
13 #include <propkey.h> | 13 #include <propkey.h> |
14 #include <propvarutil.h> | 14 #include <propvarutil.h> |
15 #include <psapi.h> | 15 #include <psapi.h> |
16 #include <roapi.h> | 16 #include <roapi.h> |
17 #include <sddl.h> | 17 #include <sddl.h> |
18 #include <setupapi.h> | 18 #include <setupapi.h> |
19 #include <shellscalingapi.h> | |
19 #include <shlwapi.h> | 20 #include <shlwapi.h> |
20 #include <signal.h> | 21 #include <signal.h> |
21 #include <stddef.h> | 22 #include <stddef.h> |
22 #include <stdlib.h> | 23 #include <stdlib.h> |
23 #include <tchar.h> // Must be before tpcshrd.h or for any use of _T macro | 24 #include <tchar.h> // Must be before tpcshrd.h or for any use of _T macro |
24 #include <tpcshrd.h> | 25 #include <tpcshrd.h> |
25 #include <uiviewsettingsinterop.h> | 26 #include <uiviewsettingsinterop.h> |
26 #include <windows.ui.viewmanagement.h> | 27 #include <windows.ui.viewmanagement.h> |
27 #include <winstring.h> | 28 #include <winstring.h> |
28 #include <wrl/wrappers/corewrappers.h> | 29 #include <wrl/wrappers/corewrappers.h> |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 void EnableFlicks(HWND hwnd) { | 591 void EnableFlicks(HWND hwnd) { |
591 ::RemoveProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY); | 592 ::RemoveProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY); |
592 } | 593 } |
593 | 594 |
594 void DisableFlicks(HWND hwnd) { | 595 void DisableFlicks(HWND hwnd) { |
595 ::SetProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY, | 596 ::SetProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY, |
596 reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS | | 597 reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS | |
597 TABLET_DISABLE_FLICKFALLBACKKEYS)); | 598 TABLET_DISABLE_FLICKFALLBACKKEYS)); |
598 } | 599 } |
599 | 600 |
601 bool IsProcessPerMonitorDpiAware() { | |
602 static enum class PerMonitorDpiAware { | |
603 UNKNOWN = 0, | |
604 PER_MONITOR_DPI_UNAWARE, | |
605 PER_MONITOR_DPI_AWARE, | |
606 } per_monitor_dpi_aware = PerMonitorDpiAware::UNKNOWN; | |
607 if (per_monitor_dpi_aware == PerMonitorDpiAware::UNKNOWN) { | |
608 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_UNAWARE; | |
609 HMODULE shcore_dll = ::LoadLibrary(L"shcore.dll"); | |
610 if (shcore_dll) { | |
611 using GetProcessDpiAwarenessPtr = | |
612 HRESULT (WINAPI *) (HANDLE, PROCESS_DPI_AWARENESS*); | |
613 GetProcessDpiAwarenessPtr process_dpi_awareness_func = | |
614 reinterpret_cast<GetProcessDpiAwarenessPtr>( | |
615 ::GetProcAddress(shcore_dll, "GetProcessDpiAwareness")); | |
scottmg
2016/06/27 17:55:04
How about
auto get_process_dpi_awareness = reinte
robliao
2016/06/27 18:39:29
This is much nicer. Done!
| |
616 if (process_dpi_awareness_func) { | |
617 PROCESS_DPI_AWARENESS awareness; | |
618 if (SUCCEEDED(process_dpi_awareness_func(nullptr, &awareness)) && | |
619 awareness == PROCESS_PER_MONITOR_DPI_AWARE) | |
620 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | |
621 } | |
622 } | |
623 } | |
624 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | |
625 } | |
626 | |
600 } // namespace win | 627 } // namespace win |
601 } // namespace base | 628 } // namespace base |
OLD | NEW |