Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwin10helpers.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwin10helpers.h"
5
6#include <QtCore/qdebug.h>
7#include <winstring.h>
8#include <roapi.h>
9
10#if defined(Q_CC_MINGW) || defined(Q_CC_CLANG)
11# define HAS_UI_VIEW_SETTINGS_INTEROP
12// Present from MSVC2015 + SDK 10 onwards
13#elif (!defined(Q_CC_MSVC) || _MSC_VER >= 1900) && WINVER >= 0x0A00
14# define HAS_UI_VIEW_SETTINGS_INTEROP
15# define HAS_UI_VIEW_SETTINGS
16#endif
17
18#include <inspectable.h>
19
20#ifdef HAS_UI_VIEW_SETTINGS
21# include <windows.ui.viewmanagement.h>
22#endif
23
24#ifdef HAS_UI_VIEW_SETTINGS_INTEROP
25# include <uiviewsettingsinterop.h>
26#endif
27
28#ifndef HAS_UI_VIEW_SETTINGS_INTEROP
29MIDL_INTERFACE("3694dbf9-8f68-44be-8ff5-195c98ede8a6")
30IUIViewSettingsInterop : public IInspectable
31{
32public:
33 virtual HRESULT STDMETHODCALLTYPE GetForWindow(
34 __RPC__in HWND hwnd,
35 __RPC__in REFIID riid,
36 __RPC__deref_out_opt void **ppv) = 0;
37};
38#endif // !HAS_UI_VIEW_SETTINGS_INTEROP
39
40#ifndef HAS_UI_VIEW_SETTINGS
41namespace ABI {
42namespace Windows {
43namespace UI {
44namespace ViewManagement {
45
47
48MIDL_INTERFACE("C63657F6-8850-470D-88F8-455E16EA2C26")
49IUIViewSettings : public IInspectable
50{
51public:
52 virtual HRESULT STDMETHODCALLTYPE get_UserInteractionMode(UserInteractionMode *value) = 0;
53};
54
55} // namespace ViewManagement
56} // namespace UI
57} // namespace Windows
58} // namespace ABI
59#endif // HAS_UI_VIEW_SETTINGS
60
62
63// Return tablet mode, note: Does not work for GetDesktopWindow().
65{
66 bool result = false;
67
68 const wchar_t uiViewSettingsId[] = L"Windows.UI.ViewManagement.UIViewSettings";
69 HSTRING_HEADER uiViewSettingsIdRefHeader;
70 HSTRING uiViewSettingsIdHs = nullptr;
71 const auto uiViewSettingsIdLen = UINT32(sizeof(uiViewSettingsId) / sizeof(uiViewSettingsId[0]) - 1);
72 if (FAILED(WindowsCreateStringReference(uiViewSettingsId, uiViewSettingsIdLen, &uiViewSettingsIdRefHeader, &uiViewSettingsIdHs)))
73 return false;
74
75 IUIViewSettingsInterop *uiViewSettingsInterop = nullptr;
76 // __uuidof(IUIViewSettingsInterop);
77 const GUID uiViewSettingsInteropRefId = {0x3694dbf9, 0x8f68, 0x44be,{0x8f, 0xf5, 0x19, 0x5c, 0x98, 0xed, 0xe8, 0xa6}};
78
79 HRESULT hr = RoGetActivationFactory(uiViewSettingsIdHs, uiViewSettingsInteropRefId,
80 reinterpret_cast<void **>(&uiViewSettingsInterop));
81 if (FAILED(hr))
82 return false;
83
84 // __uuidof(ABI::Windows::UI::ViewManagement::IUIViewSettings);
85 const GUID uiViewSettingsRefId = {0xc63657f6, 0x8850, 0x470d,{0x88, 0xf8, 0x45, 0x5e, 0x16, 0xea, 0x2c, 0x26}};
86 ABI::Windows::UI::ViewManagement::IUIViewSettings *viewSettings = nullptr;
87 hr = uiViewSettingsInterop->GetForWindow(hwnd, uiViewSettingsRefId,
88 reinterpret_cast<void **>(&viewSettings));
89 if (SUCCEEDED(hr)) {
91 hr = viewSettings->get_UserInteractionMode(&currentMode);
92 if (SUCCEEDED(hr))
93 result = currentMode == 1; // Touch, 1
94 viewSettings->Release();
95 }
96 uiViewSettingsInterop->Release();
97 return result;
98}
99
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64EXT * result
[6]
IUIViewSettingsInterop __RPC__in REFIID riid
IUIViewSettingsInterop __RPC__in REFIID __RPC__deref_out_opt void ** ppv
QT_BEGIN_NAMESPACE bool qt_windowsIsTabletMode(HWND hwnd)
long HRESULT