diff options
author | Yuhang Zhao <2546789017@qq.com> | 2021-07-29 14:58:34 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2021-11-24 09:16:38 +0800 |
commit | e75b1dfe380e854ed5ceaf5933740e3759a22aaf (patch) | |
tree | 85f20bfeab34768a1eca2675312aa909e44dc14a /src/plugins/platforms/windows/qwin10helpers.cpp | |
parent | f5f7f78766d62b7192b98b96bbd68dab1961e54e (diff) |
Windows QPA: Further cleanup of pre-Win10 code
Mostly a removal of dynamically loaded Win32 APIs.
Since Qt 6's minimum supported platform is Win10 1809
(10.0.17763, code name RS5), all these functions will
be available and no need to resolve them at run-time.
Things not remove:
WinTab functions in "qwindowstabletsupport.cpp".
Not my familiar area, so not touch it.
Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I7ad6c3bc8376f6c0e3ac90f34e22f7628efeb694
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwin10helpers.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwin10helpers.cpp | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index b8e834d54f..589311a902 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -40,8 +40,8 @@ #include "qwin10helpers.h" #include <QtCore/qdebug.h> -#include <QtCore/qoperatingsystemversion.h> -#include <QtCore/private/qsystemlibrary_p.h> +#include <winstring.h> +#include <roapi.h> #if defined(Q_CC_MINGW) || defined(Q_CC_CLANG) # define HAS_UI_VIEW_SETTINGS_INTEROP @@ -96,56 +96,23 @@ public: QT_BEGIN_NAMESPACE -// Starting from Windows 10 -struct QWindowsComBaseDLL -{ - bool init(); - bool isValid() const - { - return roGetActivationFactory != nullptr && windowsCreateStringReference != nullptr; - } - - typedef HRESULT (WINAPI *RoGetActivationFactory)(HSTRING, REFIID, void **); - typedef HRESULT (WINAPI *WindowsCreateStringReference)(PCWSTR, UINT32, HSTRING_HEADER *, HSTRING *); - - RoGetActivationFactory roGetActivationFactory = nullptr; - WindowsCreateStringReference windowsCreateStringReference = nullptr; -}; - -static QWindowsComBaseDLL baseComDll; - -bool QWindowsComBaseDLL::init() -{ - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10 && !isValid()) { - QSystemLibrary library(QStringLiteral("combase")); - roGetActivationFactory = - reinterpret_cast<RoGetActivationFactory>(library.resolve("RoGetActivationFactory")); - windowsCreateStringReference = - reinterpret_cast<WindowsCreateStringReference>(library.resolve("WindowsCreateStringReference")); - } - return isValid(); -} - // Return tablet mode, note: Does not work for GetDesktopWindow(). bool qt_windowsIsTabletMode(HWND hwnd) { bool result = false; - if (!baseComDll.init()) - return false; - const wchar_t uiViewSettingsId[] = L"Windows.UI.ViewManagement.UIViewSettings"; HSTRING_HEADER uiViewSettingsIdRefHeader; HSTRING uiViewSettingsIdHs = nullptr; const auto uiViewSettingsIdLen = UINT32(sizeof(uiViewSettingsId) / sizeof(uiViewSettingsId[0]) - 1); - if (FAILED(baseComDll.windowsCreateStringReference(uiViewSettingsId, uiViewSettingsIdLen, &uiViewSettingsIdRefHeader, &uiViewSettingsIdHs))) + if (FAILED(WindowsCreateStringReference(uiViewSettingsId, uiViewSettingsIdLen, &uiViewSettingsIdRefHeader, &uiViewSettingsIdHs))) return false; IUIViewSettingsInterop *uiViewSettingsInterop = nullptr; // __uuidof(IUIViewSettingsInterop); const GUID uiViewSettingsInteropRefId = {0x3694dbf9, 0x8f68, 0x44be,{0x8f, 0xf5, 0x19, 0x5c, 0x98, 0xed, 0xe8, 0xa6}}; - HRESULT hr = baseComDll.roGetActivationFactory(uiViewSettingsIdHs, uiViewSettingsInteropRefId, + HRESULT hr = RoGetActivationFactory(uiViewSettingsIdHs, uiViewSettingsInteropRefId, reinterpret_cast<void **>(&uiViewSettingsInterop)); if (FAILED(hr)) return false; |