summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins.qnx@kdab.com>2013-01-11 12:23:26 +0000
committerSérgio Martins <sergio.martins.qnx@kdab.com>2013-01-29 15:42:35 +0100
commit0074eaee6c09691f566d5df23bc169489edaabd9 (patch)
treedb63fb401518a49efebd3ed6be5e6eb052c5a516
parentd3a020fcc475e2a4560bbe3aff557fac601bd064 (diff)
Adjust all setDisplayRect() calls for the case when winId is 0.
alien to native promotion is broken in Qt4 QPA. updateWinId() already had a workaround, introduced in 806b4da112b35313b7e674a2735d888809f74288 This commit makes all setDisplayRect() calls use the workaround too. Change-Id: I44e879bfd7983f3f9b308d58d714014605ea128a Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
-rw-r--r--src/multimedia/qgraphicsvideoitem_overlay.cpp25
-rw-r--r--src/multimedia/qvideowidget.cpp45
-rw-r--r--src/multimedia/qvideowidget_p.h2
3 files changed, 56 insertions, 16 deletions
diff --git a/src/multimedia/qgraphicsvideoitem_overlay.cpp b/src/multimedia/qgraphicsvideoitem_overlay.cpp
index 706ce502b2..8e019c6287 100644
--- a/src/multimedia/qgraphicsvideoitem_overlay.cpp
+++ b/src/multimedia/qgraphicsvideoitem_overlay.cpp
@@ -98,6 +98,7 @@ public:
bool eventFilter(QObject *object, QEvent *event);
void updateEventFilters();
+ QWidget* nativeParent() const;
void setWidget(QWidget *widget);
void clearService();
@@ -116,6 +117,15 @@ void QGraphicsVideoItemPrivate::_q_present()
}
+QWidget* QGraphicsVideoItemPrivate::nativeParent() const
+{
+ QWidget *parent = videoWidget;
+ while (parent && !parent->winId()) {
+ parent = parent->parentWidget();
+ }
+ return parent;
+}
+
void QGraphicsVideoItemPrivate::updateWindowId()
{
const WId winId = videoWidget->winId();
@@ -125,10 +135,7 @@ void QGraphicsVideoItemPrivate::updateWindowId()
if (winId == 0) {
// Do not use videoWidget->effectiveWinId(), it will assert inside qtwidget
// This stuff is broken in QPA.
- QWidget *parent = videoWidget;
- while (parent && !parent->winId()) {
- parent = parent->parentWidget();
- }
+ QWidget *parent = nativeParent();
if (parent) {
windowControl->setWinId(parent->winId());
@@ -412,6 +419,16 @@ void QGraphicsVideoItem::paint(
QTransform transform = painter->combinedTransform();
QRect overlayRect = transform.mapRect(d->displayRect).toRect();
+
+ if (d->videoWidget && d->videoWidget->winId() == 0) {
+ // Workaround Qt4 QPA bug regarding alien to native promotion
+ QWidget *parent = d->nativeParent();
+ if (parent) {
+ QPoint topLeft = d->videoWidget->mapTo(parent, QPoint(0, 0));
+ overlayRect.translate(topLeft);
+ }
+ }
+
QRect currentSurfaceRect = d->windowControl->displayRect();
if (currentSurfaceRect != overlayRect) {
diff --git a/src/multimedia/qvideowidget.cpp b/src/multimedia/qvideowidget.cpp
index 27e404b37b..92b3b5c6f5 100644
--- a/src/multimedia/qvideowidget.cpp
+++ b/src/multimedia/qvideowidget.cpp
@@ -384,8 +384,7 @@ QSize QWindowVideoWidgetBackend::sizeHint() const
void QWindowVideoWidgetBackend::showEvent()
{
updateWindowId();
-
- m_windowControl->setDisplayRect(m_widget->rect());
+ updateDisplayRect();
#if defined(Q_WS_WIN)
m_widget->setUpdatesEnabled(false);
@@ -401,12 +400,12 @@ void QWindowVideoWidgetBackend::hideEvent(QHideEvent *)
void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *)
{
- m_windowControl->setDisplayRect(m_widget->rect());
+ updateDisplayRect();
}
void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *)
{
- m_windowControl->setDisplayRect(m_widget->rect());
+ updateDisplayRect();
}
void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event)
@@ -422,24 +421,46 @@ void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event)
event->accept();
}
-void QWindowVideoWidgetBackend::updateWindowId()
+QWidget* QWindowVideoWidgetBackend::nativeParent() const
+{
+ // Do not use m_widget->effectiveWinId(), it will assert inside qtwidget
+ // This stuff is broken in QPA.
+ QWidget *parent = m_widget;
+ while (parent && !parent->winId()) {
+ parent = parent->parentWidget();
+ }
+
+ return parent;
+}
+
+void QWindowVideoWidgetBackend::updateDisplayRect()
{
const WId winId = m_widget->winId();
// If the window ID is 0, it was not possible to promote the video widget from an alien widget
// to a native widget. As a last resort use the native ancestor instead.
if (winId == 0) {
- // Do not use m_widget->effectiveWinId(), it will assert inside qtwidget
- // This stuff is broken in QPA.
- QWidget *parent = m_widget;
- while (parent && !parent->winId()) {
- parent = parent->parentWidget();
+ QWidget *parent = nativeParent();
+ if (parent) {
+ QPoint topLeft = m_widget->mapTo(parent, QPoint(0, 0));
+ m_windowControl->setDisplayRect(QRect(topLeft, m_widget->size()));
}
+ } else {
+ m_windowControl->setDisplayRect(m_widget->rect());
+ }
+}
+
+void QWindowVideoWidgetBackend::updateWindowId()
+{
+ const WId winId = m_widget->winId();
+ // If the window ID is 0, it was not possible to promote the video widget from an alien widget
+ // to a native widget. As a last resort use the native ancestor instead.
+ if (winId == 0) {
+ QWidget *parent = nativeParent();
if (parent) {
m_windowControl->setWinId(parent->winId());
- QPoint topLeft = m_widget->mapTo(parent, QPoint(0, 0));
- m_windowControl->setDisplayRect(QRect(topLeft, m_widget->size()));
+ updateDisplayRect();
}
} else {
m_windowControl->setWinId(winId);
diff --git a/src/multimedia/qvideowidget_p.h b/src/multimedia/qvideowidget_p.h
index f1a6255b2e..4f69cf30c3 100644
--- a/src/multimedia/qvideowidget_p.h
+++ b/src/multimedia/qvideowidget_p.h
@@ -213,6 +213,8 @@ public:
private:
void updateWindowId();
+ void updateDisplayRect();
+ QWidget* nativeParent() const;
QMediaService *m_service;
QVideoWindowControl *m_windowControl;