summaryrefslogtreecommitdiffstats
path: root/src/multimedia/qgraphicsvideoitem_overlay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/qgraphicsvideoitem_overlay.cpp')
-rw-r--r--src/multimedia/qgraphicsvideoitem_overlay.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/multimedia/qgraphicsvideoitem_overlay.cpp b/src/multimedia/qgraphicsvideoitem_overlay.cpp
index b01a385987..1bcd329083 100644
--- a/src/multimedia/qgraphicsvideoitem_overlay.cpp
+++ b/src/multimedia/qgraphicsvideoitem_overlay.cpp
@@ -103,6 +103,7 @@ public:
void clearService();
void updateRects();
void updateLastFrame();
+ void updateWindowId();
void _q_present();
void _q_updateNativeSize();
@@ -115,6 +116,30 @@ void QGraphicsVideoItemPrivate::_q_present()
}
+void QGraphicsVideoItemPrivate::updateWindowId()
+{
+ const WId winId = videoWidget->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 videoWidget->effectiveWinId(), it will assert inside qtwidget
+ // This stuff is broken in QPA.
+ QWidget *parent = videoWidget;
+ while (parent && !parent->winId()) {
+ parent = parent->parentWidget();
+ }
+
+ if (parent) {
+ windowControl->setWinId(parent->winId());
+ QPoint topLeft = videoWidget->mapTo(parent, QPoint(0, 0));
+ windowControl->setDisplayRect(QRect(topLeft, videoWidget->size()));
+ }
+ } else {
+ windowControl->setWinId(winId);
+ }
+}
+
bool QGraphicsVideoItemPrivate::eventFilter(QObject *object, QEvent *event)
{
if (windowControl && object == videoWidget && QEvent::WinIdChange == event->type()) {
@@ -152,7 +177,7 @@ void QGraphicsVideoItemPrivate::setWidget(QWidget *widget)
if (videoWidget != widget) {
videoWidget = widget;
if (widget) {
- windowControl->setWinId(widget->winId());
+ updateWindowId();
widget->installEventFilter(this);
}
}