source: trunk/src/gui/kernel/qeventdispatcher_s60.cpp@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 5.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <qwidget.h>
43
44#include "qeventdispatcher_s60_p.h"
45
46QT_BEGIN_NAMESPACE
47
48QtEikonEnv::QtEikonEnv()
49 : m_lastIterationCount(0)
50 , m_savedStatusCode(KRequestPending)
51 , m_hasAlreadyRun(false)
52{
53}
54
55QtEikonEnv::~QtEikonEnv()
56{
57}
58
59void QtEikonEnv::RunL()
60{
61 QEventDispatcherS60 *dispatcher = qobject_cast<QEventDispatcherS60 *>(QAbstractEventDispatcher::instance());
62 if (!dispatcher) {
63 CEikonEnv::RunL();
64 return;
65 }
66
67 if (m_lastIterationCount != dispatcher->iterationCount()) {
68 m_hasAlreadyRun = false;
69 m_lastIterationCount = dispatcher->iterationCount();
70 }
71
72 if (m_hasAlreadyRun) {
73 // Fool the active scheduler into believing we are still waiting for events.
74 // The window server thinks we are not, however.
75 m_savedStatusCode = iStatus.Int();
76 iStatus = KRequestPending;
77 SetActive();
78 dispatcher->queueDeferredActiveObjectsCompletion();
79 } else {
80 m_hasAlreadyRun = true;
81 CEikonEnv::RunL();
82 }
83}
84
85void QtEikonEnv::DoCancel()
86{
87 complete();
88
89 CEikonEnv::DoCancel();
90}
91
92void QtEikonEnv::complete()
93{
94 if (m_hasAlreadyRun) {
95 if (m_savedStatusCode != KRequestPending) {
96 TRequestStatus *status = &iStatus;
97 QEventDispatcherSymbian::RequestComplete(status, m_savedStatusCode);
98 m_savedStatusCode = KRequestPending;
99 }
100 m_hasAlreadyRun = false;
101 }
102}
103
104QEventDispatcherS60::QEventDispatcherS60(QObject *parent)
105 : QEventDispatcherSymbian(parent),
106 m_noInputEvents(false)
107{
108}
109
110QEventDispatcherS60::~QEventDispatcherS60()
111{
112 for (int c = 0; c < m_deferredInputEvents.size(); ++c) {
113 delete m_deferredInputEvents[c].event;
114 }
115}
116
117bool QEventDispatcherS60::processEvents ( QEventLoop::ProcessEventsFlags flags )
118{
119 bool ret = false;
120
121 QT_TRY {
122 bool oldNoInputEventsValue = m_noInputEvents;
123 if (flags & QEventLoop::ExcludeUserInputEvents) {
124 m_noInputEvents = true;
125 } else {
126 m_noInputEvents = false;
127 ret = sendDeferredInputEvents() || ret;
128 }
129
130 ret = QEventDispatcherSymbian::processEvents(flags) || ret;
131
132 m_noInputEvents = oldNoInputEventsValue;
133 } QT_CATCH (const std::exception& ex) {
134#ifndef QT_NO_EXCEPTIONS
135 CActiveScheduler::Current()->Error(qt_symbian_exception2Error(ex));
136#endif
137 }
138
139 return ret;
140}
141
142bool QEventDispatcherS60::hasPendingEvents()
143{
144 return !m_deferredInputEvents.isEmpty() || QEventDispatcherSymbian::hasPendingEvents();
145}
146
147void QEventDispatcherS60::saveInputEvent(QSymbianControl *control, QWidget *widget, QInputEvent *event)
148{
149 DeferredInputEvent inputEvent = {control, widget, event};
150 m_deferredInputEvents.append(inputEvent);
151 connect(widget, SIGNAL(destroyed(QObject*)), SLOT(removeInputEventsForWidget(QObject*)));
152}
153
154bool QEventDispatcherS60::sendDeferredInputEvents()
155{
156 bool eventsSent = false;
157 while (!m_deferredInputEvents.isEmpty()) {
158 DeferredInputEvent inputEvent = m_deferredInputEvents.takeFirst();
159#ifndef QT_NO_EXCEPTIONS
160 try {
161#endif
162 inputEvent.control->sendInputEvent(inputEvent.widget, inputEvent.event);
163#ifndef QT_NO_EXCEPTIONS
164 } catch (...) {
165 delete inputEvent.event;
166 throw;
167 }
168#endif
169 delete inputEvent.event;
170 eventsSent = true;
171 }
172
173 return eventsSent;
174}
175
176void QEventDispatcherS60::removeInputEventsForWidget(QObject *object)
177{
178 for (int c = 0; c < m_deferredInputEvents.size(); ++c) {
179 if (m_deferredInputEvents[c].widget == object) {
180 delete m_deferredInputEvents[c].event;
181 m_deferredInputEvents.removeAt(c--);
182 }
183 }
184}
185
186// reimpl
187void QEventDispatcherS60::reactivateDeferredActiveObjects()
188{
189 if (S60->qtOwnsS60Environment) {
190 static_cast<QtEikonEnv *>(CCoeEnv::Static())->complete();
191 }
192
193 QEventDispatcherSymbian::reactivateDeferredActiveObjects();
194}
195
196QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.