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