2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #include "PlatformVideoWindow.h"
23 #include "HTMLVideoElement.h"
24 #include "PlatformVideoWindowPrivate.h"
27 #include <QGuiApplication>
31 using namespace WebCore;
34 static const int gHideMouseCursorDelay = 3000;
37 FullScreenVideoWindow::FullScreenVideoWindow()
40 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
41 setAttribute(Qt::WA_NativeWindow);
42 setAttribute(Qt::WA_NoSystemBackground, true);
43 setAttribute(Qt::WA_PaintOnScreen, true);
45 setWindowModality(Qt::ApplicationModal);
48 m_cursorTimer.setSingleShot(true);
49 connect(&m_cursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor()));
53 void FullScreenVideoWindow::setVideoElement(HTMLVideoElement* element)
55 m_mediaElement = element;
58 void FullScreenVideoWindow::keyPressEvent(QKeyEvent* ev)
60 if (m_mediaElement && ev->key() == Qt::Key_Space) {
61 if (!m_mediaElement->paused())
62 m_mediaElement->pause();
64 m_mediaElement->play();
65 } else if (ev->key() == Qt::Key_Escape)
67 Base::keyPressEvent(ev);
70 bool FullScreenVideoWindow::event(QEvent* ev)
73 case QEvent::MouseMove:
77 case QEvent::MouseButtonDblClick:
85 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
86 setMouseTracking(false);
90 QGuiApplication::restoreOverrideCursor();
96 return Base::event(ev);
99 void FullScreenVideoWindow::showFullScreen()
101 Base::showFullScreen();
102 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
103 setMouseTracking(true);
106 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
112 void FullScreenVideoWindow::hideCursor()
115 QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
119 void FullScreenVideoWindow::showCursor()
122 QGuiApplication::restoreOverrideCursor();
123 m_cursorTimer.start(gHideMouseCursorDelay);
128 PlatformVideoWindow::PlatformVideoWindow()
130 Base* win = new FullScreenVideoWindow();
132 win->setWindowFlags(win->windowFlags() | Qt::FramelessWindowHint);
133 // FIXME: Port to Qt 5.
134 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
136 p.setColor(QPalette::Base, Qt::black);
137 p.setColor(QPalette::Window, Qt::black);
140 win->showFullScreen();
141 m_videoWindowId = win->winId();
144 PlatformVideoWindow::~PlatformVideoWindow()
150 void PlatformVideoWindow::prepareForOverlay(GstMessage*)