summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-11-02 12:45:11 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-11-03 08:13:14 +0000
commitd6cef755f6874190d144d4d574c3c0d78f38dec4 (patch)
tree99db93cd3012c8e25ad5bf1361903556ea8f8e54 /src
parent82c70bce11abea285a5e06a357da4c9434db0529 (diff)
Fix QVideoWidget::setFullScreen()
setFullScreen(true) would always cause the video widget to be shown on the primary screen instead of the current screen the app is being shown on. The reason for this is that setting the Qt::Window flag on the widget will cause its position to be interpreted as relative to the screen instead of its parent. This position is usually on the first screen, so showFullScreen() will show it there. Fix this by moving the video widget to the physical position on the screen that it had inside its widget hierarchy before calling showFullScreen(). Also restore that position on setFullScreen(false), so that its position is correctly restored even without layouts. Fixes: QTBUG-97895 Pick-to: 6.2 Change-Id: I5207afb276e9369938d1c3d8814d9878367c6895 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/multimediawidgets/qvideowidget.cpp8
-rw-r--r--src/multimediawidgets/qvideowidget_p.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp
index b3331be09..511489dd9 100644
--- a/src/multimediawidgets/qvideowidget.cpp
+++ b/src/multimediawidgets/qvideowidget.cpp
@@ -146,10 +146,16 @@ void QVideoWidget::setFullScreen(bool fullScreen)
Qt::WindowFlags flags = windowFlags();
if (fullScreen) {
+ // get the position of the widget in global coordinates
+ QPoint position = mapToGlobal(QPoint(0,0));
d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow);
+ d_ptr->nonFullscreenPos = pos();
flags |= Qt::Window;
flags &= ~Qt::SubWindow;
setWindowFlags(flags);
+ // move the widget to the position it had on screen, so that showFullScreen() will
+ // place it on the correct screen
+ move(position);
showFullScreen();
} else {
@@ -158,6 +164,8 @@ void QVideoWidget::setFullScreen(bool fullScreen)
setWindowFlags(flags);
showNormal();
+ move(d_ptr->nonFullscreenPos);
+ d_ptr->nonFullscreenPos = {};
}
d->wasFullScreen = fullScreen;
}
diff --git a/src/multimediawidgets/qvideowidget_p.h b/src/multimediawidgets/qvideowidget_p.h
index 4b75a4c84..9a79f58ed 100644
--- a/src/multimediawidgets/qvideowidget_p.h
+++ b/src/multimediawidgets/qvideowidget_p.h
@@ -71,6 +71,7 @@ public:
QVideoWindow *videoWindow = nullptr;
QWidget *windowContainer = nullptr;
+ QPoint nonFullscreenPos;
bool createBackend();
};