From 0f6ace8118c72781e6c4c68c3dc98a2937fedf35 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 17 Aug 2016 14:22:46 +0200 Subject: winrt: Fix crash when managing multiple top-level windows When a window gets removed, the active focus window needs to be set to 0 instead of the the current window. Otherwise QGuiApplicationPrivate::focus_window is set to an invalid pointer and crashes when dereferenced. Change-Id: I258b95e447de4cbfb7f19955079c2545a738e03f Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index c1118cd0b8..703627a6c5 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -782,7 +782,7 @@ void QWinRTScreen::removeWindow(QWindow *window) if (!d->visibleWindows.removeAll(window)) return; if (wasTopWindow) - QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); + QWindowSystemInterface::handleWindowActivated(Q_NULLPTR, Qt::OtherFocusReason); handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(); #if _MSC_VER >= 1900 && !defined(QT_NO_DRAGANDDROP) -- cgit v1.2.3 From a75cfa60d7f15513218f7719410b09f708a2940e Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 17 Aug 2016 15:43:11 +0200 Subject: winrt: Fix crashes for visible window management First, offscreen windows/surfaces should not be tracked in the visible window list. Secondly when destroying a window, it is not guaranteed that it had been removed first, hence enforce it to guarantee that the visibleWindows list stays correct and does not hold invalid weak pointers to non existing windows. Change-Id: I7027ecd010b8bcb3d05e3f5d460662e883e42e50 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 4 +++- src/plugins/platforms/winrt/qwinrtwindow.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 703627a6c5..77185f1bb9 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -760,7 +760,7 @@ void QWinRTScreen::addWindow(QWindow *window) { Q_D(QWinRTScreen); qCDebug(lcQpaWindows) << __FUNCTION__ << window; - if (window == topWindow()) + if (window == topWindow() || window->surfaceClass() == QSurface::Offscreen) return; d->visibleWindows.prepend(window); @@ -804,6 +804,8 @@ void QWinRTScreen::lower(QWindow *window) const bool wasTopWindow = window == topWindow(); if (wasTopWindow && d->visibleWindows.size() == 1) return; + if (window->surfaceClass() == QSurface::Offscreen) + return; d->visibleWindows.removeAll(window); d->visibleWindows.append(window); if (wasTopWindow) diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index 3bd0cd3ad7..cc50aaa8d1 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -189,6 +189,8 @@ QWinRTWindow::~QWinRTWindow() }); RETURN_VOID_IF_FAILED("Failed to completely destroy window resources, likely because the application is shutting down"); + d->screen->removeWindow(window()); + if (!d->surface) return; -- cgit v1.2.3 From 4531ae8d699d06197d8485702fc48214c5e4dda8 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 17 Aug 2016 15:40:59 +0200 Subject: winrt: only update window title for top level widgets Previously we always updated the window title, independently whether the window was visible / the toplevel one. This can also cause troubles when setting the title during initialization. Change-Id: I02ec0f0e385fa490f641ce83a6cb27717a31620f Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 8 ++------ src/plugins/platforms/winrt/qwinrtscreen.h | 2 +- src/plugins/platforms/winrt/qwinrtwindow.cpp | 4 +++- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 77185f1bb9..dd2ebee3d5 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -764,6 +764,7 @@ void QWinRTScreen::addWindow(QWindow *window) return; d->visibleWindows.prepend(window); + updateWindowTitle(window->title()); QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(); @@ -813,15 +814,10 @@ void QWinRTScreen::lower(QWindow *window) handleExpose(); } -void QWinRTScreen::updateWindowTitle() +void QWinRTScreen::updateWindowTitle(const QString &title) { Q_D(QWinRTScreen); - QWindow *window = topWindow(); - if (!window) - return; - - const QString title = window->title(); HStringReference titleRef(reinterpret_cast(title.utf16()), title.length()); HRESULT hr = d->view->put_Title(titleRef.Get()); RETURN_VOID_IF_FAILED("Unable to set window title"); diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index a5c1d24d51..ff1ff32ce9 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -106,7 +106,7 @@ public: void raise(QWindow *window); void lower(QWindow *window); - void updateWindowTitle(); + void updateWindowTitle(const QString &title); ABI::Windows::UI::Core::ICoreWindow *coreWindow() const; ABI::Windows::UI::Xaml::IDependencyObject *canvas() const; diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index cc50aaa8d1..be55ded7cd 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -282,7 +282,9 @@ void QWinRTWindow::setWindowTitle(const QString &title) { Q_D(QWinRTWindow); d->windowTitle = title; - d->screen->updateWindowTitle(); + + if (d->screen->topWindow() == window()) + d->screen->updateWindowTitle(title); } void QWinRTWindow::raise() -- cgit v1.2.3 From b8c1efcb887a2aa313fd843aa16a5be84d4189e6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 17 Aug 2016 13:03:59 +0200 Subject: DirectWrite: Fix calculating bounding box of glyphs We don't support vertical text layouts in Qt, so the vertical advance should always be 0 (like it is in other engines). Since we were setting this, we would calculate the bounding box of strings in the DirectWrite engine as if the layouts were diagonal, adding up both the horizontal and vertical advances. [ChangeLog][QtGui][Windows] Fixed height of text bounding box when using no or vertical hinting preference, or when the device pixel ratio is different from 1. Task-number: QTBUG-51024 Change-Id: I329917eb8da71fdfdffe9651ca8f0f48d26b6a60 Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint Reviewed-by: Konstantin Ritt --- src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 04a08d892a..f2758f6d90 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -436,7 +436,7 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g) width, height, advanceWidth, - advanceHeight); + 0); } else { qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__); } -- cgit v1.2.3 From d13d81eb01a84bb8fd599ceac5ffcf19fca2f91e Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 8 Jun 2015 14:35:22 +0300 Subject: Fix QWidget::setWindowRole() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce QXcbWindowFunctions::setWmWindowRole() and call it either from the implementation of QWidget::setWindowRole() or after the creation of the corresponding QWidgetWindow. Change-Id: I143450f4673dd707bb491c1d0f0e8b61d564283d Task-number: QTBUG-45484 Reviewed-by: Laszlo Agocs Reviewed-by: Ivan Čukić --- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 3 +++ src/plugins/platforms/xcb/qxcbwindow.cpp | 21 +++++++++++++++++++++ src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 3 files changed, 26 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 96239a0f20..09e7ecf3a3 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -350,6 +350,9 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic)); + if (function == QXcbWindowFunctions::setWmWindowRoleIdentifier()) + return QFunctionPointer(QXcbWindowFunctions::SetWmWindowRole(QXcbWindow::setWmWindowRoleStatic)); + if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic)); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 247e420f5d..da5020168f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -284,6 +284,7 @@ static QWindow *childWindowAt(QWindow *win, const QPoint &p) } static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; +static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) @@ -610,6 +611,11 @@ void QXcbWindow::create() setOpacity(opacity); if (window()->isTopLevel()) setWindowIcon(window()->icon()); + + if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) { + QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray(); + setWmWindowRole(wmWindowRole); + } } QXcbWindow::~QXcbWindow() @@ -1733,6 +1739,14 @@ void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text) static_cast(window->handle())->setWindowIconText(text); } +void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role) +{ + if (window->handle()) + static_cast(window->handle())->setWmWindowRole(role); + else + window->setProperty(wm_window_role_property_id, role); +} + uint QXcbWindow::visualIdStatic(QWindow *window) { if (window && window->handle()) @@ -1898,6 +1912,13 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W xcb_flush(xcb_connection()); } +void QXcbWindow::setWmWindowRole(const QByteArray &role) +{ + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8, + role.size(), role.constData())); +} + void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window) { if (window->handle()) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 4673f3dd33..b8bcf4428a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -145,10 +145,12 @@ public: void updateNetWmUserTime(xcb_timestamp_t timestamp); static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes); + static void setWmWindowRoleStatic(QWindow *window, const QByteArray &role); static uint visualIdStatic(QWindow *window); QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const; void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags); + void setWmWindowRole(const QByteArray &role); static void setWindowIconTextStatic(QWindow *window, const QString &text); -- cgit v1.2.3