author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 14:24:45 +0300 | |
changeset 25 | e24348a560a6 |
parent 23 | 89e065397ea6 |
child 29 | b72c6db6890b |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qapplication_p.h" |
|
43 |
#include "qsessionmanager.h" |
|
44 |
#include "qevent.h" |
|
45 |
#include "qsymbianevent.h" |
|
46 |
#include "qeventdispatcher_s60_p.h" |
|
47 |
#include "qwidget.h" |
|
48 |
#include "qdesktopwidget.h" |
|
49 |
#include "private/qbackingstore_p.h" |
|
50 |
#include "qt_s60_p.h" |
|
51 |
#include "private/qevent_p.h" |
|
52 |
#include "qstring.h" |
|
53 |
#include "qdebug.h" |
|
54 |
#include "qimage.h" |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
55 |
#include "qcombobox.h" |
0 | 56 |
#include "private/qkeymapper_p.h" |
57 |
#include "private/qfont_p.h" |
|
58 |
#ifndef QT_NO_STYLE_S60 |
|
59 |
#include "private/qs60style_p.h" |
|
60 |
#endif |
|
61 |
#include "private/qwindowsurface_s60_p.h" |
|
62 |
#include "qpaintengine.h" |
|
63 |
#include "private/qmenubar_p.h" |
|
64 |
#include "private/qsoftkeymanager_p.h" |
|
65 |
||
66 |
#include "apgwgnam.h" // For CApaWindowGroupName |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
#include <mdaaudiotoneplayer.h> // For CMdaAudioToneUtility |
0 | 68 |
|
69 |
#if defined(Q_WS_S60) |
|
70 |
# if !defined(QT_NO_IM) |
|
71 |
# include "qinputcontext.h" |
|
72 |
# include <private/qcoefepinputcontext_p.h> |
|
73 |
# endif |
|
74 |
# include <private/qs60mainapplication_p.h> |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
75 |
# include <centralrepository.h> |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
76 |
# include "qs60mainappui.h" |
0 | 77 |
#endif |
78 |
||
79 |
#include "private/qstylesheetstyle_p.h" |
|
80 |
||
81 |
#include <hal.h> |
|
82 |
#include <hal_data.h> |
|
83 |
||
84 |
QT_BEGIN_NAMESPACE |
|
85 |
||
86 |
#if defined(QT_DEBUG) |
|
87 |
static bool appNoGrab = false; // Grabbing enabled |
|
88 |
#endif |
|
89 |
static bool app_do_modal = false; // modal mode |
|
90 |
Q_GLOBAL_STATIC(QS60Data, qt_s60Data); |
|
91 |
||
92 |
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*); |
|
93 |
extern QWidgetList *qt_modal_stack; // stack of modal widgets |
|
94 |
extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp |
|
95 |
||
96 |
QWidget *qt_button_down = 0; // widget got last button-down |
|
97 |
||
98 |
QSymbianControl *QSymbianControl::lastFocusedControl = 0; |
|
99 |
||
100 |
QS60Data* qGlobalS60Data() |
|
101 |
{ |
|
102 |
return qt_s60Data(); |
|
103 |
} |
|
104 |
||
105 |
bool qt_nograb() // application no-grab option |
|
106 |
{ |
|
107 |
#if defined(QT_DEBUG) |
|
108 |
return appNoGrab; |
|
109 |
#else |
|
110 |
return false; |
|
111 |
#endif |
|
112 |
} |
|
113 |
||
114 |
// Modified from http://www3.symbian.com/faq.nsf/0/0F1464EE96E737E780256D5E00503DD1?OpenDocument |
|
115 |
class QS60Beep : public CBase, public MMdaAudioToneObserver |
|
116 |
{ |
|
117 |
public: |
|
118 |
static QS60Beep* NewL(TInt aFrequency, TTimeIntervalMicroSeconds iDuration); |
|
119 |
void Play(); |
|
120 |
~QS60Beep(); |
|
121 |
private: |
|
122 |
void ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds iDuration); |
|
123 |
void MatoPrepareComplete(TInt aError); |
|
124 |
void MatoPlayComplete(TInt aError); |
|
125 |
private: |
|
126 |
typedef enum |
|
127 |
{ |
|
128 |
EBeepNotPrepared, |
|
129 |
EBeepPrepared, |
|
130 |
EBeepPlaying |
|
131 |
} TBeepState; |
|
132 |
private: |
|
133 |
CMdaAudioToneUtility* iToneUtil; |
|
134 |
TBeepState iState; |
|
135 |
TInt iFrequency; |
|
136 |
TTimeIntervalMicroSeconds iDuration; |
|
137 |
}; |
|
138 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
static QS60Beep* qt_S60Beep = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
|
0 | 141 |
QS60Beep::~QS60Beep() |
142 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
if (iToneUtil) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
switch (iState) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
case EBeepPlaying: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
iToneUtil->CancelPlay(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
case EBeepNotPrepared: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
iToneUtil->CancelPrepare(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
} |
0 | 153 |
delete iToneUtil; |
154 |
} |
|
155 |
||
156 |
QS60Beep* QS60Beep::NewL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
|
157 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
158 |
QS60Beep* self = new (ELeave) QS60Beep(); |
0 | 159 |
CleanupStack::PushL(self); |
160 |
self->ConstructL(aFrequency, aDuration); |
|
161 |
CleanupStack::Pop(); |
|
162 |
return self; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
} |
0 | 164 |
|
165 |
void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
|
166 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
iToneUtil = CMdaAudioToneUtility::NewL(*this); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
iState = EBeepNotPrepared; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
iFrequency = aFrequency; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
iDuration = aDuration; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
iToneUtil->PrepareToPlayTone(iFrequency, iDuration); |
0 | 172 |
} |
173 |
||
174 |
void QS60Beep::Play() |
|
175 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
if (iState == EBeepPlaying) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
iToneUtil->CancelPlay(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
iState = EBeepPrepared; |
0 | 179 |
} |
180 |
||
181 |
iToneUtil->Play(); |
|
182 |
iState = EBeepPlaying; |
|
183 |
} |
|
184 |
||
185 |
void QS60Beep::MatoPrepareComplete(TInt aError) |
|
186 |
{ |
|
187 |
if (aError == KErrNone) { |
|
188 |
iState = EBeepPrepared; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
Play(); |
0 | 190 |
} |
191 |
} |
|
192 |
||
193 |
void QS60Beep::MatoPlayComplete(TInt aError) |
|
194 |
{ |
|
195 |
Q_UNUSED(aError); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
iState = EBeepPrepared; |
0 | 197 |
} |
198 |
||
199 |
||
200 |
QHash<TInt, TUint> QApplicationPrivate::scanCodeCache; |
|
201 |
||
202 |
static Qt::KeyboardModifiers mapToQtModifiers(TUint s60Modifiers) |
|
203 |
{ |
|
204 |
Qt::KeyboardModifiers result = Qt::NoModifier; |
|
205 |
||
206 |
if (s60Modifiers & EModifierKeypad) |
|
207 |
result |= Qt::KeypadModifier; |
|
208 |
if (s60Modifiers & EModifierShift || s60Modifiers & EModifierLeftShift |
|
209 |
|| s60Modifiers & EModifierRightShift) |
|
210 |
result |= Qt::ShiftModifier; |
|
211 |
if (s60Modifiers & EModifierCtrl || s60Modifiers & EModifierLeftCtrl |
|
212 |
|| s60Modifiers & EModifierRightCtrl) |
|
213 |
result |= Qt::ControlModifier; |
|
214 |
if (s60Modifiers & EModifierAlt || s60Modifiers & EModifierLeftAlt |
|
215 |
|| s60Modifiers & EModifierRightAlt) |
|
216 |
result |= Qt::AltModifier; |
|
217 |
||
218 |
return result; |
|
219 |
} |
|
220 |
||
221 |
static void mapS60MouseEventTypeToQt(QEvent::Type *type, Qt::MouseButton *button, const TPointerEvent *pEvent) |
|
222 |
{ |
|
223 |
switch (pEvent->iType) { |
|
224 |
case TPointerEvent::EButton1Down: |
|
225 |
*type = QEvent::MouseButtonPress; |
|
226 |
*button = Qt::LeftButton; |
|
227 |
break; |
|
228 |
case TPointerEvent::EButton1Up: |
|
229 |
*type = QEvent::MouseButtonRelease; |
|
230 |
*button = Qt::LeftButton; |
|
231 |
break; |
|
232 |
case TPointerEvent::EButton2Down: |
|
233 |
*type = QEvent::MouseButtonPress; |
|
234 |
*button = Qt::MidButton; |
|
235 |
break; |
|
236 |
case TPointerEvent::EButton2Up: |
|
237 |
*type = QEvent::MouseButtonRelease; |
|
238 |
*button = Qt::MidButton; |
|
239 |
break; |
|
240 |
case TPointerEvent::EButton3Down: |
|
241 |
*type = QEvent::MouseButtonPress; |
|
242 |
*button = Qt::RightButton; |
|
243 |
break; |
|
244 |
case TPointerEvent::EButton3Up: |
|
245 |
*type = QEvent::MouseButtonRelease; |
|
246 |
*button = Qt::RightButton; |
|
247 |
break; |
|
248 |
case TPointerEvent::EDrag: |
|
249 |
*type = QEvent::MouseMove; |
|
250 |
*button = Qt::NoButton; |
|
251 |
break; |
|
252 |
case TPointerEvent::EMove: |
|
253 |
// Qt makes no distinction between move and drag |
|
254 |
*type = QEvent::MouseMove; |
|
255 |
*button = Qt::NoButton; |
|
256 |
break; |
|
257 |
default: |
|
258 |
*type = QEvent::None; |
|
259 |
*button = Qt::NoButton; |
|
260 |
break; |
|
261 |
} |
|
262 |
if (pEvent->iModifiers & EModifierDoubleClick){ |
|
263 |
*type = QEvent::MouseButtonDblClick; |
|
264 |
} |
|
265 |
||
266 |
if (*type == QEvent::MouseButtonPress || *type == QEvent::MouseButtonDblClick) |
|
267 |
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons | (*button); |
|
268 |
else if (*type == QEvent::MouseButtonRelease) |
|
269 |
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons &(~(*button)); |
|
270 |
||
271 |
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons & Qt::MouseButtonMask; |
|
272 |
} |
|
273 |
||
274 |
//### Can be replaced with CAknLongTapDetector if animation is required. |
|
275 |
//NOTE: if CAknLongTapDetector is used make sure it gets variated out of 3.1 and 3.2,. |
|
276 |
//also MLongTapObserver needs to be changed to MAknLongTapDetectorCallBack if CAknLongTapDetector is used. |
|
277 |
class QLongTapTimer : public CTimer |
|
278 |
{ |
|
279 |
public: |
|
280 |
static QLongTapTimer* NewL(QAbstractLongTapObserver *observer); |
|
281 |
QLongTapTimer(QAbstractLongTapObserver *observer); |
|
282 |
void ConstructL(); |
|
283 |
public: |
|
284 |
void PointerEventL(const TPointerEvent &event); |
|
285 |
void RunL(); |
|
286 |
protected: |
|
287 |
private: |
|
288 |
QAbstractLongTapObserver *m_observer; |
|
289 |
TPointerEvent m_event; |
|
290 |
QPoint m_pressedCoordinates; |
|
291 |
int m_dragDistance; |
|
292 |
}; |
|
293 |
||
294 |
QLongTapTimer* QLongTapTimer::NewL(QAbstractLongTapObserver *observer) |
|
295 |
{ |
|
296 |
QLongTapTimer* self = new QLongTapTimer(observer); |
|
297 |
self->ConstructL(); |
|
298 |
return self; |
|
299 |
} |
|
300 |
void QLongTapTimer::ConstructL() |
|
301 |
{ |
|
302 |
CTimer::ConstructL(); |
|
303 |
} |
|
304 |
||
305 |
QLongTapTimer::QLongTapTimer(QAbstractLongTapObserver *observer):CTimer(CActive::EPriorityHigh) |
|
306 |
{ |
|
307 |
m_observer = observer; |
|
308 |
m_dragDistance = qApp->startDragDistance(); |
|
309 |
CActiveScheduler::Add(this); |
|
310 |
} |
|
311 |
||
312 |
void QLongTapTimer::PointerEventL(const TPointerEvent& event) |
|
313 |
{ |
|
314 |
if ( event.iType == TPointerEvent::EDrag || event.iType == TPointerEvent::EButtonRepeat) |
|
315 |
{ |
|
316 |
QPoint diff(QPoint(event.iPosition.iX,event.iPosition.iY) - m_pressedCoordinates); |
|
317 |
if (diff.manhattanLength() < m_dragDistance) |
|
318 |
return; |
|
319 |
} |
|
320 |
Cancel(); |
|
321 |
m_event = event; |
|
322 |
if (event.iType == TPointerEvent::EButton1Down) |
|
323 |
{ |
|
324 |
m_pressedCoordinates = QPoint(event.iPosition.iX,event.iPosition.iY); |
|
325 |
// must be same as KLongTapDelay in aknlongtapdetector.h |
|
326 |
After(800000); |
|
327 |
} |
|
328 |
} |
|
329 |
void QLongTapTimer::RunL() |
|
330 |
{ |
|
331 |
if (m_observer) |
|
332 |
m_observer->HandleLongTapEventL(m_event.iPosition, m_event.iParentPosition); |
|
333 |
} |
|
334 |
||
335 |
QSymbianControl::QSymbianControl(QWidget *w) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
: CCoeControl() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
, qwidget(w) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
, m_longTapDetector(0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
, m_ignoreFocusChanged(0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
, m_symbianPopupIsOpen(0) |
0 | 341 |
{ |
342 |
} |
|
343 |
||
344 |
void QSymbianControl::ConstructL(bool isWindowOwning, bool desktop) |
|
345 |
{ |
|
346 |
if (!desktop) |
|
347 |
{ |
|
348 |
if (isWindowOwning or !qwidget->parentWidget()) |
|
349 |
CreateWindowL(S60->windowGroup()); |
|
350 |
else |
|
351 |
/** |
|
352 |
* TODO: in order to avoid creating windows for all ancestors of |
|
353 |
* this widget up to the root window, the parameter passed to |
|
354 |
* CreateWindowL should be |
|
355 |
* qwidget->parentWidget()->effectiveWinId(). However, if we do |
|
356 |
* this, then we need to take care of re-parenting when a window |
|
357 |
* is created for a widget between this one and the root window. |
|
358 |
*/ |
|
359 |
CreateWindowL(qwidget->parentWidget()->winId()); |
|
360 |
||
361 |
// Necessary in order to be able to track the activation status of |
|
362 |
// the control's window |
|
363 |
qwidget->d_func()->createExtra(); |
|
364 |
||
365 |
SetFocusing(true); |
|
366 |
m_longTapDetector = QLongTapTimer::NewL(this); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
DrawableWindow()->SetPointerGrab(ETrue); |
0 | 369 |
} |
370 |
} |
|
371 |
||
372 |
QSymbianControl::~QSymbianControl() |
|
373 |
{ |
|
374 |
if (S60->curWin == this) |
|
375 |
S60->curWin = 0; |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
376 |
if (!QApplicationPrivate::is_app_closing) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
377 |
QT_TRY { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
378 |
setFocusSafely(false); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
379 |
} QT_CATCH(const std::exception&) { |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
380 |
// ignore exceptions, nothing can be done |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
381 |
} |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
382 |
} |
0 | 383 |
S60->appUi()->RemoveFromStack(this); |
384 |
delete m_longTapDetector; |
|
385 |
} |
|
386 |
||
387 |
void QSymbianControl::setWidget(QWidget *w) |
|
388 |
{ |
|
389 |
qwidget = w; |
|
390 |
} |
|
391 |
void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ) |
|
392 |
{ |
|
393 |
QWidget *alienWidget; |
|
394 |
QPoint widgetPos = QPoint(aPenEventLocation.iX, aPenEventLocation.iY); |
|
395 |
QPoint globalPos = QPoint(aPenEventScreenLocation.iX,aPenEventScreenLocation.iY); |
|
396 |
alienWidget = qwidget->childAt(widgetPos); |
|
397 |
if (!alienWidget) |
|
398 |
alienWidget = qwidget; |
|
399 |
||
400 |
#if !defined(QT_NO_CONTEXTMENU) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
QContextMenuEvent contextMenuEvent(QContextMenuEvent::Mouse, widgetPos, globalPos, Qt::NoModifier); |
0 | 402 |
qt_sendSpontaneousEvent(alienWidget, &contextMenuEvent); |
403 |
#endif |
|
404 |
} |
|
405 |
||
406 |
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
|
407 |
void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent *event) |
|
408 |
{ |
|
409 |
QApplicationPrivate *d = QApplicationPrivate::instance(); |
|
410 |
||
411 |
QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget); |
|
412 |
||
413 |
while (d->appAllTouchPoints.count() <= event->PointerNumber()) |
|
414 |
d->appAllTouchPoints.append(QTouchEvent::TouchPoint(d->appAllTouchPoints.count())); |
|
415 |
||
416 |
Qt::TouchPointStates allStates = 0; |
|
417 |
for (int i = 0; i < d->appAllTouchPoints.count(); ++i) { |
|
418 |
QTouchEvent::TouchPoint &touchPoint = d->appAllTouchPoints[i]; |
|
419 |
||
420 |
if (touchPoint.id() == event->PointerNumber()) { |
|
421 |
Qt::TouchPointStates state; |
|
422 |
switch (event->iType) { |
|
423 |
case TPointerEvent::EButton1Down: |
|
424 |
case TPointerEvent::EEnterHighPressure: |
|
425 |
state = Qt::TouchPointPressed; |
|
426 |
break; |
|
427 |
case TPointerEvent::EButton1Up: |
|
428 |
case TPointerEvent::EExitCloseProximity: |
|
429 |
state = Qt::TouchPointReleased; |
|
430 |
break; |
|
431 |
case TPointerEvent::EDrag: |
|
432 |
state = Qt::TouchPointMoved; |
|
433 |
break; |
|
434 |
default: |
|
435 |
// how likely is this to happen? |
|
436 |
state = Qt::TouchPointStationary; |
|
437 |
break; |
|
438 |
} |
|
439 |
if (event->PointerNumber() == 0) |
|
440 |
state |= Qt::TouchPointPrimary; |
|
441 |
touchPoint.setState(state); |
|
442 |
||
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
443 |
QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); |
0 | 444 |
touchPoint.setScreenPos(screenPos); |
445 |
touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), |
|
446 |
screenPos.y() / screenGeometry.height())); |
|
447 |
||
448 |
touchPoint.setPressure(event->Pressure() / qreal(d->maxTouchPressure)); |
|
449 |
} else if (touchPoint.state() != Qt::TouchPointReleased) { |
|
450 |
// all other active touch points should be marked as stationary |
|
451 |
touchPoint.setState(Qt::TouchPointStationary); |
|
452 |
} |
|
453 |
||
454 |
allStates |= touchPoint.state(); |
|
455 |
} |
|
456 |
||
457 |
if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) { |
|
458 |
// all touch points released |
|
459 |
d->appAllTouchPoints.clear(); |
|
460 |
} |
|
461 |
||
462 |
QApplicationPrivate::translateRawTouchEvent(qwidget, |
|
463 |
QTouchEvent::TouchScreen, |
|
464 |
d->appAllTouchPoints); |
|
465 |
} |
|
466 |
#endif |
|
467 |
||
468 |
void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) |
|
469 |
{ |
|
470 |
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
|
471 |
if (pEvent.IsAdvancedPointerEvent()) { |
|
472 |
const TAdvancedPointerEvent *advancedPointerEvent = pEvent.AdvancedPointerEvent(); |
|
473 |
translateAdvancedPointerEvent(advancedPointerEvent); |
|
474 |
if (advancedPointerEvent->PointerNumber() != 0) { |
|
475 |
// only send mouse events for the first touch point |
|
476 |
return; |
|
477 |
} |
|
478 |
} |
|
479 |
#endif |
|
480 |
||
481 |
m_longTapDetector->PointerEventL(pEvent); |
|
482 |
QT_TRYCATCH_LEAVING(HandlePointerEvent(pEvent)); |
|
483 |
} |
|
484 |
||
485 |
void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) |
|
486 |
{ |
|
487 |
QMouseEvent::Type type; |
|
488 |
Qt::MouseButton button; |
|
489 |
mapS60MouseEventTypeToQt(&type, &button, &pEvent); |
|
490 |
Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers); |
|
491 |
||
492 |
QPoint widgetPos = QPoint(pEvent.iPosition.iX, pEvent.iPosition.iY); |
|
493 |
TPoint controlScreenPos = PositionRelativeToScreen(); |
|
494 |
QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
S60->lastCursorPos = globalPos; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
S60->lastPointerEventPos = widgetPos; |
0 | 497 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
QWidget *mouseGrabber = QWidget::mouseGrabber(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
QWidget *popupWidget = qApp->activePopupWidget(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
QWidget *popupReceiver = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
if (popupWidget) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
QWidget *popupChild = popupWidget->childAt(popupWidget->mapFromGlobal(globalPos)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
popupReceiver = popupChild ? popupChild : popupWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
506 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
if (mouseGrabber) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
if (popupReceiver) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
509 |
sendMouseEvent(popupReceiver, type, globalPos, button, modifiers); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
511 |
sendMouseEvent(mouseGrabber, type, globalPos, button, modifiers); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
512 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
513 |
// No Enter/Leave events in grabbing mode. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
514 |
return; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
515 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
516 |
|
0 | 517 |
QWidget *widgetUnderPointer = qwidget->childAt(widgetPos); |
518 |
if (!widgetUnderPointer) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
519 |
widgetUnderPointer = qwidget; |
0 | 520 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
521 |
QApplicationPrivate::dispatchEnterLeave(widgetUnderPointer, S60->lastPointerEventTarget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
522 |
S60->lastPointerEventTarget = widgetUnderPointer; |
0 | 523 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
524 |
QWidget *receiver; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
if (!popupReceiver && S60->mousePressTarget && type != QEvent::MouseButtonPress) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
receiver = S60->mousePressTarget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
527 |
if (type == QEvent::MouseButtonRelease) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
528 |
S60->mousePressTarget = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
530 |
receiver = popupReceiver ? popupReceiver : widgetUnderPointer; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
531 |
if (type == QEvent::MouseButtonPress) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
532 |
S60->mousePressTarget = receiver; |
0 | 533 |
} |
534 |
||
535 |
#if !defined(QT_NO_CURSOR) && !defined(Q_SYMBIAN_FIXED_POINTER_CURSORS) |
|
536 |
if (S60->brokenPointerCursors) |
|
537 |
qt_symbian_move_cursor_sprite(); |
|
538 |
#endif |
|
539 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
540 |
sendMouseEvent(receiver, type, globalPos, button, modifiers); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
541 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
542 |
|
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
543 |
#ifdef Q_WS_S60 |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
544 |
void QSymbianControl::HandleStatusPaneSizeChange() |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
545 |
{ |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
546 |
QS60MainAppUi *s60AppUi = static_cast<QS60MainAppUi *>(S60->appUi()); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
547 |
s60AppUi->HandleStatusPaneSizeChange(); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
548 |
} |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
549 |
#endif |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
550 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
551 |
void QSymbianControl::sendMouseEvent( |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
552 |
QWidget *receiver, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
553 |
QEvent::Type type, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
554 |
const QPoint &globalPos, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
555 |
Qt::MouseButton button, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
556 |
Qt::KeyboardModifiers modifiers) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
Q_ASSERT(receiver); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
QMouseEvent mEvent(type, receiver->mapFromGlobal(globalPos), globalPos, |
0 | 560 |
button, QApplicationPrivate::mouse_buttons, modifiers); |
561 |
QEventDispatcherS60 *dispatcher; |
|
562 |
// It is theoretically possible for someone to install a different event dispatcher. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(receiver->d_func()->threadData->eventDispatcher)) != 0) { |
0 | 564 |
if (dispatcher->excludeUserInputEvents()) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
dispatcher->saveInputEvent(this, receiver, new QMouseEvent(mEvent)); |
0 | 566 |
return; |
567 |
} |
|
568 |
} |
|
569 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
sendMouseEvent(receiver, &mEvent); |
0 | 571 |
} |
572 |
||
573 |
bool QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent) |
|
574 |
{ |
|
575 |
return qt_sendSpontaneousEvent(widget, mEvent); |
|
576 |
} |
|
577 |
||
578 |
TKeyResponse QSymbianControl::OfferKeyEventL(const TKeyEvent& keyEvent, TEventCode type) |
|
579 |
{ |
|
580 |
TKeyResponse r = EKeyWasNotConsumed; |
|
581 |
QT_TRYCATCH_LEAVING(r = OfferKeyEvent(keyEvent, type)); |
|
582 |
return r; |
|
583 |
} |
|
584 |
||
585 |
TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCode type) |
|
586 |
{ |
|
587 |
switch (type) { |
|
588 |
//case EEventKeyDown: // <-- Intentionally left out. See below. |
|
589 |
case EEventKeyUp: |
|
590 |
case EEventKey: |
|
591 |
{ |
|
592 |
// S60 has a confusing way of delivering key events. There are three types of |
|
593 |
// events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the |
|
594 |
// two first events are generated. When releasing the key, the last one is |
|
595 |
// generated. |
|
596 |
// Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, |
|
597 |
// we need to do some special tricks to map it to the Qt way. First, we completely |
|
598 |
// discard EKeyEventDown events, since they are redundant. Second, since |
|
599 |
// EKeyEventUp does not give us a keysym, we need to cache the keysyms from |
|
600 |
// the EKeyEvent events. This is what resolveS60ScanCode does. |
|
601 |
||
602 |
||
603 |
// ### hackish way to send Qt application to background when pressing right softkey |
|
604 |
/* |
|
605 |
if( keyEvent.iScanCode == EStdKeyDevice1 ) { |
|
606 |
S60->window_group->SetOrdinalPosition(-1); |
|
607 |
qApp->setActiveWindow(0); |
|
608 |
return EKeyWasNotConsumed; |
|
609 |
} |
|
610 |
*/ |
|
611 |
||
612 |
TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, |
|
613 |
keyEvent.iCode); |
|
614 |
int keyCode; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
615 |
if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
616 |
keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
617 |
} else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { |
0 | 618 |
// Normal characters keys. |
619 |
keyCode = s60Keysym; |
|
620 |
} else { |
|
621 |
// Special S60 keys. |
|
622 |
keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); |
|
623 |
} |
|
624 |
||
625 |
#ifndef QT_NO_CURSOR |
|
626 |
if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { |
|
627 |
//translate keys to pointer |
|
628 |
if (keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down || keyCode == Qt::Key_Select) { |
|
629 |
/*Explanation about virtualMouseAccel: |
|
630 |
Tapping an arrow key allows precise pixel positioning |
|
631 |
Holding an arrow key down, acceleration is applied to allow cursor |
|
632 |
to be quickly moved to another part of the screen by key repeats. |
|
633 |
*/ |
|
634 |
if (S60->virtualMouseLastKey == keyCode) { |
|
635 |
S60->virtualMouseAccel *= 2; |
|
636 |
if (S60->virtualMouseAccel > S60->virtualMouseMaxAccel) |
|
637 |
S60->virtualMouseAccel = S60->virtualMouseMaxAccel; |
|
638 |
} |
|
639 |
else |
|
640 |
S60->virtualMouseAccel = 1; |
|
641 |
S60->virtualMouseLastKey = keyCode; |
|
642 |
||
643 |
QPoint pos = QCursor::pos(); |
|
644 |
TPointerEvent fakeEvent; |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
645 |
fakeEvent.iType = (TPointerEvent::TType)(-1); |
0 | 646 |
TInt x = pos.x(); |
647 |
TInt y = pos.y(); |
|
648 |
if (type == EEventKeyUp) { |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
649 |
if (keyCode == Qt::Key_Select && |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
650 |
(S60->virtualMousePressedKeys & QS60Data::Select)) |
0 | 651 |
fakeEvent.iType = TPointerEvent::EButton1Up; |
652 |
S60->virtualMouseAccel = 1; |
|
653 |
S60->virtualMouseLastKey = 0; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
654 |
switch (keyCode) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
655 |
case Qt::Key_Left: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
S60->virtualMousePressedKeys &= ~QS60Data::Left; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
657 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
658 |
case Qt::Key_Right: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
659 |
S60->virtualMousePressedKeys &= ~QS60Data::Right; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
660 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
661 |
case Qt::Key_Up: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
662 |
S60->virtualMousePressedKeys &= ~QS60Data::Up; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
663 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
664 |
case Qt::Key_Down: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
665 |
S60->virtualMousePressedKeys &= ~QS60Data::Down; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
666 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
case Qt::Key_Select: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
S60->virtualMousePressedKeys &= ~QS60Data::Select; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
669 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
670 |
} |
0 | 671 |
} |
672 |
else if (type == EEventKey) { |
|
673 |
switch (keyCode) { |
|
674 |
case Qt::Key_Left: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
675 |
S60->virtualMousePressedKeys |= QS60Data::Left; |
0 | 676 |
x -= S60->virtualMouseAccel; |
677 |
fakeEvent.iType = TPointerEvent::EMove; |
|
678 |
break; |
|
679 |
case Qt::Key_Right: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
680 |
S60->virtualMousePressedKeys |= QS60Data::Right; |
0 | 681 |
x += S60->virtualMouseAccel; |
682 |
fakeEvent.iType = TPointerEvent::EMove; |
|
683 |
break; |
|
684 |
case Qt::Key_Up: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
685 |
S60->virtualMousePressedKeys |= QS60Data::Up; |
0 | 686 |
y -= S60->virtualMouseAccel; |
687 |
fakeEvent.iType = TPointerEvent::EMove; |
|
688 |
break; |
|
689 |
case Qt::Key_Down: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
690 |
S60->virtualMousePressedKeys |= QS60Data::Down; |
0 | 691 |
y += S60->virtualMouseAccel; |
692 |
fakeEvent.iType = TPointerEvent::EMove; |
|
693 |
break; |
|
694 |
case Qt::Key_Select: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
695 |
// Platform bug. If you start pressing several keys simultaneously (for |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
696 |
// example for drag'n'drop), Symbian starts producing spurious up and |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
697 |
// down messages for some keys. Therefore, make sure we have a clean slate |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
// of pressed keys before starting a new button press. |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
699 |
if (S60->virtualMousePressedKeys & QS60Data::Select) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
700 |
return EKeyWasConsumed; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
701 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
702 |
S60->virtualMousePressedKeys |= QS60Data::Select; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
703 |
fakeEvent.iType = TPointerEvent::EButton1Down; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
704 |
} |
0 | 705 |
break; |
706 |
} |
|
707 |
} |
|
708 |
//clip to screen size (window server allows a sprite hotspot to be outside the screen) |
|
709 |
if (x < 0) |
|
710 |
x = 0; |
|
711 |
else if (x >= S60->screenWidthInPixels) |
|
712 |
x = S60->screenWidthInPixels - 1; |
|
713 |
if (y < 0) |
|
714 |
y = 0; |
|
715 |
else if (y >= S60->screenHeightInPixels) |
|
716 |
y = S60->screenHeightInPixels - 1; |
|
717 |
TPoint epos(x, y); |
|
718 |
TPoint cpos = epos - PositionRelativeToScreen(); |
|
719 |
fakeEvent.iModifiers = keyEvent.iModifiers; |
|
720 |
fakeEvent.iPosition = cpos; |
|
721 |
fakeEvent.iParentPosition = epos; |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
722 |
if(fakeEvent.iType != -1) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
723 |
HandlePointerEvent(fakeEvent); |
0 | 724 |
return EKeyWasConsumed; |
725 |
} |
|
726 |
else { |
|
727 |
S60->virtualMouseLastKey = keyCode; |
|
728 |
S60->virtualMouseAccel = 1; |
|
729 |
} |
|
730 |
} |
|
731 |
#endif |
|
732 |
||
733 |
Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); |
|
734 |
QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, |
|
735 |
mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
(keyEvent.iRepeats != 0), 1, keyEvent.iScanCode, s60Keysym, keyEvent.iModifiers); |
0 | 737 |
// WId wid = reinterpret_cast<RWindowGroup *>(keyEvent.Handle())->Child(); |
738 |
// if (!wid) |
|
739 |
// Could happen if window isn't shown yet. |
|
740 |
// return EKeyWasNotConsumed; |
|
741 |
QWidget *widget; |
|
742 |
widget = QWidget::keyboardGrabber(); |
|
743 |
if (!widget) { |
|
744 |
if (QApplicationPrivate::popupWidgets != 0) { |
|
745 |
widget = QApplication::activePopupWidget()->focusWidget(); |
|
746 |
if (!widget) { |
|
747 |
widget = QApplication::activePopupWidget(); |
|
748 |
} |
|
749 |
} else { |
|
750 |
widget = QApplicationPrivate::focus_widget; |
|
751 |
if (!widget) { |
|
752 |
widget = qwidget; |
|
753 |
} |
|
754 |
} |
|
755 |
} |
|
756 |
||
757 |
QEventDispatcherS60 *dispatcher; |
|
758 |
// It is theoretically possible for someone to install a different event dispatcher. |
|
759 |
if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(widget->d_func()->threadData->eventDispatcher)) != 0) { |
|
760 |
if (dispatcher->excludeUserInputEvents()) { |
|
761 |
dispatcher->saveInputEvent(this, widget, new QKeyEventEx(qKeyEvent)); |
|
762 |
return EKeyWasConsumed; |
|
763 |
} |
|
764 |
} |
|
765 |
return sendKeyEvent(widget, &qKeyEvent); |
|
766 |
} |
|
767 |
} |
|
768 |
return EKeyWasNotConsumed; |
|
769 |
} |
|
770 |
||
771 |
void QSymbianControl::sendInputEvent(QWidget *widget, QInputEvent *inputEvent) |
|
772 |
{ |
|
773 |
switch (inputEvent->type()) { |
|
774 |
case QEvent::KeyPress: |
|
775 |
case QEvent::KeyRelease: |
|
776 |
sendKeyEvent(widget, static_cast<QKeyEvent *>(inputEvent)); |
|
777 |
break; |
|
778 |
case QEvent::MouseButtonDblClick: |
|
779 |
case QEvent::MouseButtonPress: |
|
780 |
case QEvent::MouseButtonRelease: |
|
781 |
case QEvent::MouseMove: |
|
782 |
sendMouseEvent(widget, static_cast<QMouseEvent *>(inputEvent)); |
|
783 |
break; |
|
784 |
default: |
|
785 |
// Shouldn't get here. |
|
786 |
Q_ASSERT_X(0 == 1, "QSymbianControl::sendInputEvent()", "inputEvent->type() is unknown"); |
|
787 |
break; |
|
788 |
} |
|
789 |
} |
|
790 |
||
791 |
TKeyResponse QSymbianControl::sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent) |
|
792 |
{ |
|
793 |
#if !defined(QT_NO_IM) && defined(Q_WS_S60) |
|
794 |
if (widget && widget->isEnabled() && widget->testAttribute(Qt::WA_InputMethodEnabled)) { |
|
795 |
QInputContext *qic = widget->inputContext(); |
|
796 |
if (qic && qic->filterEvent(keyEvent)) |
|
797 |
return EKeyWasConsumed; |
|
798 |
} |
|
799 |
#endif // !defined(QT_NO_IM) && defined(Q_WS_S60) |
|
800 |
||
801 |
if (widget && qt_sendSpontaneousEvent(widget, keyEvent)) |
|
802 |
if (keyEvent->isAccepted()) |
|
803 |
return EKeyWasConsumed; |
|
804 |
||
805 |
return EKeyWasNotConsumed; |
|
806 |
} |
|
807 |
||
808 |
#if !defined(QT_NO_IM) && defined(Q_WS_S60) |
|
809 |
TCoeInputCapabilities QSymbianControl::InputCapabilities() const |
|
810 |
{ |
|
811 |
QWidget *w = 0; |
|
812 |
||
813 |
if (qwidget->hasFocus()) |
|
814 |
w = qwidget; |
|
815 |
else |
|
816 |
w = qwidget->focusWidget(); |
|
817 |
||
818 |
QCoeFepInputContext *ic; |
|
819 |
if (w && w->isEnabled() && w->testAttribute(Qt::WA_InputMethodEnabled) |
|
820 |
&& (ic = qobject_cast<QCoeFepInputContext *>(w->inputContext()))) { |
|
821 |
return ic->inputCapabilities(); |
|
822 |
} else { |
|
823 |
return TCoeInputCapabilities(TCoeInputCapabilities::ENone, 0, 0); |
|
824 |
} |
|
825 |
} |
|
826 |
#endif |
|
827 |
||
828 |
void QSymbianControl::Draw(const TRect& controlRect) const |
|
829 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
830 |
// Set flag to avoid calling DrawNow in window surface |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
831 |
QWidget *window = qwidget->window(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
832 |
Q_ASSERT(window); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
833 |
QTLWExtra *topExtra = window->d_func()->maybeTopData(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
834 |
Q_ASSERT(topExtra); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
835 |
if (!topExtra->inExpose) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
836 |
topExtra->inExpose = true; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
837 |
QRect exposeRect = qt_TRect2QRect(controlRect); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
838 |
qwidget->d_func()->syncBackingStore(exposeRect); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
839 |
topExtra->inExpose = false; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
840 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
841 |
|
0 | 842 |
QWindowSurface *surface = qwidget->windowSurface(); |
843 |
QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
|
844 |
||
845 |
if (!engine) |
|
846 |
return; |
|
847 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
const bool sendNativePaintEvents = qwidget->d_func()->extraData()->receiveNativePaintEvents; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
if (sendNativePaintEvents) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
const QRect r = qt_TRect2QRect(controlRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
QMetaObject::invokeMethod(qwidget, "beginNativePaintEvent", Qt::DirectConnection, Q_ARG(QRect, r)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
852 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
853 |
|
0 | 854 |
// Map source rectangle into coordinates of the backing store. |
855 |
const QPoint controlBase(controlRect.iTl.iX, controlRect.iTl.iY); |
|
856 |
const QPoint backingStoreBase = qwidget->mapTo(qwidget->window(), controlBase); |
|
857 |
const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size()); |
|
858 |
||
859 |
if (engine->type() == QPaintEngine::Raster) { |
|
860 |
QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); |
|
861 |
CFbsBitmap *bitmap = s60Surface->symbianBitmap(); |
|
862 |
CWindowGc &gc = SystemGc(); |
|
863 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
864 |
switch(qwidget->d_func()->extraData()->nativePaintMode) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
case QWExtra::Disable: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
866 |
// Do nothing |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
case QWExtra::Blit: |
0 | 870 |
if (qwidget->d_func()->isOpaque) |
871 |
gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
872 |
gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
873 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
case QWExtra::ZeroFill: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
876 |
if (Window().DisplayMode() == EColor16MA) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
877 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
879 |
gc.SetBrushColor(TRgb::Color16MA(0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
gc.Clear(controlRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
gc.SetBrushColor(TRgb(0x000000)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
883 |
gc.Clear(controlRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
888 |
Q_ASSERT(false); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
889 |
} |
0 | 890 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
if (sendNativePaintEvents) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
const QRect r = qt_TRect2QRect(controlRect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
894 |
// The draw ops aren't actually sent to WSERV until the graphics |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
895 |
// context is deactivated, which happens in the function calling |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
896 |
// this one. We therefore delay the delivery of endNativePaintEvent, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
897 |
// to ensure that drawing has completed by the time the widget |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
898 |
// receives the event. Note that, if the widget needs to ensure |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
899 |
// that the draw ops have actually been executed into the output |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
900 |
// framebuffer, a call to RWsSession::Flush is required in the |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
901 |
// endNativePaintEvent implementation. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
902 |
QMetaObject::invokeMethod(qwidget, "endNativePaintEvent", Qt::QueuedConnection, Q_ARG(QRect, r)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
903 |
} |
0 | 904 |
} |
905 |
||
906 |
void QSymbianControl::SizeChanged() |
|
907 |
{ |
|
908 |
CCoeControl::SizeChanged(); |
|
909 |
||
910 |
QSize oldSize = qwidget->size(); |
|
911 |
QSize newSize(Size().iWidth, Size().iHeight); |
|
912 |
||
913 |
if (oldSize != newSize) { |
|
914 |
QRect cr = qwidget->geometry(); |
|
915 |
cr.setSize(newSize); |
|
916 |
qwidget->data->crect = cr; |
|
917 |
if (qwidget->isVisible()) { |
|
918 |
QTLWExtra *tlwExtra = qwidget->d_func()->maybeTopData(); |
|
919 |
bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt(); |
|
920 |
if (!slowResize && tlwExtra) |
|
921 |
tlwExtra->inTopLevelResize = true; |
|
922 |
QResizeEvent e(newSize, oldSize); |
|
923 |
qt_sendSpontaneousEvent(qwidget, &e); |
|
924 |
if (!qwidget->testAttribute(Qt::WA_StaticContents)) |
|
925 |
qwidget->d_func()->syncBackingStore(); |
|
926 |
if (!slowResize && tlwExtra) |
|
927 |
tlwExtra->inTopLevelResize = false; |
|
928 |
} |
|
929 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
// CCoeControl::SetExtent calls SizeChanged, but does not call |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
// PositionChanged, so we call it here to ensure that the widget's |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
933 |
// position is updated. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
934 |
PositionChanged(); |
0 | 935 |
} |
936 |
||
937 |
void QSymbianControl::PositionChanged() |
|
938 |
{ |
|
939 |
CCoeControl::PositionChanged(); |
|
940 |
||
941 |
QPoint oldPos = qwidget->geometry().topLeft(); |
|
942 |
QPoint newPos(Position().iX, Position().iY); |
|
943 |
||
944 |
if (oldPos != newPos) { |
|
945 |
QRect cr = qwidget->geometry(); |
|
946 |
cr.moveTopLeft(newPos); |
|
947 |
qwidget->data->crect = cr; |
|
948 |
QTLWExtra *top = qwidget->d_func()->maybeTopData(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
949 |
if (top && (qwidget->windowState() & (~Qt::WindowActive)) == Qt::WindowNoState) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
950 |
top->normalGeometry.moveTopLeft(newPos); |
0 | 951 |
if (qwidget->isVisible()) { |
952 |
QMoveEvent e(newPos, oldPos); |
|
953 |
qt_sendSpontaneousEvent(qwidget, &e); |
|
954 |
} else { |
|
955 |
QMoveEvent * e = new QMoveEvent(newPos, oldPos); |
|
956 |
QApplication::postEvent(qwidget, e); |
|
957 |
} |
|
958 |
} |
|
959 |
} |
|
960 |
||
961 |
void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) |
|
962 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
963 |
if (m_ignoreFocusChanged || (qwidget->windowType() & Qt::WindowType_Mask) == Qt::Desktop) |
0 | 964 |
return; |
965 |
||
966 |
// Popups never get focused, but still receive the FocusChanged when they are hidden. |
|
967 |
if (QApplicationPrivate::popupWidgets != 0 |
|
968 |
|| (qwidget->windowType() & Qt::Popup) == Qt::Popup) |
|
969 |
return; |
|
970 |
||
971 |
if (IsFocused() && IsVisible()) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
972 |
if (m_symbianPopupIsOpen) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
973 |
QWidget *fw = QApplication::focusWidget(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
974 |
if (fw) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
975 |
QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
976 |
QCoreApplication::sendEvent(fw, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
977 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
978 |
m_symbianPopupIsOpen = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
979 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
980 |
|
0 | 981 |
QApplication::setActiveWindow(qwidget->window()); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
982 |
qwidget->d_func()->setWindowIcon_sys(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
983 |
qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
0 | 984 |
#ifdef Q_WS_S60 |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
985 |
// If widget is fullscreen/minimized, hide status pane and button container otherwise show them. |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
986 |
CEikStatusPane *statusPane = S60->statusPane(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
987 |
CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
988 |
TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
989 |
if (statusPane) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
990 |
statusPane->MakeVisible(visible); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
991 |
if (buttonGroup) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
992 |
// Visibility |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
993 |
const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
994 |
const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
995 |
buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint)); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
996 |
} |
0 | 997 |
#endif |
998 |
} else if (QApplication::activeWindow() == qwidget->window()) { |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
999 |
if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1000 |
QWidget *fw = QApplication::focusWidget(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1001 |
if (fw) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1003 |
QCoreApplication::sendEvent(fw, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1005 |
m_symbianPopupIsOpen = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
return; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1008 |
|
0 | 1009 |
QApplication::setActiveWindow(0); |
1010 |
} |
|
1011 |
// else { We don't touch the active window unless we were explicitly activated or deactivated } |
|
1012 |
} |
|
1013 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1014 |
void QSymbianControl::handleClientAreaChange() |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1015 |
{ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1016 |
const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1017 |
if (qwidget->isFullScreen() && !cbaVisibilityHint) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1018 |
SetExtentToWholeScreen(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1019 |
} else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1020 |
TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1021 |
SetExtent(r.iTl, r.Size()); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1022 |
} else if (!qwidget->isMinimized()) { // Normal geometry |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1023 |
if (!qwidget->testAttribute(Qt::WA_Resized)) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1024 |
qwidget->adjustSize(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1025 |
qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1026 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1027 |
if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1028 |
TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1029 |
SetPosition(r.iTl); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1030 |
qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1031 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1032 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1033 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1034 |
|
0 | 1035 |
void QSymbianControl::HandleResourceChange(int resourceType) |
1036 |
{ |
|
1037 |
switch (resourceType) { |
|
1038 |
case KInternalStatusPaneChange: |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1039 |
handleClientAreaChange(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1040 |
if (IsFocused() && IsVisible()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1041 |
qwidget->d_func()->setWindowIcon_sys(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1042 |
qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1043 |
} |
0 | 1044 |
break; |
1045 |
case KUidValueCoeFontChangeEvent: |
|
1046 |
// font change event |
|
1047 |
break; |
|
1048 |
#ifdef Q_WS_S60 |
|
1049 |
case KEikDynamicLayoutVariantSwitch: |
|
1050 |
{ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1051 |
handleClientAreaChange(); |
0 | 1052 |
break; |
1053 |
} |
|
1054 |
#endif |
|
1055 |
default: |
|
1056 |
break; |
|
1057 |
} |
|
1058 |
||
1059 |
CCoeControl::HandleResourceChange(resourceType); |
|
1060 |
||
1061 |
} |
|
1062 |
void QSymbianControl::CancelLongTapTimer() |
|
1063 |
{ |
|
1064 |
m_longTapDetector->Cancel(); |
|
1065 |
} |
|
1066 |
||
1067 |
TTypeUid::Ptr QSymbianControl::MopSupplyObject(TTypeUid id) |
|
1068 |
{ |
|
1069 |
if (id.iUid == ETypeId) |
|
1070 |
return id.MakePtr(this); |
|
1071 |
||
1072 |
return CCoeControl::MopSupplyObject(id); |
|
1073 |
} |
|
1074 |
||
1075 |
void QSymbianControl::setFocusSafely(bool focus) |
|
1076 |
{ |
|
1077 |
// The stack hack in here is very unfortunate, but it is the only way to ensure proper |
|
1078 |
// focus in Symbian. If this is not executed, the control which happens to be on |
|
1079 |
// the top of the stack may randomly be assigned focus by Symbian, for example |
|
1080 |
// when creating new windows (specifically in CCoeAppUi::HandleStackChanged()). |
|
1081 |
if (focus) { |
|
1082 |
S60->appUi()->RemoveFromStack(this); |
|
1083 |
// Symbian doesn't automatically remove focus from the last focused control, so we need to |
|
1084 |
// remember it and clear focus ourselves. |
|
1085 |
if (lastFocusedControl && lastFocusedControl != this) |
|
1086 |
lastFocusedControl->SetFocus(false); |
|
1087 |
QT_TRAP_THROWING(S60->appUi()->AddToStackL(this, |
|
1088 |
ECoeStackPriorityDefault + 1, ECoeStackFlagStandard)); // Note the + 1 |
|
1089 |
lastFocusedControl = this; |
|
1090 |
this->SetFocus(true); |
|
1091 |
} else { |
|
1092 |
S60->appUi()->RemoveFromStack(this); |
|
1093 |
QT_TRAP_THROWING(S60->appUi()->AddToStackL(this, |
|
1094 |
ECoeStackPriorityDefault, ECoeStackFlagStandard)); |
|
1095 |
if(this == lastFocusedControl) |
|
1096 |
lastFocusedControl = 0; |
|
1097 |
this->SetFocus(false); |
|
1098 |
} |
|
1099 |
} |
|
1100 |
||
1101 |
/*! |
|
1102 |
\typedef QApplication::QS60MainApplicationFactory |
|
1103 |
\since 4.6 |
|
1104 |
||
1105 |
This is a typedef for a pointer to a function with the following |
|
1106 |
signature: |
|
1107 |
||
1108 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 47 |
|
1109 |
||
1110 |
\sa QApplication::QApplication() |
|
1111 |
*/ |
|
1112 |
||
1113 |
/*! |
|
1114 |
\since 4.6 |
|
1115 |
||
1116 |
Creates an application using the application factory given in |
|
1117 |
\a factory, and using \a argc command line arguments in \a argv. |
|
1118 |
\a factory can be leaving, but the error will be converted to a |
|
1119 |
standard exception. |
|
1120 |
||
1121 |
This function is only available on S60. |
|
1122 |
*/ |
|
1123 |
QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv) |
|
1124 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
1125 |
{ |
|
1126 |
Q_D(QApplication); |
|
1127 |
S60->s60ApplicationFactory = factory; |
|
1128 |
d->construct(); |
|
1129 |
} |
|
1130 |
||
1131 |
QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int _internal) |
|
1132 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
1133 |
{ |
|
1134 |
Q_D(QApplication); |
|
1135 |
S60->s60ApplicationFactory = factory; |
|
1136 |
d->construct(); |
|
1137 |
QApplicationPrivate::app_compile_version = _internal; |
|
1138 |
} |
|
1139 |
||
1140 |
void qt_init(QApplicationPrivate * /* priv */, int) |
|
1141 |
{ |
|
1142 |
if (!CCoeEnv::Static()) { |
|
1143 |
// The S60 framework creates a new trap handler which will render any existing traps |
|
1144 |
// invalid as long as it is active. This means that all code in main() that occurs after |
|
1145 |
// the QApplication construction needs to be surrounded by a new trap, despite having |
|
1146 |
// an outer one already. To avoid this, we save the original trap handler here, and set |
|
1147 |
// it back after the S60 framework is constructed. Then we restore it right before the S60 |
|
1148 |
// framework destruction. |
|
1149 |
TTrapHandler *origTrapHandler = User::TrapHandler(); |
|
1150 |
||
1151 |
// The S60 framework has not been initalized. We need to do it. |
|
1152 |
TApaApplicationFactory factory(S60->s60ApplicationFactory ? |
|
1153 |
S60->s60ApplicationFactory : newS60Application); |
|
1154 |
CApaCommandLine* commandLine = 0; |
|
1155 |
TInt err = CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine); |
|
1156 |
// After this construction, CEikonEnv will be available from CEikonEnv::Static(). |
|
1157 |
// (much like our qApp). |
|
1158 |
CEikonEnv* coe = new CEikonEnv; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1159 |
//not using QT_TRAP_THROWING, because coe owns the cleanupstack so it can't be pushed there. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1160 |
if(err == KErrNone) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1161 |
TRAP(err, coe->ConstructAppFromCommandLineL(factory,*commandLine)); |
0 | 1162 |
delete commandLine; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1163 |
if(err != KErrNone) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1164 |
qWarning() << "qt_init: Eikon application construct failed (" |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1165 |
<< err |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1166 |
<< "), maybe missing resource file on S60 3.1?"; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1167 |
delete coe; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
qt_symbian_throwIfError(err); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
} |
0 | 1170 |
|
1171 |
S60->s60InstalledTrapHandler = User::SetTrapHandler(origTrapHandler); |
|
1172 |
||
1173 |
S60->qtOwnsS60Environment = true; |
|
1174 |
} else { |
|
1175 |
S60->qtOwnsS60Environment = false; |
|
1176 |
} |
|
1177 |
||
1178 |
#ifdef QT_NO_DEBUG |
|
1179 |
if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty()) |
|
1180 |
#endif |
|
1181 |
S60->wsSession().SetAutoFlush(ETrue); |
|
1182 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1183 |
#ifdef Q_SYMBIAN_WINDOW_SIZE_CACHE |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1184 |
TRAP_IGNORE(S60->wsSession().EnableWindowSizeCacheL()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1185 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1186 |
|
0 | 1187 |
S60->updateScreenSize(); |
1188 |
||
1189 |
||
1190 |
TDisplayMode mode = S60->screenDevice()->DisplayMode(); |
|
1191 |
S60->screenDepth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(mode); |
|
1192 |
||
1193 |
//NB: RWsSession::GetColorModeList tells you what window modes are supported, |
|
1194 |
//not what bitmap formats. |
|
1195 |
if(QSysInfo::symbianVersion() == QSysInfo::SV_9_2) |
|
1196 |
S60->supportsPremultipliedAlpha = 0; |
|
1197 |
else |
|
1198 |
S60->supportsPremultipliedAlpha = 1; |
|
1199 |
||
1200 |
RProcess me; |
|
1201 |
TSecureId securId = me.SecureId(); |
|
1202 |
S60->uid = securId.operator TUid(); |
|
1203 |
||
1204 |
// enable focus events - used to re-enable mouse after focus changed between mouse and non mouse app, |
|
1205 |
// and for dimming behind modal windows |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1206 |
S60->windowGroup().EnableFocusChangeEvents(); |
0 | 1207 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1208 |
//Check if mouse interaction is supported (either EMouse=1 in the HAL, or EMachineUID is one of the phones known to support this) |
0 | 1209 |
const TInt KMachineUidSamsungI8510 = 0x2000C51E; |
1210 |
// HAL::Get(HALData::EPen, TInt& result) may set 'result' to 1 on some 3.1 systems (e.g. N95). |
|
1211 |
// But we know that S60 systems below 5.0 did not support touch. |
|
1212 |
static const bool touchIsUnsupportedOnSystem = |
|
1213 |
QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 |
|
1214 |
|| QSysInfo::s60Version() == QSysInfo::SV_S60_3_2; |
|
1215 |
TInt machineUID; |
|
1216 |
TInt mouse; |
|
1217 |
TInt touch; |
|
1218 |
TInt err; |
|
1219 |
err = HAL::Get(HALData::EMouse, mouse); |
|
1220 |
if (err != KErrNone) |
|
1221 |
mouse = 0; |
|
1222 |
err = HAL::Get(HALData::EMachineUid, machineUID); |
|
1223 |
if (err != KErrNone) |
|
1224 |
machineUID = 0; |
|
1225 |
err = HAL::Get(HALData::EPen, touch); |
|
1226 |
if (err != KErrNone || touchIsUnsupportedOnSystem) |
|
1227 |
touch = 0; |
|
1228 |
#ifdef __WINS__ |
|
1229 |
if(QSysInfo::symbianVersion() <= QSysInfo::SV_9_4) { |
|
1230 |
//for symbian SDK emulator, force values to match typical devices. |
|
1231 |
mouse = 0; |
|
1232 |
touch = touchIsUnsupportedOnSystem ? 0 : 1; |
|
1233 |
} |
|
1234 |
#endif |
|
1235 |
if (mouse || machineUID == KMachineUidSamsungI8510) { |
|
1236 |
S60->hasTouchscreen = false; |
|
1237 |
S60->virtualMouseRequired = false; |
|
1238 |
} |
|
1239 |
else if (!touch) { |
|
1240 |
S60->hasTouchscreen = false; |
|
1241 |
S60->virtualMouseRequired = true; |
|
1242 |
} |
|
1243 |
else { |
|
1244 |
S60->hasTouchscreen = true; |
|
1245 |
S60->virtualMouseRequired = false; |
|
1246 |
} |
|
1247 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1248 |
S60->avkonComponentsSupportTransparency = false; |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1249 |
S60->menuBeingConstructed = false; |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1250 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1251 |
#ifdef Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1252 |
TUid KCRUidAvkon = { 0x101F876E }; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1253 |
TUint32 KAknAvkonTransparencyEnabled = 0x0000000D; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1254 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1255 |
CRepository* repository = 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1256 |
TRAP(err, repository = CRepository::NewL(KCRUidAvkon)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1257 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1258 |
if(err == KErrNone) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1259 |
TInt value = 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1260 |
err = repository->Get(KAknAvkonTransparencyEnabled, value); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1261 |
if(err == KErrNone) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1262 |
S60->avkonComponentsSupportTransparency = (value==1) ? true : false; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1263 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1264 |
} |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1265 |
#endif |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1266 |
|
0 | 1267 |
if (touch) { |
1268 |
QApplicationPrivate::navigationMode = Qt::NavigationModeNone; |
|
1269 |
} else { |
|
1270 |
QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; |
|
1271 |
} |
|
1272 |
||
1273 |
#ifndef QT_NO_CURSOR |
|
1274 |
//Check if window server pointer cursors are supported or not |
|
1275 |
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
1276 |
//In generic binary, use the HAL and OS version |
|
1277 |
//Any other known good phones should be added here. |
|
1278 |
if (machineUID == KMachineUidSamsungI8510 || (QSysInfo::symbianVersion() != QSysInfo::SV_9_4 |
|
1279 |
&& QSysInfo::symbianVersion() != QSysInfo::SV_9_3 && QSysInfo::symbianVersion() |
|
1280 |
!= QSysInfo::SV_9_2)) { |
|
1281 |
S60->brokenPointerCursors = false; |
|
1282 |
qt_symbian_setWindowGroupCursor(Qt::ArrowCursor, S60->windowGroup()); |
|
1283 |
} |
|
1284 |
else |
|
1285 |
S60->brokenPointerCursors = true; |
|
1286 |
#endif |
|
1287 |
||
1288 |
if (S60->mouseInteractionEnabled) { |
|
1289 |
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
1290 |
if (S60->brokenPointerCursors) { |
|
1291 |
qt_symbian_set_pointer_sprite(Qt::ArrowCursor); |
|
1292 |
qt_symbian_show_pointer_sprite(); |
|
1293 |
} |
|
1294 |
else |
|
1295 |
#endif |
|
1296 |
S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); |
|
1297 |
} |
|
1298 |
#endif |
|
1299 |
||
1300 |
QFont systemFont; |
|
1301 |
systemFont.setFamily(systemFont.defaultFamily()); |
|
1302 |
QApplicationPrivate::setSystemFont(systemFont); |
|
1303 |
||
1304 |
/* |
|
1305 |
### Commented out for now as parameter handling not needed in SOS(yet). Code below will break testlib with -o flag |
|
1306 |
int argc = priv->argc; |
|
1307 |
char **argv = priv->argv; |
|
1308 |
||
1309 |
// Get command line params |
|
1310 |
int j = argc ? 1 : 0; |
|
1311 |
for (int i=1; i<argc; i++) { |
|
1312 |
if (argv[i] && *argv[i] != '-') { |
|
1313 |
argv[j++] = argv[i]; |
|
1314 |
continue; |
|
1315 |
} |
|
1316 |
||
1317 |
#if defined(QT_DEBUG) |
|
1318 |
if (qstrcmp(argv[i], "-nograb") == 0) |
|
1319 |
appNoGrab = !appNoGrab; |
|
1320 |
else |
|
1321 |
#endif // QT_DEBUG |
|
1322 |
; |
|
1323 |
} |
|
1324 |
*/ |
|
1325 |
||
1326 |
// Register WId with the metatype system. This is to enable |
|
1327 |
// QWidgetPrivate::create_sys to used delayed slot invokation in order |
|
1328 |
// to destroy WId objects during reparenting. |
|
1329 |
qRegisterMetaType<WId>("WId"); |
|
1330 |
} |
|
1331 |
||
1332 |
/***************************************************************************** |
|
1333 |
qt_cleanup() - cleans up when the application is finished |
|
1334 |
*****************************************************************************/ |
|
1335 |
void qt_cleanup() |
|
1336 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1337 |
if(qt_S60Beep) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1338 |
delete qt_S60Beep; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1339 |
qt_S60Beep = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1340 |
} |
0 | 1341 |
QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles |
1342 |
// S60 structure and window server session are freed in eventdispatcher destructor as they are needed there |
|
1343 |
||
1344 |
// It's important that this happens here, before the event dispatcher gets |
|
1345 |
// deleted, because the input context needs the event loop one last time before |
|
1346 |
// it dies. |
|
1347 |
delete QApplicationPrivate::inputContext; |
|
1348 |
QApplicationPrivate::inputContext = 0; |
|
1349 |
||
1350 |
//Change mouse pointer back |
|
1351 |
S60->wsSession().SetPointerCursorMode(EPointerCursorNone); |
|
1352 |
||
1353 |
if (S60->qtOwnsS60Environment) { |
|
1354 |
// Restore the S60 framework trap handler. See qt_init(). |
|
1355 |
User::SetTrapHandler(S60->s60InstalledTrapHandler); |
|
1356 |
||
1357 |
CEikonEnv* coe = CEikonEnv::Static(); |
|
1358 |
coe->PrepareToExit(); |
|
1359 |
// The CEikonEnv itself is destroyed in here. |
|
1360 |
coe->DestroyEnvironment(); |
|
1361 |
} |
|
1362 |
} |
|
1363 |
||
1364 |
void QApplicationPrivate::initializeWidgetPaletteHash() |
|
1365 |
{ |
|
1366 |
// TODO: Implement QApplicationPrivate::initializeWidgetPaletteHash() |
|
1367 |
// Possibly a task fot the S60Style guys |
|
1368 |
} |
|
1369 |
||
1370 |
void QApplicationPrivate::createEventDispatcher() |
|
1371 |
{ |
|
1372 |
Q_Q(QApplication); |
|
1373 |
eventDispatcher = new QEventDispatcherS60(q); |
|
1374 |
} |
|
1375 |
||
1376 |
QString QApplicationPrivate::appName() const |
|
1377 |
{ |
|
1378 |
return QCoreApplicationPrivate::appName(); |
|
1379 |
} |
|
1380 |
||
1381 |
bool QApplicationPrivate::modalState() |
|
1382 |
{ |
|
1383 |
return app_do_modal; |
|
1384 |
} |
|
1385 |
||
1386 |
void QApplicationPrivate::enterModal_sys(QWidget *widget) |
|
1387 |
{ |
|
1388 |
if (widget) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1389 |
static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(ETrue); |
0 | 1390 |
// Modal partial screen dialogs (like queries) capture pointer events. |
1391 |
// ### FixMe: Add specialized behaviour for fullscreen modal dialogs |
|
1392 |
widget->effectiveWinId()->SetGloballyCapturing(ETrue); |
|
1393 |
widget->effectiveWinId()->SetPointerCapture(ETrue); |
|
1394 |
} |
|
1395 |
if (!qt_modal_stack) |
|
1396 |
qt_modal_stack = new QWidgetList; |
|
1397 |
qt_modal_stack->insert(0, widget); |
|
1398 |
app_do_modal = true; |
|
1399 |
} |
|
1400 |
||
1401 |
void QApplicationPrivate::leaveModal_sys(QWidget *widget) |
|
1402 |
{ |
|
1403 |
if (widget) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(EFalse); |
0 | 1405 |
// ### FixMe: Add specialized behaviour for fullscreen modal dialogs |
1406 |
widget->effectiveWinId()->SetGloballyCapturing(EFalse); |
|
1407 |
widget->effectiveWinId()->SetPointerCapture(EFalse); |
|
1408 |
} |
|
1409 |
if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { |
|
1410 |
if (qt_modal_stack->isEmpty()) { |
|
1411 |
delete qt_modal_stack; |
|
1412 |
qt_modal_stack = 0; |
|
1413 |
} |
|
1414 |
} |
|
1415 |
app_do_modal = qt_modal_stack != 0; |
|
1416 |
} |
|
1417 |
||
1418 |
void QApplicationPrivate::openPopup(QWidget *popup) |
|
1419 |
{ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1420 |
if (popup && qobject_cast<QComboBox *>(popup->parentWidget())) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1421 |
static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(ETrue); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1422 |
|
0 | 1423 |
if (!QApplicationPrivate::popupWidgets) |
1424 |
QApplicationPrivate::popupWidgets = new QWidgetList; |
|
1425 |
QApplicationPrivate::popupWidgets->append(popup); |
|
1426 |
||
1427 |
// Cancel focus widget pointer capture and long tap timer |
|
1428 |
if (QApplication::focusWidget()) { |
|
1429 |
static_cast<QSymbianControl*>(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer(); |
|
1430 |
QApplication::focusWidget()->effectiveWinId()->SetPointerCapture(false); |
|
1431 |
} |
|
1432 |
||
1433 |
if (!qt_nograb()) { |
|
1434 |
// Cancel pointer capture and long tap timer for earlier popup |
|
1435 |
int popupCount = QApplicationPrivate::popupWidgets->count(); |
|
1436 |
if (popupCount > 1) { |
|
1437 |
QWidget* prevPopup = QApplicationPrivate::popupWidgets->at(popupCount-2); |
|
1438 |
static_cast<QSymbianControl*>(prevPopup->effectiveWinId())->CancelLongTapTimer(); |
|
1439 |
prevPopup->effectiveWinId()->SetPointerCapture(false); |
|
1440 |
} |
|
1441 |
||
1442 |
// Enable pointer capture for this (topmost) popup |
|
1443 |
Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); |
|
1444 |
WId id = popup->effectiveWinId(); |
|
1445 |
id->SetPointerCapture(true); |
|
1446 |
} |
|
1447 |
||
1448 |
// popups are not focus-handled by the window system (the first |
|
1449 |
// popup grabbed the keyboard), so we have to do that manually: A |
|
1450 |
// new popup gets the focus |
|
1451 |
QWidget *fw = popup->focusWidget(); |
|
1452 |
if (fw) { |
|
1453 |
fw->setFocus(Qt::PopupFocusReason); |
|
1454 |
} else if (QApplicationPrivate::popupWidgets->count() == 1) { // this was the first popup |
|
1455 |
fw = QApplication::focusWidget(); |
|
1456 |
if (fw) { |
|
1457 |
QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); |
|
1458 |
q_func()->sendEvent(fw, &e); |
|
1459 |
} |
|
1460 |
} |
|
1461 |
} |
|
1462 |
||
1463 |
void QApplicationPrivate::closePopup(QWidget *popup) |
|
1464 |
{ |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1465 |
if (popup && qobject_cast<QComboBox *>(popup->parentWidget())) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1466 |
static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(EFalse); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1467 |
|
0 | 1468 |
if (!QApplicationPrivate::popupWidgets) |
1469 |
return; |
|
1470 |
QApplicationPrivate::popupWidgets->removeAll(popup); |
|
1471 |
||
1472 |
// Cancel pointer capture and long tap for this popup |
|
1473 |
WId id = popup->effectiveWinId(); |
|
1474 |
id->SetPointerCapture(false); |
|
1475 |
static_cast<QSymbianControl*>(id)->CancelLongTapTimer(); |
|
1476 |
||
1477 |
if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup |
|
1478 |
delete QApplicationPrivate::popupWidgets; |
|
1479 |
QApplicationPrivate::popupWidgets = 0; |
|
1480 |
if (!qt_nograb()) { // grabbing not disabled |
|
1481 |
Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); |
|
1482 |
if (QWidgetPrivate::mouseGrabber != 0) |
|
1483 |
QWidgetPrivate::mouseGrabber->grabMouse(); |
|
1484 |
||
1485 |
if (QWidgetPrivate::keyboardGrabber != 0) |
|
1486 |
QWidgetPrivate::keyboardGrabber->grabKeyboard(); |
|
1487 |
||
1488 |
QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() |
|
1489 |
: q_func()->focusWidget(); |
|
1490 |
if (fw) { |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1491 |
if(fw->window()->isModal()) // restore pointer capture for modal window |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1492 |
fw->effectiveWinId()->SetPointerCapture(true); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1493 |
|
0 | 1494 |
if (fw != q_func()->focusWidget()) { |
1495 |
fw->setFocus(Qt::PopupFocusReason); |
|
1496 |
} else { |
|
1497 |
QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); |
|
1498 |
q_func()->sendEvent(fw, &e); |
|
1499 |
} |
|
1500 |
} |
|
1501 |
} |
|
1502 |
} else { |
|
1503 |
||
1504 |
// popups are not focus-handled by the window system (the |
|
1505 |
// first popup grabbed the keyboard), so we have to do that |
|
1506 |
// manually: A popup was closed, so the previous popup gets |
|
1507 |
// the focus. |
|
1508 |
QWidget* aw = QApplicationPrivate::popupWidgets->last(); |
|
1509 |
if (QWidget *fw = QApplication::focusWidget()) { |
|
1510 |
QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); |
|
1511 |
q_func()->sendEvent(fw, &e); |
|
1512 |
} |
|
1513 |
||
1514 |
// Enable pointer capture for previous popup |
|
1515 |
if (aw) { |
|
1516 |
aw->effectiveWinId()->SetPointerCapture(true); |
|
1517 |
} |
|
1518 |
} |
|
1519 |
} |
|
1520 |
||
1521 |
QWidget * QApplication::topLevelAt(QPoint const& point) |
|
1522 |
{ |
|
1523 |
QWidget *found = 0; |
|
1524 |
int lowestZ = INT_MAX; |
|
1525 |
QWidgetList list = QApplication::topLevelWidgets(); |
|
1526 |
for (int i = 0; i < list.count(); ++i) { |
|
1527 |
QWidget *widget = list.at(i); |
|
1528 |
if (widget->isVisible() && !(widget->windowType() == Qt::Desktop)) { |
|
1529 |
Q_ASSERT(widget->testAttribute(Qt::WA_WState_Created)); |
|
1530 |
if (widget->geometry().adjusted(0,0,1,1).contains(point)) { |
|
1531 |
// At this point we know there is a Qt widget under the point. |
|
1532 |
// Now we need to make sure it is the top most in the z-order. |
|
1533 |
RDrawableWindow *const window = widget->effectiveWinId()->DrawableWindow(); |
|
1534 |
int z = window->OrdinalPosition(); |
|
1535 |
if (z < lowestZ) { |
|
1536 |
lowestZ = z; |
|
1537 |
found = widget; |
|
1538 |
} |
|
1539 |
} |
|
1540 |
} |
|
1541 |
} |
|
1542 |
return found; |
|
1543 |
} |
|
1544 |
||
1545 |
void QApplication::alert(QWidget * /* widget */, int /* duration */) |
|
1546 |
{ |
|
1547 |
// TODO: Implement QApplication::alert(QWidget *widget, int duration) |
|
1548 |
} |
|
1549 |
||
1550 |
int QApplication::doubleClickInterval() |
|
1551 |
{ |
|
1552 |
TTimeIntervalMicroSeconds32 us; |
|
1553 |
TInt distance; |
|
1554 |
S60->wsSession().GetDoubleClickSettings(us, distance); |
|
1555 |
return (us.Int() / 1000); |
|
1556 |
} |
|
1557 |
||
1558 |
void QApplication::setDoubleClickInterval(int ms) |
|
1559 |
{ |
|
1560 |
TTimeIntervalMicroSeconds32 newUs( ms * 1000); |
|
1561 |
TTimeIntervalMicroSeconds32 us; |
|
1562 |
TInt distance; |
|
1563 |
S60->wsSession().GetDoubleClickSettings(us, distance); |
|
1564 |
if (us != newUs) |
|
1565 |
S60->wsSession().SetDoubleClick(newUs, distance); |
|
1566 |
} |
|
1567 |
||
1568 |
int QApplication::keyboardInputInterval() |
|
1569 |
{ |
|
1570 |
return QApplicationPrivate::keyboard_input_time; |
|
1571 |
} |
|
1572 |
||
1573 |
void QApplication::setKeyboardInputInterval(int ms) |
|
1574 |
{ |
|
1575 |
QApplicationPrivate::keyboard_input_time = ms; |
|
1576 |
} |
|
1577 |
||
1578 |
int QApplication::cursorFlashTime() |
|
1579 |
{ |
|
1580 |
return QApplicationPrivate::cursor_flash_time; |
|
1581 |
} |
|
1582 |
||
1583 |
void QApplication::setCursorFlashTime(int msecs) |
|
1584 |
{ |
|
1585 |
QApplicationPrivate::cursor_flash_time = msecs; |
|
1586 |
} |
|
1587 |
||
1588 |
void QApplication::beep() |
|
1589 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1590 |
if (!qt_S60Beep) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1591 |
TInt frequency = 880; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1592 |
TTimeIntervalMicroSeconds duration(500000); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1593 |
TRAP_IGNORE(qt_S60Beep=QS60Beep::NewL(frequency, duration)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1594 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1595 |
if (qt_S60Beep) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1596 |
qt_S60Beep->Play(); |
0 | 1597 |
} |
1598 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1599 |
static inline bool callSymbianEventFilters(const QSymbianEvent *event) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1600 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1601 |
long unused; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1602 |
return qApp->filterEvent(const_cast<QSymbianEvent *>(event), &unused); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1603 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1604 |
|
0 | 1605 |
/*! |
1606 |
\warning This function is only available on Symbian. |
|
1607 |
\since 4.6 |
|
1608 |
||
1609 |
This function processes an individual Symbian event |
|
1610 |
\a event. It returns 1 if the event was handled, 0 if |
|
1611 |
the \a event was not handled, and -1 if the event was |
|
1612 |
not handled because the event is not known to Qt. |
|
1613 |
*/ |
|
1614 |
||
1615 |
int QApplication::symbianProcessEvent(const QSymbianEvent *event) |
|
1616 |
{ |
|
1617 |
Q_D(QApplication); |
|
1618 |
||
1619 |
QScopedLoopLevelCounter counter(d->threadData); |
|
1620 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1621 |
if (d->eventDispatcher->filterEvent(const_cast<QSymbianEvent *>(event))) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1622 |
return 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1623 |
|
0 | 1624 |
QWidget *w = qApp ? qApp->focusWidget() : 0; |
1625 |
if (w) { |
|
1626 |
QInputContext *ic = w->inputContext(); |
|
1627 |
if (ic && ic->symbianFilterEvent(w, event)) |
|
1628 |
return 1; |
|
1629 |
} |
|
1630 |
||
1631 |
if (symbianEventFilter(event)) |
|
1632 |
return 1; |
|
1633 |
||
1634 |
switch (event->type()) { |
|
1635 |
case QSymbianEvent::WindowServerEvent: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1636 |
return d->symbianProcessWsEvent(event); |
0 | 1637 |
case QSymbianEvent::CommandEvent: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1638 |
return d->symbianHandleCommand(event); |
0 | 1639 |
case QSymbianEvent::ResourceChangeEvent: |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1640 |
return d->symbianResourceChange(event); |
0 | 1641 |
default: |
1642 |
return -1; |
|
1643 |
} |
|
1644 |
} |
|
1645 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1646 |
int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent) |
0 | 1647 |
{ |
1648 |
// Qt event handling. Handle some events regardless of if the handle is in our |
|
1649 |
// widget map or not. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1650 |
const TWsEvent *event = symbianEvent->windowServerEvent(); |
0 | 1651 |
CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle()); |
1652 |
const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control); |
|
1653 |
switch (event->Type()) { |
|
1654 |
case EEventPointerEnter: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1655 |
if (controlInMap) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1656 |
callSymbianEventFilters(symbianEvent); |
0 | 1657 |
return 1; // Qt::Enter will be generated in HandlePointerL |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1658 |
} |
0 | 1659 |
break; |
1660 |
case EEventPointerExit: |
|
1661 |
if (controlInMap) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1662 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1663 |
return 1; |
0 | 1664 |
if (S60) { |
1665 |
// mouseEvent outside our window, send leave event to last focused widget |
|
1666 |
QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos, |
|
1667 |
Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); |
|
1668 |
if (S60->lastPointerEventTarget) |
|
1669 |
qt_sendSpontaneousEvent(S60->lastPointerEventTarget,&mEvent); |
|
1670 |
S60->lastPointerEventTarget = 0; |
|
1671 |
} |
|
1672 |
return 1; |
|
1673 |
} |
|
1674 |
break; |
|
1675 |
case EEventScreenDeviceChanged: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1676 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1677 |
return 1; |
0 | 1678 |
if (S60) |
1679 |
S60->updateScreenSize(); |
|
1680 |
if (qt_desktopWidget) { |
|
1681 |
QSize oldSize = qt_desktopWidget->size(); |
|
1682 |
qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels); |
|
1683 |
qt_desktopWidget->data->crect.setHeight(S60->screenHeightInPixels); |
|
1684 |
QResizeEvent e(qt_desktopWidget->size(), oldSize); |
|
1685 |
QApplication::sendEvent(qt_desktopWidget, &e); |
|
1686 |
} |
|
1687 |
return 0; // Propagate to CONE |
|
1688 |
case EEventWindowVisibilityChanged: |
|
1689 |
if (controlInMap) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1690 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1691 |
return 1; |
0 | 1692 |
const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); |
1693 |
QWidget *w = QWidgetPrivate::mapper->value(control); |
|
1694 |
if (!w->d_func()->maybeTopData()) |
|
1695 |
break; |
|
1696 |
if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { |
|
1697 |
delete w->d_func()->topData()->backingStore; |
|
1698 |
w->d_func()->topData()->backingStore = 0; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1699 |
// In order to ensure that any resources used by the window surface |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1700 |
// are immediately freed, we flush the WSERV command buffer. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1701 |
S60->wsSession().Flush(); |
0 | 1702 |
} else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) |
1703 |
&& !w->d_func()->maybeBackingStore()) { |
|
1704 |
w->d_func()->topData()->backingStore = new QWidgetBackingStore(w); |
|
1705 |
w->d_func()->invalidateBuffer(w->rect()); |
|
1706 |
w->repaint(); |
|
1707 |
} |
|
1708 |
return 1; |
|
1709 |
} |
|
1710 |
break; |
|
1711 |
case EEventFocusGained: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1712 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1713 |
return 1; |
0 | 1714 |
#ifndef QT_NO_CURSOR |
1715 |
//re-enable mouse interaction |
|
1716 |
if (S60->mouseInteractionEnabled) { |
|
1717 |
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
1718 |
if (S60->brokenPointerCursors) |
|
1719 |
qt_symbian_show_pointer_sprite(); |
|
1720 |
else |
|
1721 |
#endif |
|
1722 |
S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); |
|
1723 |
} |
|
1724 |
#endif |
|
1725 |
break; |
|
1726 |
case EEventFocusLost: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1727 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1728 |
return 1; |
0 | 1729 |
#ifndef QT_NO_CURSOR |
1730 |
//disable mouse as may be moving to application that does not support it |
|
1731 |
if (S60->mouseInteractionEnabled) { |
|
1732 |
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
1733 |
if (S60->brokenPointerCursors) |
|
1734 |
qt_symbian_hide_pointer_sprite(); |
|
1735 |
else |
|
1736 |
#endif |
|
1737 |
S60->wsSession().SetPointerCursorMode(EPointerCursorNone); |
|
1738 |
} |
|
1739 |
#endif |
|
1740 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1741 |
default: |
0 | 1742 |
break; |
1743 |
} |
|
1744 |
||
1745 |
if (!controlInMap) |
|
1746 |
return -1; |
|
1747 |
||
1748 |
return 0; |
|
1749 |
} |
|
1750 |
||
1751 |
/*! |
|
1752 |
\warning This virtual function is only available on Symbian. |
|
1753 |
\since 4.6 |
|
1754 |
||
1755 |
If you create an application that inherits QApplication and reimplement |
|
1756 |
this function, you get direct access to events that the are received |
|
1757 |
from Symbian. The events are passed in the \a event parameter. |
|
1758 |
||
1759 |
Return true if you want to stop the event from being processed. Return |
|
1760 |
false for normal event dispatching. The default implementation returns |
|
1761 |
false, and does nothing with \a event. |
|
1762 |
*/ |
|
1763 |
bool QApplication::symbianEventFilter(const QSymbianEvent *event) |
|
1764 |
{ |
|
1765 |
Q_UNUSED(event); |
|
1766 |
return false; |
|
1767 |
} |
|
1768 |
||
1769 |
/*! |
|
1770 |
\warning This function is only available on Symbian. |
|
1771 |
\since 4.6 |
|
1772 |
||
1773 |
Handles \a{command}s which are typically handled by |
|
1774 |
CAknAppUi::HandleCommandL(). Qts Ui integration into Symbian is |
|
1775 |
partially achieved by deriving from CAknAppUi. Currently, exit, |
|
1776 |
menu and softkey commands are handled. |
|
1777 |
||
1778 |
\sa s60EventFilter(), s60ProcessEvent() |
|
1779 |
*/ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1780 |
int QApplicationPrivate::symbianHandleCommand(const QSymbianEvent *symbianEvent) |
0 | 1781 |
{ |
1782 |
Q_Q(QApplication); |
|
1783 |
int ret = 0; |
|
1784 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1785 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1786 |
return 1; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1787 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1788 |
int command = symbianEvent->command(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1789 |
|
0 | 1790 |
switch (command) { |
1791 |
#ifdef Q_WS_S60 |
|
1792 |
case EAknSoftkeyExit: { |
|
1793 |
QCloseEvent ev; |
|
1794 |
QApplication::sendSpontaneousEvent(q, &ev); |
|
1795 |
if (ev.isAccepted()) { |
|
1796 |
q->quit(); |
|
1797 |
ret = 1; |
|
1798 |
} |
|
1799 |
break; |
|
1800 |
} |
|
1801 |
#endif |
|
1802 |
case EEikCmdExit: |
|
1803 |
q->quit(); |
|
1804 |
ret = 1; |
|
1805 |
break; |
|
1806 |
default: |
|
1807 |
bool handled = QSoftKeyManager::handleCommand(command); |
|
1808 |
if (handled) |
|
1809 |
ret = 1; |
|
1810 |
#ifdef Q_WS_S60 |
|
1811 |
else |
|
1812 |
ret = QMenuBarPrivate::symbianCommands(command); |
|
1813 |
#endif |
|
1814 |
break; |
|
1815 |
} |
|
1816 |
||
1817 |
return ret; |
|
1818 |
} |
|
1819 |
||
1820 |
/*! |
|
1821 |
\warning This function is only available on Symbian. |
|
1822 |
\since 4.6 |
|
1823 |
||
1824 |
Handles the resource change specified by \a type. |
|
1825 |
||
1826 |
Currently, KEikDynamicLayoutVariantSwitch and |
|
1827 |
KAknsMessageSkinChange are handled. |
|
1828 |
*/ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1829 |
int QApplicationPrivate::symbianResourceChange(const QSymbianEvent *symbianEvent) |
0 | 1830 |
{ |
1831 |
int ret = 0; |
|
1832 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1833 |
int type = symbianEvent->resourceChangeType(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1834 |
|
0 | 1835 |
switch (type) { |
1836 |
#ifdef Q_WS_S60 |
|
1837 |
case KEikDynamicLayoutVariantSwitch: |
|
1838 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1839 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1840 |
return 1; |
0 | 1841 |
if (S60) |
1842 |
S60->updateScreenSize(); |
|
1843 |
||
1844 |
#ifndef QT_NO_STYLE_S60 |
|
1845 |
QS60Style *s60Style = 0; |
|
1846 |
||
1847 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1848 |
QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style()); |
|
1849 |
if (proxy) |
|
1850 |
s60Style = qobject_cast<QS60Style*>(proxy->baseStyle()); |
|
1851 |
else |
|
1852 |
#endif |
|
1853 |
s60Style = qobject_cast<QS60Style*>(QApplication::style()); |
|
1854 |
||
1855 |
if (s60Style) { |
|
1856 |
s60Style->d_func()->handleDynamicLayoutVariantSwitch(); |
|
1857 |
ret = 1; |
|
1858 |
} |
|
1859 |
#endif |
|
1860 |
} |
|
1861 |
break; |
|
1862 |
||
1863 |
#ifndef QT_NO_STYLE_S60 |
|
1864 |
case KAknsMessageSkinChange: |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1865 |
if (callSymbianEventFilters(symbianEvent)) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1866 |
return 1; |
0 | 1867 |
if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style())) { |
1868 |
s60Style->d_func()->handleSkinChange(); |
|
1869 |
ret = 1; |
|
1870 |
} |
|
1871 |
break; |
|
1872 |
#endif |
|
1873 |
#endif // Q_WS_S60 |
|
1874 |
default: |
|
1875 |
break; |
|
1876 |
} |
|
1877 |
||
1878 |
return ret; |
|
1879 |
} |
|
1880 |
||
1881 |
#ifndef QT_NO_WHEELEVENT |
|
1882 |
int QApplication::wheelScrollLines() |
|
1883 |
{ |
|
1884 |
return QApplicationPrivate::wheel_scroll_lines; |
|
1885 |
} |
|
1886 |
||
1887 |
void QApplication::setWheelScrollLines(int n) |
|
1888 |
{ |
|
1889 |
QApplicationPrivate::wheel_scroll_lines = n; |
|
1890 |
} |
|
1891 |
#endif //QT_NO_WHEELEVENT |
|
1892 |
||
1893 |
bool QApplication::isEffectEnabled(Qt::UIEffect /* effect */) |
|
1894 |
{ |
|
1895 |
// TODO: Implement QApplication::isEffectEnabled(Qt::UIEffect effect) |
|
1896 |
return false; |
|
1897 |
} |
|
1898 |
||
1899 |
void QApplication::setEffectEnabled(Qt::UIEffect /* effect */, bool /* enable */) |
|
1900 |
{ |
|
1901 |
// TODO: Implement QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) |
|
1902 |
} |
|
1903 |
||
1904 |
TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym) |
|
1905 |
{ |
|
1906 |
if (keysym) { |
|
1907 |
// If keysym is specified, cache it. |
|
1908 |
scanCodeCache.insert(scanCode, keysym); |
|
1909 |
return keysym; |
|
1910 |
} else { |
|
1911 |
// If not, retrieve the cached version. |
|
1912 |
return scanCodeCache[scanCode]; |
|
1913 |
} |
|
1914 |
} |
|
1915 |
||
1916 |
void QApplicationPrivate::initializeMultitouch_sys() |
|
1917 |
{ |
|
1918 |
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
|
1919 |
if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone) |
|
1920 |
maxTouchPressure = KMaxTInt; |
|
1921 |
#endif |
|
1922 |
} |
|
1923 |
||
1924 |
void QApplicationPrivate::cleanupMultitouch_sys() |
|
1925 |
{ } |
|
1926 |
||
1927 |
#ifndef QT_NO_SESSIONMANAGER |
|
1928 |
QSessionManager::QSessionManager(QApplication * /* app */, QString & /* id */, QString& /* key */) |
|
1929 |
{ |
|
1930 |
||
1931 |
} |
|
1932 |
||
1933 |
QSessionManager::~QSessionManager() |
|
1934 |
{ |
|
1935 |
||
1936 |
} |
|
1937 |
||
1938 |
bool QSessionManager::allowsInteraction() |
|
1939 |
{ |
|
1940 |
return false; |
|
1941 |
} |
|
1942 |
||
1943 |
void QSessionManager::cancel() |
|
1944 |
{ |
|
1945 |
||
1946 |
} |
|
1947 |
#endif //QT_NO_SESSIONMANAGER |
|
1948 |
||
1949 |
#ifdef QT_KEYPAD_NAVIGATION |
|
1950 |
/* |
|
1951 |
* Show/Hide the mouse cursor depending on phone type and chosen mode |
|
1952 |
*/ |
|
1953 |
void QApplicationPrivate::setNavigationMode(Qt::NavigationMode mode) |
|
1954 |
{ |
|
1955 |
#ifndef QT_NO_CURSOR |
|
1956 |
const bool wasCursorOn = (QApplicationPrivate::navigationMode == Qt::NavigationModeCursorAuto |
|
1957 |
&& !S60->hasTouchscreen) |
|
1958 |
|| QApplicationPrivate::navigationMode == Qt::NavigationModeCursorForceVisible; |
|
1959 |
const bool isCursorOn = (mode == Qt::NavigationModeCursorAuto |
|
1960 |
&& !S60->hasTouchscreen) |
|
1961 |
|| mode == Qt::NavigationModeCursorForceVisible; |
|
1962 |
||
1963 |
if (!wasCursorOn && isCursorOn) { |
|
1964 |
//Show the cursor, when changing from another mode to cursor mode |
|
1965 |
qt_symbian_set_cursor_visible(true); |
|
1966 |
} |
|
1967 |
else if (wasCursorOn && !isCursorOn) { |
|
1968 |
//Hide the cursor, when leaving cursor mode |
|
1969 |
qt_symbian_set_cursor_visible(false); |
|
1970 |
} |
|
1971 |
#endif |
|
1972 |
QApplicationPrivate::navigationMode = mode; |
|
1973 |
} |
|
1974 |
#endif |
|
1975 |
||
1976 |
#ifndef QT_NO_CURSOR |
|
1977 |
/***************************************************************************** |
|
1978 |
QApplication cursor stack |
|
1979 |
*****************************************************************************/ |
|
1980 |
||
1981 |
void QApplication::setOverrideCursor(const QCursor &cursor) |
|
1982 |
{ |
|
1983 |
qApp->d_func()->cursor_list.prepend(cursor); |
|
1984 |
qt_symbian_setGlobalCursor(cursor); |
|
1985 |
} |
|
1986 |
||
1987 |
void QApplication::restoreOverrideCursor() |
|
1988 |
{ |
|
1989 |
if (qApp->d_func()->cursor_list.isEmpty()) |
|
1990 |
return; |
|
1991 |
qApp->d_func()->cursor_list.removeFirst(); |
|
1992 |
||
1993 |
if (!qApp->d_func()->cursor_list.isEmpty()) { |
|
1994 |
qt_symbian_setGlobalCursor(qApp->d_func()->cursor_list.first()); |
|
1995 |
} |
|
1996 |
else { |
|
1997 |
//determine which widget has focus |
|
1998 |
QWidget *w = QApplication::widgetAt(QCursor::pos()); |
|
1999 |
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
2000 |
if (S60->brokenPointerCursors) { |
|
2001 |
qt_symbian_set_pointer_sprite(w ? w->cursor() : Qt::ArrowCursor); |
|
2002 |
} |
|
2003 |
else |
|
2004 |
#endif |
|
2005 |
{ |
|
2006 |
//because of the internals of window server, we need to force the cursor |
|
2007 |
//to be set in all child windows too, otherwise when the cursor is over |
|
2008 |
//the child window it may show a widget cursor or arrow cursor instead, |
|
2009 |
//depending on construction order. |
|
2010 |
QListIterator<WId> iter(QWidgetPrivate::mapper->uniqueKeys()); |
|
2011 |
while (iter.hasNext()) { |
|
2012 |
CCoeControl *ctrl = iter.next(); |
|
2013 |
if(ctrl->OwnsWindow()) { |
|
2014 |
ctrl->DrawableWindow()->ClearPointerCursor(); |
|
2015 |
} |
|
2016 |
} |
|
2017 |
if (w) |
|
2018 |
qt_symbian_setWindowCursor(w->cursor(), w->effectiveWinId()); |
|
2019 |
else |
|
2020 |
qt_symbian_setWindowGroupCursor(Qt::ArrowCursor, S60->windowGroup()); |
|
2021 |
} |
|
2022 |
} |
|
2023 |
} |
|
2024 |
||
2025 |
#endif // QT_NO_CURSOR |
|
2026 |
||
2027 |
QT_END_NAMESPACE |