| 1 | /* This file is part of the KDE project.
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 |
|
|---|
| 5 | This library is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU Lesser General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 2.1 or 3 of the License.
|
|---|
| 8 |
|
|---|
| 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
|
|---|
| 12 | GNU Lesser General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU Lesser General Public License
|
|---|
| 15 | along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 16 |
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect
|
|---|
| 20 | #include <QtGui/private/qwidget_p.h> // to access QWExtra
|
|---|
| 21 | #include <QResizeEvent>
|
|---|
| 22 | #include <QMoveEvent>
|
|---|
| 23 |
|
|---|
| 24 | #include <coemain.h> // for CCoeEnv
|
|---|
| 25 |
|
|---|
| 26 | #include "ancestormovemonitor.h"
|
|---|
| 27 | #include "utils.h"
|
|---|
| 28 | #include "videooutput_dsa.h"
|
|---|
| 29 |
|
|---|
| 30 | QT_BEGIN_NAMESPACE
|
|---|
| 31 |
|
|---|
| 32 | using namespace Phonon;
|
|---|
| 33 | using namespace Phonon::MMF;
|
|---|
| 34 |
|
|---|
| 35 | DsaVideoOutput::DsaVideoOutput(QWidget *parent)
|
|---|
| 36 | : AbstractVideoOutput(parent)
|
|---|
| 37 | , m_ancestorMoveMonitor(0)
|
|---|
| 38 | {
|
|---|
| 39 | TRACE_CONTEXT(DsaVideoOutput::DsaVideoOutput, EVideoInternal);
|
|---|
| 40 | TRACE_ENTRY("parent 0x%08x", parent);
|
|---|
| 41 |
|
|---|
| 42 | setPalette(QPalette(Qt::black));
|
|---|
| 43 | setAttribute(Qt::WA_OpaquePaintEvent, true);
|
|---|
| 44 | setAttribute(Qt::WA_NoSystemBackground, true);
|
|---|
| 45 | setAutoFillBackground(false);
|
|---|
| 46 |
|
|---|
| 47 | qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill;
|
|---|
| 48 | qt_widget_private(this)->extraData()->receiveNativePaintEvents = true;
|
|---|
| 49 |
|
|---|
| 50 | getVideoWindowScreenRect();
|
|---|
| 51 |
|
|---|
| 52 | dump();
|
|---|
| 53 |
|
|---|
| 54 | TRACE_EXIT_0();
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | DsaVideoOutput::~DsaVideoOutput()
|
|---|
| 58 | {
|
|---|
| 59 | TRACE_CONTEXT(DsaVideoOutput::~DsaVideoOutput, EVideoInternal);
|
|---|
| 60 | TRACE_ENTRY_0();
|
|---|
| 61 |
|
|---|
| 62 | m_ancestorMoveMonitor->unRegisterTarget(this);
|
|---|
| 63 |
|
|---|
| 64 | TRACE_EXIT_0();
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | //-----------------------------------------------------------------------------
|
|---|
| 68 | // Public functions
|
|---|
| 69 | //-----------------------------------------------------------------------------
|
|---|
| 70 |
|
|---|
| 71 | void MMF::DsaVideoOutput::setAncestorMoveMonitor(AncestorMoveMonitor *monitor)
|
|---|
| 72 | {
|
|---|
| 73 | m_ancestorMoveMonitor = monitor;
|
|---|
| 74 | registerForAncestorMoved();
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | const QRect& MMF::DsaVideoOutput::videoWindowScreenRect() const
|
|---|
| 78 | {
|
|---|
| 79 | return m_videoWindowScreenRect;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | void MMF::DsaVideoOutput::ancestorMoved()
|
|---|
| 83 | {
|
|---|
| 84 | TRACE_CONTEXT(DsaVideoOutput::ancestorMoved, EVideoInternal);
|
|---|
| 85 | TRACE_ENTRY_0();
|
|---|
| 86 |
|
|---|
| 87 | RWindowBase *const window = videoWindow();
|
|---|
| 88 |
|
|---|
| 89 | if (window) {
|
|---|
| 90 | const TPoint newWindowPosSymbian = window->AbsPosition();
|
|---|
| 91 | const QPoint newWindowPos(newWindowPosSymbian.iX, newWindowPosSymbian.iY);
|
|---|
| 92 |
|
|---|
| 93 | if (newWindowPos != m_videoWindowScreenRect.topLeft()) {
|
|---|
| 94 | m_videoWindowScreenRect.moveTo(newWindowPos);
|
|---|
| 95 | emit videoWindowScreenRectChanged();
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | TRACE_EXIT_0();
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | void MMF::DsaVideoOutput::beginNativePaintEvent(const QRect & /*controlRect*/)
|
|---|
| 103 | {
|
|---|
| 104 | TRACE_CONTEXT(DsaVideoOutput::beginNativePaintEvent, EVideoInternal);
|
|---|
| 105 | TRACE_ENTRY_0();
|
|---|
| 106 |
|
|---|
| 107 | emit beginVideoWindowNativePaint();
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | void MMF::DsaVideoOutput::endNativePaintEvent(const QRect & /*controlRect*/)
|
|---|
| 111 | {
|
|---|
| 112 | TRACE_CONTEXT(DsaVideoOutput::endNativePaintEvent, EVideoInternal);
|
|---|
| 113 | TRACE_ENTRY_0();
|
|---|
| 114 |
|
|---|
| 115 | // Ensure that draw ops are executed into the WSERV output framebuffer
|
|---|
| 116 | CCoeEnv::Static()->WsSession().Flush();
|
|---|
| 117 |
|
|---|
| 118 | emit endVideoWindowNativePaint();
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | //-----------------------------------------------------------------------------
|
|---|
| 122 | // Private functions
|
|---|
| 123 | //-----------------------------------------------------------------------------
|
|---|
| 124 |
|
|---|
| 125 | void MMF::DsaVideoOutput::getVideoWindowScreenRect()
|
|---|
| 126 | {
|
|---|
| 127 | RWindowBase *const window = videoWindow();
|
|---|
| 128 | if (window)
|
|---|
| 129 | m_videoWindowScreenRect =
|
|---|
| 130 | qt_TRect2QRect(TRect(window->AbsPosition(), window->Size()));
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | void MMF::DsaVideoOutput::registerForAncestorMoved()
|
|---|
| 134 | {
|
|---|
| 135 | m_ancestorMoveMonitor->registerTarget(this);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | void MMF::DsaVideoOutput::resizeEvent(QResizeEvent *event)
|
|---|
| 139 | {
|
|---|
| 140 | TRACE_CONTEXT(DsaVideoOutput::resizeEvent, EVideoInternal);
|
|---|
| 141 | TRACE("%d %d -> %d %d",
|
|---|
| 142 | event->oldSize().width(), event->oldSize().height(),
|
|---|
| 143 | event->size().width(), event->size().height());
|
|---|
| 144 |
|
|---|
| 145 | if (event->size() != event->oldSize()) {
|
|---|
| 146 | m_videoWindowScreenRect.setSize(event->size());
|
|---|
| 147 | emit videoWindowScreenRectChanged();
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | void MMF::DsaVideoOutput::moveEvent(QMoveEvent *event)
|
|---|
| 152 | {
|
|---|
| 153 | TRACE_CONTEXT(DsaVideoOutput::moveEvent, EVideoInternal);
|
|---|
| 154 | TRACE("%d %d -> %d %d",
|
|---|
| 155 | event->oldPos().x(), event->oldPos().y(),
|
|---|
| 156 | event->pos().x(), event->pos().y());
|
|---|
| 157 |
|
|---|
| 158 | if (event->pos() != event->oldPos()) {
|
|---|
| 159 | m_videoWindowScreenRect.moveTo(event->pos());
|
|---|
| 160 | emit videoWindowScreenRectChanged();
|
|---|
| 161 | }
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | bool MMF::DsaVideoOutput::event(QEvent *event)
|
|---|
| 165 | {
|
|---|
| 166 | TRACE_CONTEXT(DsaVideoOutput::event, EVideoInternal);
|
|---|
| 167 |
|
|---|
| 168 | if (event->type() == QEvent::WinIdChange) {
|
|---|
| 169 | TRACE_0("WinIdChange");
|
|---|
| 170 | getVideoWindowScreenRect();
|
|---|
| 171 | emit videoWindowChanged();
|
|---|
| 172 | return true;
|
|---|
| 173 | } else if (event->type() == QEvent::ParentChange) {
|
|---|
| 174 | // Tell ancestor move monitor to update ancestor list for this widget
|
|---|
| 175 | registerForAncestorMoved();
|
|---|
| 176 | return true;
|
|---|
| 177 | } else {
|
|---|
| 178 | return QWidget::event(event);
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | QT_END_NAMESPACE
|
|---|
| 183 |
|
|---|