QVideoWidget: fixed setFullScreen(false) on the Xcb platform.
authorYoann Lopes <yoann.lopes@digia.com>
Fri, 28 Sep 2012 15:53:11 +0000 (17:53 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 1 Oct 2012 07:31:28 +0000 (09:31 +0200)
Fixed exiting fullscreen when a QVideoWidget is embedded in another QWidget.
Requires change I3616dc0f in qtbase to work.
Because of a bug in some X window managers, the order in which
setWindowFlags() and showNormal() are called has been changed.

Change-Id: I335d47a3a1d9ce517978cad35597d72312150db1
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
examples/player/videowidget.cpp
src/multimediawidgets/qvideowidget.cpp

index 0b2d709..1dfbf94 100644 (file)
@@ -57,7 +57,7 @@ VideoWidget::VideoWidget(QWidget *parent)
 void VideoWidget::keyPressEvent(QKeyEvent *event)
 {
     if (event->key() == Qt::Key_Escape && isFullScreen()) {
-        showNormal();
+        setFullScreen(false);
 
         event->accept();
     } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
index a5670d2..031193d 100644 (file)
@@ -720,9 +720,9 @@ void QVideoWidget::setFullScreen(bool fullScreen)
 {
     Q_D(QVideoWidget);
 
-    if (fullScreen) {
-        Qt::WindowFlags flags = windowFlags();
+    Qt::WindowFlags flags = windowFlags();
 
+    if (fullScreen) {
         d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow);
         flags |= Qt::Window;
         flags &= ~Qt::SubWindow;
@@ -730,6 +730,10 @@ void QVideoWidget::setFullScreen(bool fullScreen)
 
         showFullScreen();
     } else {
+        flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags...
+        flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow)
+        setWindowFlags(flags);
+
         showNormal();
     }
 }
@@ -910,13 +914,8 @@ bool QVideoWidget::event(QEvent *event)
             if (d->currentControl)
                 d->currentControl->setFullScreen(false);
 
-            if (d->wasFullScreen) {
-                flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags...
-                flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow)
-                setWindowFlags(flags);
-
+            if (d->wasFullScreen)
                 emit fullScreenChanged(d->wasFullScreen = false);
-            }
         }
     }
     return QWidget::event(event);