From 32708d53946da77b6137fa04b1849b27e84f2d0f Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Tue, 26 Jun 2018 12:52:18 -0400 Subject: Fix video window parenting and positioning The positioning code seemed to be expecting that the video window is created as an application window but mm-renderer creates the window as a child when a group is specified. When the application window isn't located in the top-left corner of the display, this assumption produces incorrect positioning of the video window. Contrary to what a comment in the code indicated, the video window does not need to be parented to the application window. Doing so just makes it difficult to determine the correct position for the video window. Also ensure that the video window is resized when the metadata information doesn't contain width/height. On QNX 7.0.0, the code may fail to resize the window because the metadata doesn't contain the width/height information under the expected key. A floating point divide by zero occurs with undefined results. I'll adjust for the width/height move in a separate commit. Change-Id: I540c1798a03b7c03a4438d0852c80e4d086009be Reviewed-by: Janne Koskinen Reviewed-by: Rafael Roquetto --- .../qnx/mediaplayer/mmrenderervideowindowcontrol.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/plugins/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp b/src/plugins/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp index 9930dd2e1..fbd698eea 100644 --- a/src/plugins/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp +++ b/src/plugins/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp @@ -205,18 +205,11 @@ void MmRendererVideoWindowControl::attachDisplay(mmr_context_t *context) return; } - QWindow *windowForGroup = window; - - //According to mmr_output_attach() documentation, the window group name of the - //application's top-level window is expected. - while (windowForGroup->parent()) - windowForGroup = windowForGroup->parent(); - const char * const groupNameData = static_cast( - nativeInterface->nativeResourceForWindow("windowGroup", windowForGroup)); + nativeInterface->nativeResourceForWindow("windowGroup", window)); if (!groupNameData) { qDebug() << "MmRendererVideoWindowControl: Unable to find window group for window" - << windowForGroup; + << window; return; } @@ -250,9 +243,7 @@ void MmRendererVideoWindowControl::updateVideoPosition() { QWindow * const window = findWindow(m_winId); if (m_context && m_videoId != -1 && window) { - QPoint topLeft = m_fullscreen ? - QPoint(0,0) : - window->mapToGlobal(m_displayRect.topLeft()); + QPoint topLeft = m_displayRect.topLeft(); QScreen * const screen = window->screen(); int width = m_fullscreen ? @@ -262,7 +253,8 @@ void MmRendererVideoWindowControl::updateVideoPosition() screen->size().height() : m_displayRect.height(); - if (m_metaData.hasVideo()) { // We need the source size to do aspect ratio scaling + if (m_metaData.hasVideo() && m_metaData.width() > 0 && m_metaData.height() > 0) { + // We need the source size to do aspect ratio scaling const qreal sourceRatio = m_metaData.width() / static_cast(m_metaData.height()); const qreal targetRatio = width / static_cast(height); -- cgit v1.2.1