diff options
Diffstat (limited to 'src/plugins/platforms/winrt')
-rw-r--r-- | src/plugins/platforms/winrt/qwinrteglcontext.cpp | 1 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtfileengine.cpp | 12 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtscreen.cpp | 260 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtscreen.h | 18 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtwindow.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/winrt.pro | 2 |
6 files changed, 124 insertions, 174 deletions
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp index fc5cabc033..5c3ecd8726 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp @@ -138,6 +138,7 @@ void QWinRTEGLContext::initialize() EGL_CONTEXT_CLIENT_VERSION, d->format.majorVersion(), EGL_CONTEXT_MINOR_VERSION_KHR, d->format.minorVersion(), EGL_CONTEXT_FLAGS_KHR, flags, + EGL_CONTEXT_OPENGL_NO_ERROR_KHR, true, EGL_NONE }; d->eglContext = eglCreateContext(g->eglDisplay, d->eglConfig, d->eglShareContext, attributes); diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp index ad81ef4f5f..53e7ebd30d 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp +++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp @@ -466,14 +466,20 @@ qint64 QWinRTFileEngine::read(char *data, qint64 maxlen) hr = stream->ReadAsync(buffer.Get(), length, InputStreamOptions_None, &op); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); - hr = QWinRTFunctions::await(op, buffer.GetAddressOf()); + // Quoting MSDN IInputStream::ReadAsync() documentation: + // "Depending on the implementation, the data that's read might be placed + // into the input buffer, or it might be returned in a different buffer." + // Using GetAddressOf can cause ref counting errors leaking the original + // buffer. + ComPtr<IBuffer> effectiveBuffer; + hr = QWinRTFunctions::await(op, effectiveBuffer.GetAddressOf()); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); - hr = buffer->get_Length(&length); + hr = effectiveBuffer->get_Length(&length); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess; - hr = buffer.As(&byteArrayAccess); + hr = effectiveBuffer.As(&byteArrayAccess); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); byte *bytes; diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 562372d0b8..aed33f6b48 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -88,9 +88,9 @@ typedef ITypedEventHandler<CoreWindow*, PointerEventArgs*> PointerHandler; typedef ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*> SizeChangedHandler; typedef ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*> VisibilityChangedHandler; typedef ITypedEventHandler<DisplayInformation*, IInspectable*> DisplayInformationHandler; -#ifdef Q_OS_WINPHONE -typedef ITypedEventHandler<StatusBar*, IInspectable*> StatusBarHandler; -#endif +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +typedef ITypedEventHandler<ApplicationView*, IInspectable*> VisibleBoundsChangedHandler; +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) QT_BEGIN_NAMESPACE @@ -451,10 +451,10 @@ typedef HRESULT (__stdcall ICoreWindow::*CoreWindowCallbackRemover)(EventRegistr uint qHash(CoreWindowCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } typedef HRESULT (__stdcall IDisplayInformation::*DisplayCallbackRemover)(EventRegistrationToken); uint qHash(DisplayCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } -#ifdef Q_OS_WINPHONE -typedef HRESULT (__stdcall IStatusBar::*StatusBarCallbackRemover)(EventRegistrationToken); -uint qHash(StatusBarCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } -#endif +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +typedef HRESULT (__stdcall IApplicationView2::*ApplicationView2CallbackRemover)(EventRegistrationToken); +uint qHash(ApplicationView2CallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) class QWinRTScreenPrivate { @@ -464,13 +464,11 @@ public: ComPtr<Xaml::IDependencyObject> canvas; ComPtr<IApplicationView> view; ComPtr<IDisplayInformation> displayInformation; -#ifdef Q_OS_WINPHONE - ComPtr<IStatusBar> statusBar; -#endif QScopedPointer<QWinRTCursor> cursor; QHash<quint32, QWindowSystemInterface::TouchPoint> touchPoints; - QSizeF logicalSize; + QRectF logicalRect; + QRectF visibleRect; QSurfaceFormat surfaceFormat; qreal logicalDpi; QDpi physicalDpi; @@ -481,9 +479,10 @@ public: QHash<Qt::Key, KeyInfo> activeKeys; QHash<CoreWindowCallbackRemover, EventRegistrationToken> windowTokens; QHash<DisplayCallbackRemover, EventRegistrationToken> displayTokens; -#ifdef Q_OS_WINPHONE - QHash<StatusBarCallbackRemover, EventRegistrationToken> statusBarTokens; -#endif +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + QHash<ApplicationView2CallbackRemover, EventRegistrationToken> view2Tokens; + ComPtr<IApplicationView2> view2; +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) }; // To be called from the XAML thread @@ -514,7 +513,8 @@ QWinRTScreen::QWinRTScreen() Rect rect; hr = d->coreWindow->get_Bounds(&rect); Q_ASSERT_SUCCEEDED(hr); - d->logicalSize = QSizeF(rect.Width, rect.Height); + d->logicalRect = QRectF(0.0f, 0.0f, rect.Width, rect.Height); + d->visibleRect = QRectF(0.0f, 0.0f, rect.Width, rect.Height); // Orientation handling ComPtr<IDisplayInformationStatics> displayInformationStatics; @@ -549,9 +549,9 @@ QWinRTScreen::QWinRTScreen() ComPtr<Xaml::IFrameworkElement> frameworkElement; hr = canvas.As(&frameworkElement); Q_ASSERT_SUCCEEDED(hr); - hr = frameworkElement->put_Width(d->logicalSize.width()); + hr = frameworkElement->put_Width(d->logicalRect.width()); Q_ASSERT_SUCCEEDED(hr); - hr = frameworkElement->put_Height(d->logicalSize.height()); + hr = frameworkElement->put_Height(d->logicalRect.height()); Q_ASSERT_SUCCEEDED(hr); ComPtr<Xaml::IUIElement> uiElement; hr = canvas.As(&uiElement); @@ -563,14 +563,10 @@ QWinRTScreen::QWinRTScreen() d->cursor.reset(new QWinRTCursor); -#ifdef Q_OS_WINPHONE - ComPtr<IStatusBarStatics> statusBarStatics; - hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_StatusBar).Get(), - IID_PPV_ARGS(&statusBarStatics)); - Q_ASSERT_SUCCEEDED(hr); - hr = statusBarStatics->GetForCurrentView(&d->statusBar); +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + hr = d->view.As(&d->view2); Q_ASSERT_SUCCEEDED(hr); -#endif // Q_OS_WINPHONE +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) } QWinRTScreen::~QWinRTScreen() @@ -590,12 +586,12 @@ QWinRTScreen::~QWinRTScreen() hr = (d->displayInformation.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } -#ifdef Q_OS_WINPHONE - for (QHash<StatusBarCallbackRemover, EventRegistrationToken>::const_iterator i = d->statusBarTokens.begin(); i != d->statusBarTokens.end(); ++i) { - hr = (d->statusBar.Get()->*i.key())(i.value()); +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + for (QHash<ApplicationView2CallbackRemover, EventRegistrationToken>::const_iterator i = d->view2Tokens.begin(); i != d->view2Tokens.end(); ++i) { + hr = (d->view2.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } -#endif //Q_OS_WINPHONE +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) return hr; }); RETURN_VOID_IF_FAILED("Failed to unregister screen event callbacks"); @@ -604,33 +600,17 @@ QWinRTScreen::~QWinRTScreen() QRect QWinRTScreen::geometry() const { Q_D(const QWinRTScreen); - return QRect(QPoint(), (d->logicalSize * d->scaleFactor).toSize()); + return QRect(QPoint(), QSizeF(d->logicalRect.size() * d->scaleFactor).toSize()); } -#ifdef Q_OS_WINPHONE QRect QWinRTScreen::availableGeometry() const { Q_D(const QWinRTScreen); - QRect statusBar; - QEventDispatcherWinRT::runOnXamlThread([d, &statusBar]() { - HRESULT hr; - Rect rect; - hr = d->statusBar->get_OccludedRect(&rect); - Q_ASSERT_SUCCEEDED(hr); - statusBar.setRect(qRound(rect.X * d->scaleFactor), - qRound(rect.Y * d->scaleFactor), - qRound(rect.Width * d->scaleFactor), - qRound(rect.Height * d->scaleFactor)); - return S_OK; - }); - - return geometry().adjusted( - d->orientation == Qt::LandscapeOrientation ? statusBar.width() : 0, - d->orientation == Qt::PortraitOrientation ? statusBar.height() : 0, - d->orientation == Qt::InvertedLandscapeOrientation ? -statusBar.width() : 0, - 0); + return QRectF((d->visibleRect.x() - d->logicalRect.x())* d->scaleFactor, + (d->visibleRect.y() - d->logicalRect.y()) * d->scaleFactor, + d->visibleRect.width() * d->scaleFactor, + d->visibleRect.height() * d->scaleFactor).toRect(); } -#endif //Q_OS_WINPHONE int QWinRTScreen::depth() const { @@ -645,8 +625,8 @@ QImage::Format QWinRTScreen::format() const QSizeF QWinRTScreen::physicalSize() const { Q_D(const QWinRTScreen); - return QSizeF(d->logicalSize.width() * d->scaleFactor / d->physicalDpi.first * qreal(25.4), - d->logicalSize.height() * d->scaleFactor / d->physicalDpi.second * qreal(25.4)); + return QSizeF(d->logicalRect.width() * d->scaleFactor / d->physicalDpi.first * qreal(25.4), + d->logicalRect.height() * d->scaleFactor / d->physicalDpi.second * qreal(25.4)); } QDpi QWinRTScreen::logicalDpi() const @@ -723,29 +703,6 @@ Xaml::IDependencyObject *QWinRTScreen::canvas() const return d->canvas.Get(); } -#ifdef Q_OS_WINPHONE -void QWinRTScreen::setStatusBarVisibility(bool visible, QWindow *window) -{ - Q_D(QWinRTScreen); - qCDebug(lcQpaWindows) << __FUNCTION__ << window << visible; - - const Qt::WindowFlags windowType = window->flags() & Qt::WindowType_Mask; - if (!window || (windowType != Qt::Window && windowType != Qt::Dialog)) - return; - - QEventDispatcherWinRT::runOnXamlThread([d, visible]() { - HRESULT hr; - ComPtr<IAsyncAction> op; - if (visible) - hr = d->statusBar->ShowAsync(&op); - else - hr = d->statusBar->HideAsync(&op); - Q_ASSERT_SUCCEEDED(hr); - return S_OK; - }); -} -#endif //Q_OS_WINPHONE - void QWinRTScreen::initialize() { Q_D(QWinRTScreen); @@ -768,15 +725,14 @@ void QWinRTScreen::initialize() Q_ASSERT_SUCCEEDED(hr); hr = d->coreWindow->add_PointerWheelChanged(Callback<PointerHandler>(this, &QWinRTScreen::onPointerUpdated).Get(), &d->windowTokens[&ICoreWindow::remove_PointerWheelChanged]); Q_ASSERT_SUCCEEDED(hr); -#ifndef Q_OS_WINPHONE - hr = d->coreWindow->add_SizeChanged(Callback<SizeChangedHandler>(this, &QWinRTScreen::onSizeChanged).Get(), &d->windowTokens[&ICoreWindow::remove_SizeChanged]); +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + hr = d->view2->add_VisibleBoundsChanged(Callback<VisibleBoundsChangedHandler>(this, &QWinRTScreen::onWindowSizeChanged).Get(), &d->view2Tokens[&IApplicationView2::remove_VisibleBoundsChanged]); Q_ASSERT_SUCCEEDED(hr); #else - hr = d->statusBar->add_Showing(Callback<StatusBarHandler>(this, &QWinRTScreen::onStatusBarShowing).Get(), &d->statusBarTokens[&IStatusBar::remove_Showing]); - Q_ASSERT_SUCCEEDED(hr); - hr = d->statusBar->add_Hiding(Callback<StatusBarHandler>(this, &QWinRTScreen::onStatusBarHiding).Get(), &d->statusBarTokens[&IStatusBar::remove_Hiding]); - Q_ASSERT_SUCCEEDED(hr); -#endif + hr = d->coreWindow->add_SizeChanged(Callback<SizeChangedHandler>(this, &QWinRTScreen::onWindowSizeChanged).Get(), &d->windowTokens[&ICoreWindow::remove_SizeChanged]); + Q_ASSERT_SUCCEEDED(hr) +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + hr = d->coreWindow->add_Activated(Callback<ActivatedHandler>(this, &QWinRTScreen::onActivated).Get(), &d->windowTokens[&ICoreWindow::remove_Activated]); Q_ASSERT_SUCCEEDED(hr); hr = d->coreWindow->add_Closed(Callback<ClosedHandler>(this, &QWinRTScreen::onClosed).Get(), &d->windowTokens[&ICoreWindow::remove_Closed]); @@ -804,11 +760,6 @@ void QWinRTScreen::addWindow(QWindow *window) if (window == topWindow()) return; -#ifdef Q_OS_WINPHONE - if (window->visibility() != QWindow::Maximized && window->visibility() != QWindow::Windowed) - setStatusBarVisibility(false, window); -#endif - d->visibleWindows.prepend(window); QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); handleExpose(); @@ -820,11 +771,6 @@ void QWinRTScreen::removeWindow(QWindow *window) Q_D(QWinRTScreen); qCDebug(lcQpaWindows) << __FUNCTION__ << window; -#ifdef Q_OS_WINPHONE - if (window->visibility() == QWindow::Minimized) - setStatusBarVisibility(false, window); -#endif - const bool wasTopWindow = window == topWindow(); if (!d->visibleWindows.removeAll(window)) return; @@ -1009,8 +955,20 @@ HRESULT QWinRTScreen::onPointerEntered(ICoreWindow *, IPointerEventArgs *args) return S_OK; } -HRESULT QWinRTScreen::onPointerExited(ICoreWindow *, IPointerEventArgs *) +HRESULT QWinRTScreen::onPointerExited(ICoreWindow *, IPointerEventArgs *args) { + Q_D(QWinRTScreen); + + ComPtr<IPointerPoint> pointerPoint; + if (FAILED(args->get_CurrentPoint(&pointerPoint))) + return E_INVALIDARG; + + quint32 id; + if (FAILED(pointerPoint->get_PointerId(&id))) + return E_INVALIDARG; + + d->touchPoints.remove(id); + QWindowSystemInterface::handleLeaveEvent(0); return S_OK; } @@ -1094,6 +1052,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) break; } + case PointerDeviceType_Pen: case PointerDeviceType_Touch: { if (!d->touchDevice) { d->touchDevice = new QTouchDevice; @@ -1112,51 +1071,45 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) float pressure; properties->get_Pressure(&pressure); - QHash<quint32, QWindowSystemInterface::TouchPoint>::iterator it = d->touchPoints.find(id); - if (it != d->touchPoints.end()) { - boolean isPressed; + boolean isPressed; #ifndef Q_OS_WINPHONE - pointerPoint->get_IsInContact(&isPressed); + pointerPoint->get_IsInContact(&isPressed); #else - properties->get_IsLeftButtonPressed(&isPressed); // IsInContact not reliable on phone + properties->get_IsLeftButtonPressed(&isPressed); // IsInContact not reliable on phone #endif - it.value().state = isPressed ? Qt::TouchPointMoved : Qt::TouchPointReleased; - } else { + + const QRectF areaRect(area.X * d->scaleFactor, area.Y * d->scaleFactor, + area.Width * d->scaleFactor, area.Height * d->scaleFactor); + + QHash<quint32, QWindowSystemInterface::TouchPoint>::iterator it = d->touchPoints.find(id); + if (it == d->touchPoints.end()) { it = d->touchPoints.insert(id, QWindowSystemInterface::TouchPoint()); - it.value().state = Qt::TouchPointPressed; it.value().id = id; } - it.value().area = QRectF(area.X * d->scaleFactor, area.Y * d->scaleFactor, - area.Width * d->scaleFactor, area.Height * d->scaleFactor); - it.value().normalPosition = QPointF(point.X/d->logicalSize.width(), point.Y/d->logicalSize.height()); - it.value().pressure = pressure; - QWindowSystemInterface::handleTouchEvent(topWindow(), d->touchDevice, d->touchPoints.values(), mods); + if (isPressed && it.value().pressure == 0.) + it.value().state = Qt::TouchPointPressed; + else if (!isPressed && it.value().pressure > 0.) + it.value().state = Qt::TouchPointReleased; + else if (it.value().area == areaRect) + it.value().state = Qt::TouchPointStationary; + else + it.value().state = Qt::TouchPointMoved; - // Remove released points, station others - for (QHash<quint32, QWindowSystemInterface::TouchPoint>::iterator i = d->touchPoints.begin(); i != d->touchPoints.end();) { - if (i.value().state == Qt::TouchPointReleased) - i = d->touchPoints.erase(i); - else - (i++).value().state = Qt::TouchPointStationary; - } + it.value().area = areaRect; + it.value().normalPosition = QPointF(point.X/d->logicalRect.width(), point.Y/d->logicalRect.height()); + it.value().pressure = pressure; - break; - } - case PointerDeviceType_Pen: { - quint32 id; - pointerPoint->get_PointerId(&id); + QWindowSystemInterface::handleTouchEvent(topWindow(), d->touchDevice, d->touchPoints.values(), mods); - boolean isPressed; - pointerPoint->get_IsInContact(&isPressed); + // Fall-through for pen to generate tablet event + if (pointerDeviceType != PointerDeviceType_Pen) + break; boolean isEraser; properties->get_IsEraser(&isEraser); int pointerType = isEraser ? 3 : 1; - float pressure; - properties->get_Pressure(&pressure); - float xTilt; properties->get_XTilt(&xTilt); @@ -1177,22 +1130,6 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) return S_OK; } -HRESULT QWinRTScreen::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs *) -{ - Q_D(QWinRTScreen); - - Rect size; - HRESULT hr; - hr = d->coreWindow->get_Bounds(&size); - RETURN_OK_IF_FAILED("Failed to get window bounds"); - d->logicalSize = QSizeF(size.Width, size.Height); - qCDebug(lcQpaWindows) << __FUNCTION__ << d->logicalSize; - QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry()); - QPlatformScreen::resizeMaximizedWindows(); - handleExpose(); - return S_OK; -} - HRESULT QWinRTScreen::onActivated(ICoreWindow *, IWindowActivatedEventArgs *args) { Q_D(QWinRTScreen); @@ -1205,6 +1142,8 @@ HRESULT QWinRTScreen::onActivated(ICoreWindow *, IWindowActivatedEventArgs *args return S_OK; } + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); + // Activate topWindow if (!d->visibleWindows.isEmpty()) { Qt::FocusReason focusReason = activationState == CoreWindowActivationState_PointerActivated @@ -1231,8 +1170,10 @@ HRESULT QWinRTScreen::onVisibilityChanged(ICoreWindow *, IVisibilityChangedEvent RETURN_OK_IF_FAILED("Failed to get visibility."); qCDebug(lcQpaWindows) << __FUNCTION__ << visible; QWindowSystemInterface::handleApplicationStateChanged(visible ? Qt::ApplicationActive : Qt::ApplicationHidden); - if (visible) + if (visible) { handleExpose(); + onWindowSizeChanged(nullptr, nullptr); + } return S_OK; } @@ -1248,9 +1189,7 @@ HRESULT QWinRTScreen::onOrientationChanged(IDisplayInformation *, IInspectable * if (d->orientation != newOrientation) { d->orientation = newOrientation; qCDebug(lcQpaWindows) << " New orientation:" << newOrientation; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) - onSizeChanged(nullptr, nullptr); -#endif + onWindowSizeChanged(nullptr, nullptr); QWindowSystemInterface::handleScreenOrientationChange(screen(), d->orientation); handleExpose(); // Clean broken frames caused by race between Qt and ANGLE } @@ -1294,20 +1233,35 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) return S_OK; } -#ifdef Q_OS_WINPHONE -HRESULT QWinRTScreen::onStatusBarShowing(IStatusBar *, IInspectable *) +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *) +#else +HRESULT QWinRTScreen::onWindowSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs *) +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) { - qCDebug(lcQpaWindows) << __FUNCTION__; - onSizeChanged(nullptr, nullptr); - return S_OK; -} + Q_D(QWinRTScreen); -HRESULT QWinRTScreen::onStatusBarHiding(IStatusBar *, IInspectable *) -{ - qCDebug(lcQpaWindows) << __FUNCTION__; - onSizeChanged(nullptr, nullptr); + HRESULT hr; + Rect windowSize; + + hr = d->coreWindow->get_Bounds(&windowSize); + RETURN_OK_IF_FAILED("Failed to get window bounds"); + d->logicalRect = QRectF(windowSize.X, windowSize.Y, windowSize.Width, windowSize.Height); + +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + Rect visibleRect; + hr = d->view2->get_VisibleBounds(&visibleRect); + RETURN_OK_IF_FAILED("Failed to get window visible bounds"); + d->visibleRect = QRectF(visibleRect.X, visibleRect.Y, visibleRect.Width, visibleRect.Height); +#else + d->visibleRect = QRectF(windowSize.X, windowSize.Y, windowSize.Width, windowSize.Height); +#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + + qCDebug(lcQpaWindows) << __FUNCTION__ << d->logicalRect; + QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry()); + QPlatformScreen::resizeMaximizedWindows(); + handleExpose(); return S_OK; } -#endif //Q_OS_WINPHONE QT_END_NAMESPACE diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index bfab1e8385..5cada9726d 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -65,7 +65,7 @@ namespace ABI { struct IWindow; } namespace ViewManagement { - struct IStatusBar; + struct IApplicationView; } } namespace Graphics { @@ -88,10 +88,9 @@ class QWinRTScreen : public QPlatformScreen public: explicit QWinRTScreen(); ~QWinRTScreen(); + QRect geometry() const Q_DECL_OVERRIDE; -#ifdef Q_OS_WINPHONE QRect availableGeometry() const Q_DECL_OVERRIDE; -#endif int depth() const Q_DECL_OVERRIDE; QImage::Format format() const Q_DECL_OVERRIDE; QSizeF physicalSize() const Q_DECL_OVERRIDE; @@ -115,10 +114,6 @@ public: ABI::Windows::UI::Core::ICoreWindow *coreWindow() const; ABI::Windows::UI::Xaml::IDependencyObject *canvas() const; -#ifdef Q_OS_WINPHONE - void setStatusBarVisibility(bool visible, QWindow *window); -#endif - void initialize(); private: @@ -130,7 +125,6 @@ private: HRESULT onPointerEntered(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); HRESULT onPointerExited(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); HRESULT onPointerUpdated(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); - HRESULT onSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *); HRESULT onActivated(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowActivatedEventArgs *); @@ -139,10 +133,10 @@ private: HRESULT onOrientationChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *); HRESULT onDpiChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *); - -#ifdef Q_OS_WINPHONE - HRESULT onStatusBarShowing(ABI::Windows::UI::ViewManagement::IStatusBar *, IInspectable *); - HRESULT onStatusBarHiding(ABI::Windows::UI::ViewManagement::IStatusBar *, IInspectable *); +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) + HRESULT onWindowSizeChanged(ABI::Windows::UI::ViewManagement::IApplicationView *, IInspectable *); +#else + HRESULT onWindowSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *); #endif QScopedPointer<QWinRTScreenPrivate> d_ptr; diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index 9df087c055..3cae53d0a0 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -42,7 +42,6 @@ #include <private/qeventdispatcher_winrt_p.h> #include <EGL/egl.h> -#define EGL_EGLEXT_PROTOTYPES #include <EGL/eglext.h> #include <qfunctions_winrt.h> @@ -322,10 +321,6 @@ void QWinRTWindow::setWindowState(Qt::WindowState state) if (d->state == state) return; -#ifdef Q_OS_WINPHONE - d->screen->setStatusBarVisibility(state == Qt::WindowMaximized || state == Qt::WindowNoState, window()); -#endif - if (state == Qt::WindowMinimized) setUIElementVisibility(d->uiElement.Get(), false); diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 261295ef0b..144c581015 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -4,7 +4,7 @@ CONFIG -= precompile_header QT += core-private gui-private platformsupport-private -DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ GL_GLEXT_PROTOTYPES +DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ LIBS += $$QMAKE_LIBS_CORE -ldwrite -ld3d11 INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/freetype/include |