From 436faee8b3704f9aae5620bc69f14c3461fc208c Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 27 Feb 2018 19:59:54 +0100 Subject: WinRT: Add Windows UI Automation support Adds support to accessibility tools and programmatic UI control to the WinRT platform through Windows UI Automation, using the AutomationPeer API. [ChangeLog][winrt][feature] Added support to Windows UI Automation to the WinRT QPA, allowing Qt-based UWP applications to operate with accessibility and programmatic UI control tools. Change-Id: If0a8edbebc7c16c4896d749f2d7e11809b4b37b3 Reviewed-by: Oliver Wolff Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/winrt/qwinrtscreen.cpp') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index e37aeb0bc5..a325d6f817 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -46,6 +46,7 @@ #include "qwinrtdrag.h" #endif #include "qwinrtwindow.h" +#include "qwinrtcanvas.h" #include #include @@ -463,7 +464,7 @@ public: QTouchDevice *touchDevice; ComPtr coreWindow; ComPtr redirect; - ComPtr canvas; + ComPtr canvas; ComPtr view; ComPtr displayInformation; @@ -553,27 +554,25 @@ QWinRTScreen::QWinRTScreen() hr = applicationViewStatics->GetForCurrentView(&d->view); RETURN_VOID_IF_FAILED("Could not access currentView"); - // Create a canvas and set it as the window content. Eventually, this should have its own method so multiple "screens" can be added - ComPtr canvas; - hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_UI_Xaml_Controls_Canvas).Get(), &canvas); - Q_ASSERT_SUCCEEDED(hr); + d->canvas = Make([this]() { return topWindow(); }); + ComPtr frameworkElement; - hr = canvas.As(&frameworkElement); + hr = d->canvas.As(&frameworkElement); Q_ASSERT_SUCCEEDED(hr); hr = frameworkElement->put_Width(d->logicalRect.width()); Q_ASSERT_SUCCEEDED(hr); hr = frameworkElement->put_Height(d->logicalRect.height()); Q_ASSERT_SUCCEEDED(hr); + ComPtr uiElement; - hr = canvas.As(&uiElement); + hr = d->canvas.As(&uiElement); Q_ASSERT_SUCCEEDED(hr); + #ifndef QT_NO_DRAGANDDROP QWinRTDrag::instance()->setUiElement(uiElement); #endif hr = window->put_Content(uiElement.Get()); Q_ASSERT_SUCCEEDED(hr); - hr = canvas.As(&d->canvas); - Q_ASSERT_SUCCEEDED(hr); d->cursor.reset(new QWinRTCursor); @@ -723,7 +722,10 @@ ICoreWindow *QWinRTScreen::coreWindow() const Xaml::IDependencyObject *QWinRTScreen::canvas() const { Q_D(const QWinRTScreen); - return d->canvas.Get(); + Xaml::IDependencyObject *depCanvas; + if (SUCCEEDED(d->canvas.CopyTo(&depCanvas))) + return depCanvas; + return nullptr; } void QWinRTScreen::initialize() -- cgit v1.2.3