author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 13 | cc75c76972ee |
parent 12 | 25a739ee40f4 |
child 14 | c0432d11811c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qwidget_p.h" |
|
43 |
#include "qdesktopwidget.h" |
|
44 |
#include "qapplication.h" |
|
45 |
#include "qapplication_p.h" |
|
46 |
#include "private/qbackingstore_p.h" |
|
47 |
#include "qevent.h" |
|
48 |
#include "qt_s60_p.h" |
|
49 |
||
50 |
#include "qbitmap.h" |
|
51 |
#include "private/qwindowsurface_s60_p.h" |
|
52 |
||
53 |
#include <qinputcontext.h> |
|
54 |
||
55 |
#ifdef Q_WS_S60 |
|
56 |
#include <aknappui.h> |
|
57 |
#endif |
|
58 |
||
59 |
// This is necessary in order to be able to perform delayed invokation on slots |
|
60 |
// which take arguments of type WId. One example is |
|
61 |
// QWidgetPrivate::_q_delayedDestroy, which is used to delay destruction of |
|
62 |
// CCoeControl objects until after the CONE event handler has finished running. |
|
63 |
Q_DECLARE_METATYPE(WId) |
|
64 |
||
65 |
QT_BEGIN_NAMESPACE |
|
66 |
||
67 |
extern bool qt_nograb(); |
|
68 |
||
69 |
QWidget *QWidgetPrivate::mouseGrabber = 0; |
|
70 |
QWidget *QWidgetPrivate::keyboardGrabber = 0; |
|
71 |
||
72 |
static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b) |
|
73 |
{ |
|
74 |
if ( a.count() != b.count()) |
|
75 |
return false; |
|
76 |
int index=0; |
|
77 |
while (index<a.count()) { |
|
78 |
if (a.at(index)->softKeyRole() != b.at(index)->softKeyRole()) |
|
79 |
return false; |
|
80 |
if (a.at(index)->text().compare(b.at(index)->text())!=0) |
|
81 |
return false; |
|
82 |
index++; |
|
83 |
} |
|
84 |
return true; |
|
85 |
} |
|
86 |
||
87 |
void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) |
|
88 |
{ |
|
89 |
// Note: based on x11 implementation |
|
90 |
||
91 |
static const int XCOORD_MAX = 16383; |
|
92 |
static const int WRECT_MAX = 16383; |
|
93 |
||
94 |
Q_Q(QWidget); |
|
95 |
||
96 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
97 |
||
98 |
/* |
|
99 |
There are up to four different coordinate systems here: |
|
100 |
Qt coordinate system for this widget. |
|
101 |
Symbian coordinate system for this widget (relative to wrect). |
|
102 |
Qt coordinate system for parent |
|
103 |
Symbian coordinate system for parent (relative to parent's wrect). |
|
104 |
*/ |
|
105 |
||
106 |
QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX); |
|
107 |
QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX); |
|
108 |
QRect wrect; |
|
109 |
//xrect is the Symbian geometry of my widget. (starts out in parent's Qt coord sys, and ends up in parent's Symbian coord sys) |
|
110 |
QRect xrect = data.crect; |
|
111 |
||
112 |
const QWidget *const parent = q->parentWidget(); |
|
113 |
QRect parentWRect = parent->data->wrect; |
|
114 |
||
115 |
if (parentWRect.isValid()) { |
|
116 |
// parent is clipped, and we have to clip to the same limit as parent |
|
117 |
if (!parentWRect.contains(xrect)) { |
|
118 |
xrect &= parentWRect; |
|
119 |
wrect = xrect; |
|
120 |
//translate from parent's to my Qt coord sys |
|
121 |
wrect.translate(-data.crect.topLeft()); |
|
122 |
} |
|
123 |
//translate from parent's Qt coords to parent's X coords |
|
124 |
xrect.translate(-parentWRect.topLeft()); |
|
125 |
||
126 |
} else { |
|
127 |
// parent is not clipped, we may or may not have to clip |
|
128 |
||
129 |
if (data.wrect.isValid() && QRect(QPoint(),data.crect.size()).contains(data.wrect)) { |
|
130 |
// This is where the main optimization is: we are already |
|
131 |
// clipped, and if our clip is still valid, we can just |
|
132 |
// move our window, and do not need to move or clip |
|
133 |
// children |
|
134 |
||
135 |
QRect vrect = xrect & parent->rect(); |
|
136 |
vrect.translate(-data.crect.topLeft()); //the part of me that's visible through parent, in my Qt coords |
|
137 |
if (data.wrect.contains(vrect)) { |
|
138 |
xrect = data.wrect; |
|
139 |
xrect.translate(data.crect.topLeft()); |
|
140 |
if (data.winid) |
|
141 |
data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); |
|
142 |
return; |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
if (!validRange.contains(xrect)) { |
|
147 |
// we are too big, and must clip |
|
148 |
xrect &=wrectRange; |
|
149 |
wrect = xrect; |
|
150 |
wrect.translate(-data.crect.topLeft()); |
|
151 |
//parent's X coord system is equal to parent's Qt coord |
|
152 |
//sys, so we don't need to map xrect. |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
// unmap if we are outside the valid window system coord system |
|
157 |
bool outsideRange = !xrect.isValid(); |
|
158 |
bool mapWindow = false; |
|
159 |
if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) { |
|
160 |
q->setAttribute(Qt::WA_OutsideWSRange, outsideRange); |
|
161 |
if (outsideRange) { |
|
162 |
if (data.winid) |
|
163 |
data.winid->DrawableWindow()->SetVisible(EFalse); |
|
164 |
q->setAttribute(Qt::WA_Mapped, false); |
|
165 |
} else if (!q->isHidden()) { |
|
166 |
mapWindow = true; |
|
167 |
} |
|
168 |
} |
|
169 |
||
170 |
if (outsideRange) |
|
171 |
return; |
|
172 |
||
173 |
bool jump = (data.wrect != wrect); |
|
174 |
data.wrect = wrect; |
|
175 |
||
176 |
// and now recursively for all children... |
|
177 |
for (int i = 0; i < children.size(); ++i) { |
|
178 |
QObject *object = children.at(i); |
|
179 |
if (object->isWidgetType()) { |
|
180 |
QWidget *w = static_cast<QWidget *>(object); |
|
181 |
if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) |
|
182 |
w->d_func()->setWSGeometry(jump); |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
if (data.winid) { |
|
187 |
// move ourselves to the new position and map (if necessary) after |
|
188 |
// the movement. Rationale: moving unmapped windows is much faster |
|
189 |
// than moving mapped windows |
|
190 |
if (!parent->internalWinId()) |
|
191 |
xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0))); |
|
192 |
||
193 |
data.winid->SetExtent(TPoint(xrect.x(), xrect.y()), TSize(xrect.width(), xrect.height())); |
|
194 |
} |
|
195 |
||
196 |
if (mapWindow and !dontShow) { |
|
197 |
q->setAttribute(Qt::WA_Mapped); |
|
198 |
if (q->internalWinId()) |
|
199 |
q->internalWinId()->DrawableWindow()->SetVisible(ETrue); |
|
200 |
} |
|
201 |
||
202 |
if (jump && data.winid) { |
|
203 |
RWindow *const window = static_cast<RWindow *>(data.winid->DrawableWindow()); |
|
204 |
window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) |
|
209 |
{ |
|
210 |
Q_Q(QWidget); |
|
211 |
||
212 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
213 |
||
214 |
if ((q->windowType() == Qt::Desktop)) |
|
215 |
return; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
QPoint oldPos(q->pos()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
QSize oldSize(q->size()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
QRect oldGeom(data.crect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
// Lose maximized status if deliberate resize |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
if (w != oldSize.width() || h != oldSize.height()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
data.window_state &= ~Qt::WindowMaximized; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
|
0 | 225 |
if (extra) { // any size restrictions? |
226 |
w = qMin(w,extra->maxw); |
|
227 |
h = qMin(h,extra->maxh); |
|
228 |
w = qMax(w,extra->minw); |
|
229 |
h = qMax(h,extra->minh); |
|
230 |
} |
|
231 |
||
232 |
if (q->isWindow()) |
|
233 |
topData()->normalGeometry = QRect(0, 0, -1, -1); |
|
234 |
else { |
|
235 |
uint s = data.window_state; |
|
236 |
s &= ~(Qt::WindowMaximized | Qt::WindowFullScreen); |
|
237 |
data.window_state = s; |
|
238 |
} |
|
239 |
||
240 |
bool isResize = w != oldSize.width() || h != oldSize.height(); |
|
241 |
if (!isMove && !isResize) |
|
242 |
return; |
|
243 |
||
244 |
if (q->isWindow()) { |
|
245 |
if (w == 0 || h == 0) { |
|
246 |
q->setAttribute(Qt::WA_OutsideWSRange, true); |
|
247 |
if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) |
|
248 |
hide_sys(); |
|
249 |
data.crect = QRect(x, y, w, h); |
|
250 |
data.window_state &= ~Qt::WindowFullScreen; |
|
251 |
} else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) { |
|
252 |
q->setAttribute(Qt::WA_OutsideWSRange, false); |
|
253 |
||
254 |
// put the window in its place and show it |
|
255 |
q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
|
256 |
data.crect.setRect(x, y, w, h); |
|
257 |
show_sys(); |
|
258 |
} else { |
|
259 |
QRect r = QRect(x, y, w, h); |
|
260 |
data.crect = r; |
|
261 |
q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
|
262 |
topData()->normalGeometry = data.crect; |
|
263 |
} |
|
264 |
} else { |
|
265 |
data.crect.setRect(x, y, w, h); |
|
266 |
||
267 |
QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData(); |
|
268 |
const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false; |
|
269 |
||
270 |
if (q->isVisible() && (!inTopLevelResize || q->internalWinId())) { |
|
271 |
// Top-level resize optimization does not work for native child widgets; |
|
272 |
// disable it for this particular widget. |
|
273 |
if (inTopLevelResize) |
|
274 |
tlwExtra->inTopLevelResize = false; |
|
275 |
if (!isResize && maybeBackingStore()) |
|
276 |
moveRect(QRect(oldPos, oldSize), x - oldPos.x(), y - oldPos.y()); |
|
277 |
else |
|
278 |
invalidateBuffer_resizeHelper(oldPos, oldSize); |
|
279 |
||
280 |
if (inTopLevelResize) |
|
281 |
tlwExtra->inTopLevelResize = true; |
|
282 |
} |
|
283 |
if (q->testAttribute(Qt::WA_WState_Created)) |
|
284 |
setWSGeometry(); |
|
285 |
} |
|
286 |
||
287 |
if (q->isVisible()) { |
|
288 |
if (isMove && q->pos() != oldPos) { |
|
289 |
QMoveEvent e(q->pos(), oldPos); |
|
290 |
QApplication::sendEvent(q, &e); |
|
291 |
} |
|
292 |
if (isResize) { |
|
293 |
bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt(); |
|
294 |
const bool setTopLevelResize = !slowResize && q->isWindow() && extra && extra->topextra |
|
295 |
&& !extra->topextra->inTopLevelResize; |
|
296 |
if (setTopLevelResize) |
|
297 |
extra->topextra->inTopLevelResize = true; |
|
298 |
QResizeEvent e(q->size(), oldSize); |
|
299 |
QApplication::sendEvent(q, &e); |
|
300 |
if (!q->testAttribute(Qt::WA_StaticContents) && q->internalWinId()) |
|
301 |
q->internalWinId()->DrawDeferred(); |
|
302 |
if (setTopLevelResize) |
|
303 |
extra->topextra->inTopLevelResize = false; |
|
304 |
} |
|
305 |
} else { |
|
306 |
if (isMove && q->pos() != oldPos) |
|
307 |
q->setAttribute(Qt::WA_PendingMoveEvent, true); |
|
308 |
if (isResize) |
|
309 |
q->setAttribute(Qt::WA_PendingResizeEvent, true); |
|
310 |
} |
|
311 |
} |
|
312 |
||
313 |
void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool destroyOldWindow) |
|
314 |
{ |
|
315 |
Q_Q(QWidget); |
|
316 |
||
317 |
Qt::WindowType type = q->windowType(); |
|
318 |
Qt::WindowFlags &flags = data.window_flags; |
|
319 |
QWidget *parentWidget = q->parentWidget(); |
|
320 |
||
321 |
bool topLevel = (flags & Qt::Window); |
|
322 |
bool popup = (type == Qt::Popup); |
|
323 |
bool dialog = (type == Qt::Dialog |
|
324 |
|| type == Qt::Sheet |
|
325 |
|| (flags & Qt::MSWindowsFixedSizeDialogHint)); |
|
326 |
bool desktop = (type == Qt::Desktop); |
|
327 |
//bool tool = (type == Qt::Tool || type == Qt::Drawer); |
|
328 |
||
329 |
if (popup) |
|
330 |
flags |= Qt::WindowStaysOnTopHint; // a popup stays on top |
|
331 |
||
332 |
TRect clientRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
333 |
int sw = clientRect.Width(); |
|
334 |
int sh = clientRect.Height(); |
|
335 |
||
336 |
if (desktop) { |
|
337 |
TSize screenSize = S60->screenDevice()->SizeInPixels(); |
|
338 |
data.crect.setRect(0, 0, screenSize.iWidth, screenSize.iHeight); |
|
339 |
q->setAttribute(Qt::WA_DontShowOnScreen); |
|
340 |
} else if (topLevel && !q->testAttribute(Qt::WA_Resized)){ |
|
341 |
int width = sw; |
|
342 |
int height = sh; |
|
343 |
if (extra) { |
|
344 |
width = qMax(qMin(width, extra->maxw), extra->minw); |
|
345 |
height = qMax(qMin(height, extra->maxh), extra->minh); |
|
346 |
} |
|
347 |
data.crect.setSize(QSize(width, height)); |
|
348 |
} |
|
349 |
||
350 |
CCoeControl *const destroyw = destroyOldWindow ? data.winid : 0; |
|
351 |
||
352 |
createExtra(); |
|
353 |
if (window) { |
|
354 |
setWinId(window); |
|
355 |
TRect tr = window->Rect(); |
|
356 |
data.crect.setRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); |
|
357 |
||
358 |
} else if (topLevel) { |
|
359 |
if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen)) |
|
360 |
data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); |
|
361 |
||
362 |
QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
|
363 |
QT_TRAP_THROWING(control->ConstructL(true, desktop)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi())); |
0 | 365 |
|
366 |
// Symbian windows are always created in an inactive state |
|
367 |
// We perform this assignment for the case where the window is being re-created |
|
368 |
// as aa result of a call to setParent_sys, on either this widget or one of its |
|
369 |
// ancestors. |
|
370 |
extra->activated = 0; |
|
371 |
||
372 |
if (!desktop) { |
|
373 |
TInt stackingFlags; |
|
374 |
if ((q->windowType() & Qt::Popup) == Qt::Popup) { |
|
375 |
stackingFlags = ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus; |
|
376 |
} else { |
|
377 |
stackingFlags = ECoeStackFlagStandard; |
|
378 |
} |
|
379 |
control->MakeVisible(false); |
|
380 |
QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags)); |
|
381 |
// Avoid keyboard focus to a hidden window. |
|
382 |
control->setFocusSafely(false); |
|
383 |
||
384 |
RDrawableWindow *const drawableWindow = control->DrawableWindow(); |
|
385 |
// Request mouse move events. |
|
386 |
drawableWindow->PointerFilter(EPointerFilterEnterExit |
|
387 |
| EPointerFilterMove | EPointerFilterDrag, 0); |
|
388 |
drawableWindow->EnableVisibilityChangeEvents(); |
|
389 |
||
12
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
390 |
s60UpdateIsOpaque(); |
0 | 391 |
} |
392 |
||
393 |
q->setAttribute(Qt::WA_WState_Created); |
|
394 |
||
395 |
int x, y, w, h; |
|
396 |
data.crect.getRect(&x, &y, &w, &h); |
|
397 |
control->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
|
398 |
||
399 |
// We wait until the control is fully constructed before calling setWinId, because |
|
400 |
// this generates a WinIdChanged event. |
|
401 |
setWinId(control.take()); |
|
402 |
||
403 |
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget |
|
404 |
||
405 |
QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
|
406 |
QT_TRAP_THROWING(control->ConstructL(!parentWidget)); |
|
407 |
||
408 |
// Symbian windows are always created in an inactive state |
|
409 |
// We perform this assignment for the case where the window is being re-created |
|
410 |
// as aa result of a call to setParent_sys, on either this widget or one of its |
|
411 |
// ancestors. |
|
412 |
extra->activated = 0; |
|
413 |
||
414 |
TInt stackingFlags; |
|
415 |
if ((q->windowType() & Qt::Popup) == Qt::Popup) { |
|
416 |
stackingFlags = ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus; |
|
417 |
} else { |
|
418 |
stackingFlags = ECoeStackFlagStandard; |
|
419 |
} |
|
420 |
control->MakeVisible(false); |
|
421 |
QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control.data(), ECoeStackPriorityDefault, stackingFlags)); |
|
422 |
// Avoid keyboard focus to a hidden window. |
|
423 |
control->setFocusSafely(false); |
|
424 |
||
425 |
q->setAttribute(Qt::WA_WState_Created); |
|
426 |
int x, y, w, h; |
|
427 |
data.crect.getRect(&x, &y, &w, &h); |
|
428 |
control->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
|
429 |
||
430 |
RDrawableWindow *const drawableWindow = control->DrawableWindow(); |
|
431 |
// Request mouse move events. |
|
432 |
drawableWindow->PointerFilter(EPointerFilterEnterExit |
|
433 |
| EPointerFilterMove | EPointerFilterDrag, 0); |
|
434 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
435 |
if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { |
0 | 436 |
activateSymbianWindow(control.data()); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
437 |
control->MakeVisible(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
} |
0 | 439 |
|
440 |
// We wait until the control is fully constructed before calling setWinId, because |
|
441 |
// this generates a WinIdChanged event. |
|
442 |
setWinId(control.take()); |
|
443 |
} |
|
444 |
||
445 |
if (destroyw) { |
|
446 |
destroyw->ControlEnv()->AppUi()->RemoveFromStack(destroyw); |
|
447 |
||
448 |
// Delay deletion of the control in case this function is called in the |
|
449 |
// context of a CONE event handler such as |
|
450 |
// CCoeControl::ProcessPointerEventL |
|
451 |
QMetaObject::invokeMethod(q, "_q_delayedDestroy", |
|
452 |
Qt::QueuedConnection, Q_ARG(WId, destroyw)); |
|
453 |
} |
|
454 |
||
455 |
if (q->testAttribute(Qt::WA_AcceptTouchEvents)) |
|
456 |
registerTouchWindow(); |
|
457 |
} |
|
458 |
||
459 |
||
460 |
void QWidgetPrivate::show_sys() |
|
461 |
{ |
|
462 |
Q_Q(QWidget); |
|
463 |
||
464 |
if (q->testAttribute(Qt::WA_OutsideWSRange)) |
|
465 |
return; |
|
466 |
||
467 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
468 |
||
469 |
q->setAttribute(Qt::WA_Mapped); |
|
470 |
||
471 |
if (q->testAttribute(Qt::WA_DontShowOnScreen)) { |
|
472 |
invalidateBuffer(q->rect()); |
|
473 |
return; |
|
474 |
} |
|
475 |
||
476 |
if (q->internalWinId()) { |
|
477 |
if (!extra->activated) |
|
478 |
activateSymbianWindow(); |
|
479 |
||
480 |
QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); |
|
481 |
||
482 |
id->MakeVisible(true); |
|
483 |
||
484 |
if(q->isWindow()) |
|
485 |
id->setFocusSafely(true); |
|
486 |
} |
|
487 |
||
488 |
invalidateBuffer(q->rect()); |
|
489 |
} |
|
490 |
||
491 |
void QWidgetPrivate::activateSymbianWindow(WId wid) |
|
492 |
{ |
|
493 |
Q_Q(QWidget); |
|
494 |
||
495 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
496 |
Q_ASSERT(q->testAttribute(Qt::WA_Mapped)); |
|
497 |
Q_ASSERT(!extra->activated); |
|
498 |
||
499 |
if(!wid) |
|
500 |
wid = q->internalWinId(); |
|
501 |
||
502 |
Q_ASSERT(wid); |
|
503 |
||
504 |
QT_TRAP_THROWING(wid->ActivateL()); |
|
505 |
extra->activated = 1; |
|
506 |
} |
|
507 |
||
508 |
void QWidgetPrivate::hide_sys() |
|
509 |
{ |
|
510 |
Q_Q(QWidget); |
|
511 |
||
512 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
513 |
deactivateWidgetCleanup(); |
|
514 |
QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); |
|
515 |
||
516 |
if (id) { |
|
517 |
//Incorrect optimisation - for popup windows, Qt's focus is moved before |
|
518 |
//hide_sys is called, resulting in the popup window keeping its elevated |
|
519 |
//position in the CONE control stack. |
|
520 |
//This can result in keyboard focus being in an invisible widget in some |
|
521 |
//conditions - e.g. QTBUG-4733 |
|
522 |
//if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() |
|
523 |
id->setFocusSafely(false); |
|
524 |
id->MakeVisible(false); |
|
525 |
if (QWidgetBackingStore *bs = maybeBackingStore()) |
|
526 |
bs->releaseBuffer(); |
|
527 |
} else { |
|
528 |
invalidateBuffer(q->rect()); |
|
529 |
} |
|
530 |
||
531 |
q->setAttribute(Qt::WA_Mapped, false); |
|
532 |
} |
|
533 |
||
534 |
void QWidgetPrivate::setFocus_sys() |
|
535 |
{ |
|
536 |
Q_Q(QWidget); |
|
537 |
if (q->testAttribute(Qt::WA_WState_Created) && q->window()->windowType() != Qt::Popup) |
|
538 |
if (!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged() |
|
539 |
static_cast<QSymbianControl *>(q->effectiveWinId())->setFocusSafely(true); |
|
540 |
} |
|
541 |
||
542 |
void QWidgetPrivate::raise_sys() |
|
543 |
{ |
|
544 |
Q_Q(QWidget); |
|
545 |
||
546 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
547 |
if (q->internalWinId()) { |
|
548 |
q->internalWinId()->DrawableWindow()->SetOrdinalPosition(0); |
|
549 |
||
550 |
// If toplevel widget, raise app to foreground |
|
551 |
if (q->isWindow()) |
|
552 |
S60->wsSession().SetWindowGroupOrdinalPosition(S60->windowGroup().Identifier(), 0); |
|
553 |
} |
|
554 |
} |
|
555 |
||
556 |
void QWidgetPrivate::lower_sys() |
|
557 |
{ |
|
558 |
Q_Q(QWidget); |
|
559 |
||
560 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
561 |
if (q->internalWinId()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
562 |
// If toplevel widget, lower app to background |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
if (q->isWindow()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
S60->wsSession().SetWindowGroupOrdinalPosition(S60->windowGroup().Identifier(), -1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
566 |
q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
} |
0 | 568 |
|
569 |
if (!q->isWindow()) |
|
570 |
invalidateBuffer(q->rect()); |
|
571 |
} |
|
572 |
||
573 |
void QWidgetPrivate::setModal_sys() |
|
574 |
{ |
|
575 |
||
576 |
} |
|
577 |
||
578 |
void QWidgetPrivate::stackUnder_sys(QWidget* w) |
|
579 |
{ |
|
580 |
Q_Q(QWidget); |
|
581 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
582 |
||
583 |
if (q->internalWinId() && w->internalWinId()) { |
|
584 |
RDrawableWindow *const thisWindow = q->internalWinId()->DrawableWindow(); |
|
585 |
RDrawableWindow *const otherWindow = w->internalWinId()->DrawableWindow(); |
|
586 |
thisWindow->SetOrdinalPosition(otherWindow->OrdinalPosition() + 1); |
|
587 |
} |
|
588 |
||
589 |
if (!q->isWindow() || !w->internalWinId()) |
|
590 |
invalidateBuffer(q->rect()); |
|
591 |
} |
|
592 |
||
593 |
void QWidgetPrivate::reparentChildren() |
|
594 |
{ |
|
595 |
Q_Q(QWidget); |
|
596 |
||
597 |
QObjectList chlist = q->children(); |
|
598 |
for (int i = 0; i < chlist.size(); ++i) { // reparent children |
|
599 |
QObject *obj = chlist.at(i); |
|
600 |
if (obj->isWidgetType()) { |
|
601 |
QWidget *w = (QWidget *)obj; |
|
602 |
if (!w->testAttribute(Qt::WA_WState_Created)) |
|
603 |
continue; |
|
604 |
if (!w->isWindow()) { |
|
605 |
w->d_func()->invalidateBuffer(w->rect()); |
|
606 |
WId parent = q->effectiveWinId(); |
|
607 |
WId child = w->effectiveWinId(); |
|
608 |
if (parent != child) { |
|
609 |
// Child widget is native. Because Symbian windows cannot be |
|
610 |
// re-parented, we must re-create the window. |
|
611 |
const WId window = 0; |
|
612 |
const bool initializeWindow = false; |
|
613 |
const bool destroyOldWindow = true; |
|
614 |
w->d_func()->create_sys(window, initializeWindow, destroyOldWindow); |
|
615 |
} |
|
616 |
// ### TODO: We probably also need to update the component array here |
|
617 |
w->d_func()->reparentChildren(); |
|
618 |
} else { |
|
619 |
bool showIt = w->isVisible(); |
|
620 |
QPoint old_pos = w->pos(); |
|
621 |
w->setParent(q, w->windowFlags()); |
|
622 |
w->move(old_pos); |
|
623 |
if (showIt) |
|
624 |
w->show(); |
|
625 |
} |
|
626 |
} |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) |
|
631 |
{ |
|
632 |
Q_Q(QWidget); |
|
633 |
||
634 |
bool wasCreated = q->testAttribute(Qt::WA_WState_Created); |
|
635 |
||
636 |
if (q->isVisible() && q->parentWidget() && parent != q->parentWidget()) |
|
637 |
q->parentWidget()->d_func()->invalidateBuffer(q->geometry()); |
|
638 |
||
639 |
if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
|
640 |
q->setAttribute(Qt::WA_DropSiteRegistered, false); |
|
641 |
||
642 |
QSymbianControl *old_winid = static_cast<QSymbianControl *>(wasCreated ? data.winid : 0); |
|
643 |
if ((q->windowType() == Qt::Desktop)) |
|
644 |
old_winid = 0; |
|
645 |
setWinId(0); |
|
646 |
||
647 |
// hide and reparent our own window away. Otherwise we might get |
|
648 |
// destroyed when emitting the child remove event below. See QWorkspace. |
|
649 |
if (wasCreated && old_winid) { |
|
650 |
old_winid->MakeVisible(false); |
|
651 |
if (old_winid->IsFocused()) // Avoid unnecessary calls to FocusChanged() |
|
652 |
old_winid->setFocusSafely(false); |
|
653 |
old_winid->SetParent(0); |
|
654 |
} |
|
655 |
||
656 |
QObjectPrivate::setParent_helper(parent); |
|
657 |
bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); |
|
658 |
||
659 |
data.window_flags = f; |
|
660 |
data.fstrut_dirty = true; |
|
661 |
q->setAttribute(Qt::WA_WState_Created, false); |
|
662 |
q->setAttribute(Qt::WA_WState_Visible, false); |
|
663 |
q->setAttribute(Qt::WA_WState_Hidden, false); |
|
664 |
adjustFlags(data.window_flags, q); |
|
665 |
// keep compatibility with previous versions, we need to preserve the created state |
|
666 |
// (but we recreate the winId for the widget being reparented, again for compatibility) |
|
667 |
if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) |
|
668 |
createWinId(); |
|
669 |
if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden) |
|
670 |
q->setAttribute(Qt::WA_WState_Hidden); |
|
671 |
q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); |
|
672 |
||
673 |
if (wasCreated) |
|
674 |
reparentChildren(); |
|
675 |
||
676 |
if (old_winid) { |
|
677 |
CBase::Delete(old_winid); |
|
678 |
} |
|
679 |
||
680 |
if (q->testAttribute(Qt::WA_AcceptDrops) |
|
681 |
|| (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) |
|
682 |
q->setAttribute(Qt::WA_DropSiteRegistered, true); |
|
683 |
||
684 |
invalidateBuffer(q->rect()); |
|
685 |
} |
|
686 |
||
687 |
void QWidgetPrivate::setConstraints_sys() |
|
688 |
{ |
|
689 |
||
690 |
} |
|
691 |
||
692 |
||
693 |
void QWidgetPrivate::s60UpdateIsOpaque() |
|
694 |
{ |
|
695 |
Q_Q(QWidget); |
|
696 |
||
697 |
if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground)) |
|
698 |
return; |
|
699 |
||
700 |
if ((data.window_flags & Qt::FramelessWindowHint) == 0) |
|
701 |
return; |
|
702 |
||
703 |
RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); |
|
704 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
705 |
#ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
706 |
window->SetSurfaceTransparency(!isOpaque); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
707 |
#else |
0 | 708 |
if (!isOpaque) { |
709 |
const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); |
|
710 |
if (window->SetTransparencyAlphaChannel() == KErrNone) |
|
711 |
window->SetBackgroundColor(TRgb(255, 255, 255, 0)); |
|
712 |
} else |
|
713 |
window->SetTransparentRegion(TRegionFix<1>()); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
714 |
#endif |
0 | 715 |
} |
716 |
||
717 |
void QWidgetPrivate::setWindowIcon_sys(bool forceReset) |
|
718 |
{ |
|
719 |
#ifdef Q_WS_S60 |
|
720 |
Q_Q(QWidget); |
|
721 |
||
722 |
if (!q->testAttribute(Qt::WA_WState_Created) || !q->isWindow() ) |
|
723 |
return; |
|
724 |
||
725 |
QTLWExtra* topData = this->topData(); |
|
726 |
if (topData->iconPixmap && !forceReset) |
|
727 |
// already been set |
|
728 |
return; |
|
729 |
||
730 |
TRect cPaneRect; |
|
731 |
TBool found = AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EContextPane, cPaneRect ); |
|
732 |
CAknContextPane* contextPane = S60->contextPane(); |
|
733 |
if (found && contextPane) { // We have context pane with valid metrics |
|
734 |
QIcon icon = q->windowIcon(); |
|
735 |
if (!icon.isNull()) { |
|
736 |
// Valid icon -> set it as an context pane picture |
|
737 |
QSize size = icon.actualSize(QSize(cPaneRect.Size().iWidth, cPaneRect.Size().iHeight)); |
|
738 |
QPixmap pm = icon.pixmap(size); |
|
739 |
QBitmap mask = pm.mask(); |
|
740 |
if (mask.isNull()) { |
|
741 |
mask = QBitmap(pm.size()); |
|
742 |
mask.fill(Qt::color1); |
|
743 |
} |
|
744 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
745 |
CFbsBitmap* nBitmap = pm.toSymbianCFbsBitmap(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
746 |
CFbsBitmap* nMask = mask.toSymbianCFbsBitmap(); |
0 | 747 |
contextPane->SetPicture(nBitmap,nMask); |
748 |
} else { |
|
749 |
// Icon set to null -> set context pane picture to default |
|
750 |
QT_TRAP_THROWING(contextPane->SetPictureToDefaultL()); |
|
751 |
} |
|
752 |
} else { |
|
753 |
// Context pane does not exist, try setting small icon to title pane |
|
754 |
TRect titlePaneRect; |
|
755 |
TBool found = AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, titlePaneRect ); |
|
756 |
CAknTitlePane* titlePane = S60->titlePane(); |
|
757 |
if (found && titlePane) { // We have title pane with valid metrics |
|
758 |
// The API to get title_pane graphics size is not public -> assume square space based |
|
759 |
// on titlebar font height. CAknBitmap would be optimum, wihtout setting the size, since |
|
760 |
// then title pane would automatically scale the bitmap. Unfortunately it is not public API |
|
761 |
// Also this function is leaving, although it is not named as such. |
|
762 |
const CFont * font; |
|
763 |
QT_TRAP_THROWING(font = AknLayoutUtils::FontFromId(EAknLogicalFontTitleFont)); |
|
764 |
TSize iconSize(font->HeightInPixels(), font->HeightInPixels()); |
|
765 |
||
766 |
QIcon icon = q->windowIcon(); |
|
767 |
if (!icon.isNull()) { |
|
768 |
// Valid icon -> set it as an title pane small picture |
|
769 |
QSize size = icon.actualSize(QSize(iconSize.iWidth, iconSize.iHeight)); |
|
770 |
QPixmap pm = icon.pixmap(size); |
|
771 |
QBitmap mask = pm.mask(); |
|
772 |
if (mask.isNull()) { |
|
773 |
mask = QBitmap(pm.size()); |
|
774 |
mask.fill(Qt::color1); |
|
775 |
} |
|
776 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
CFbsBitmap* nBitmap = pm.toSymbianCFbsBitmap(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
778 |
CFbsBitmap* nMask = mask.toSymbianCFbsBitmap(); |
0 | 779 |
titlePane->SetSmallPicture( nBitmap, nMask, ETrue ); |
780 |
} else { |
|
781 |
// Icon set to null -> set context pane picture to default |
|
782 |
titlePane->SetSmallPicture( NULL, NULL, EFalse ); |
|
783 |
} |
|
784 |
} |
|
785 |
} |
|
786 |
||
787 |
#else |
|
788 |
Q_UNUSED(forceReset) |
|
789 |
#endif |
|
790 |
} |
|
791 |
||
792 |
void QWidgetPrivate::setWindowTitle_sys(const QString &caption) |
|
793 |
{ |
|
794 |
#ifdef Q_WS_S60 |
|
795 |
Q_Q(QWidget); |
|
796 |
if (q->isWindow()) { |
|
797 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
798 |
CAknTitlePane* titlePane = S60->titlePane(); |
|
799 |
if (titlePane) { |
|
800 |
if (caption.isEmpty()) { |
|
801 |
QT_TRAP_THROWING(titlePane->SetTextToDefaultL()); |
|
802 |
} else { |
|
803 |
QT_TRAP_THROWING(titlePane->SetTextL(qt_QString2TPtrC(caption))); |
|
804 |
} |
|
805 |
} |
|
806 |
} |
|
807 |
#else |
|
808 |
Q_UNUSED(caption) |
|
809 |
#endif |
|
810 |
} |
|
811 |
||
812 |
void QWidgetPrivate::setWindowIconText_sys(const QString & /*iconText */) |
|
813 |
{ |
|
814 |
||
815 |
} |
|
816 |
||
817 |
void QWidgetPrivate::scroll_sys(int dx, int dy) |
|
818 |
{ |
|
819 |
Q_Q(QWidget); |
|
820 |
||
821 |
scrollChildren(dx, dy); |
|
822 |
if (!paintOnScreen() || !q->internalWinId() || !q->internalWinId()->OwnsWindow()) { |
|
823 |
scrollRect(q->rect(), dx, dy); |
|
824 |
} else { |
|
825 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
826 |
RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); |
|
827 |
window->Scroll(TPoint(dx, dy)); |
|
828 |
} |
|
829 |
} |
|
830 |
||
831 |
void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) |
|
832 |
{ |
|
833 |
Q_Q(QWidget); |
|
834 |
||
835 |
if (!paintOnScreen() || !q->internalWinId() || !q->internalWinId()->OwnsWindow()) { |
|
836 |
scrollRect(r, dx, dy); |
|
837 |
} else { |
|
838 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
839 |
RDrawableWindow *const window = q->internalWinId()->DrawableWindow(); |
|
840 |
window->Scroll(TPoint(dx, dy), qt_QRect2TRect(r)); |
|
841 |
} |
|
842 |
} |
|
843 |
||
844 |
/*! |
|
845 |
For this function to work in the emulator, you must add: |
|
846 |
TRANSPARENCY |
|
847 |
To a line in the wsini.ini file. |
|
848 |
*/ |
|
849 |
void QWidgetPrivate::setWindowOpacity_sys(qreal) |
|
850 |
{ |
|
851 |
// ### TODO: Implement uniform window transparency |
|
852 |
} |
|
853 |
||
854 |
void QWidgetPrivate::updateFrameStrut() |
|
855 |
{ |
|
856 |
||
857 |
} |
|
858 |
||
859 |
void QWidgetPrivate::updateSystemBackground() |
|
860 |
{ |
|
861 |
||
862 |
} |
|
863 |
||
864 |
void QWidgetPrivate::registerDropSite(bool /* on */) |
|
865 |
{ |
|
866 |
||
867 |
} |
|
868 |
||
869 |
void QWidgetPrivate::createTLSysExtra() |
|
870 |
{ |
|
871 |
extra->topextra->backingStore = 0; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
872 |
extra->topextra->inExpose = 0; |
0 | 873 |
} |
874 |
||
875 |
void QWidgetPrivate::deleteTLSysExtra() |
|
876 |
{ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
877 |
delete extra->topextra->backingStore; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
878 |
extra->topextra->backingStore = 0; |
0 | 879 |
} |
880 |
||
881 |
void QWidgetPrivate::createSysExtra() |
|
882 |
{ |
|
883 |
extra->activated = 0; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
extra->nativePaintMode = QWExtra::Default; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
extra->receiveNativePaintEvents = 0; |
0 | 886 |
} |
887 |
||
888 |
void QWidgetPrivate::deleteSysExtra() |
|
889 |
{ |
|
890 |
// this should only be non-zero if destroy() has not run due to constructor fail |
|
891 |
if (data.winid) { |
|
892 |
data.winid->ControlEnv()->AppUi()->RemoveFromStack(data.winid); |
|
893 |
delete data.winid; |
|
894 |
data.winid = 0; |
|
895 |
} |
|
896 |
} |
|
897 |
||
898 |
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() |
|
899 |
{ |
|
900 |
return new QS60WindowSurface(q_func()); |
|
901 |
} |
|
902 |
||
903 |
void QWidgetPrivate::setMask_sys(const QRegion& /* region */) |
|
904 |
{ |
|
905 |
||
906 |
} |
|
907 |
||
908 |
void QWidgetPrivate::registerTouchWindow() |
|
909 |
{ |
|
910 |
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
|
911 |
Q_Q(QWidget); |
|
912 |
if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) { |
|
913 |
RWindow *rwindow = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); |
|
914 |
rwindow->EnableAdvancedPointers(); |
|
915 |
} |
|
916 |
#endif |
|
917 |
} |
|
918 |
||
919 |
int QWidget::metric(PaintDeviceMetric m) const |
|
920 |
{ |
|
921 |
Q_D(const QWidget); |
|
922 |
int val; |
|
923 |
if (m == PdmWidth) { |
|
924 |
val = data->crect.width(); |
|
925 |
} else if (m == PdmHeight) { |
|
926 |
val = data->crect.height(); |
|
927 |
} else { |
|
928 |
CWsScreenDevice *scr = S60->screenDevice(); |
|
929 |
switch(m) { |
|
930 |
case PdmDpiX: |
|
931 |
case PdmPhysicalDpiX: |
|
932 |
if (d->extra && d->extra->customDpiX) { |
|
933 |
val = d->extra->customDpiX; |
|
934 |
} else { |
|
935 |
const QWidgetPrivate *p = d; |
|
936 |
while (p->parent) { |
|
937 |
p = static_cast<const QWidget *>(p->parent)->d_func(); |
|
938 |
if (p->extra && p->extra->customDpiX) { |
|
939 |
val = p->extra->customDpiX; |
|
940 |
break; |
|
941 |
} |
|
942 |
} |
|
943 |
if (p == d || !(p->extra && p->extra->customDpiX)) |
|
944 |
val = S60->defaultDpiX; |
|
945 |
} |
|
946 |
break; |
|
947 |
case PdmDpiY: |
|
948 |
case PdmPhysicalDpiY: |
|
949 |
if (d->extra && d->extra->customDpiY) { |
|
950 |
val = d->extra->customDpiY; |
|
951 |
} else { |
|
952 |
const QWidgetPrivate *p = d; |
|
953 |
while (p->parent) { |
|
954 |
p = static_cast<const QWidget *>(p->parent)->d_func(); |
|
955 |
if (p->extra && p->extra->customDpiY) { |
|
956 |
val = p->extra->customDpiY; |
|
957 |
break; |
|
958 |
} |
|
959 |
} |
|
960 |
if (p == d || !(p->extra && p->extra->customDpiY)) |
|
961 |
val = S60->defaultDpiY; |
|
962 |
} |
|
963 |
break; |
|
964 |
case PdmWidthMM: |
|
965 |
{ |
|
966 |
TInt twips = scr->HorizontalPixelsToTwips(data->crect.width()); |
|
967 |
val = (int)(twips * (25.4/KTwipsPerInch)); |
|
968 |
break; |
|
969 |
} |
|
970 |
case PdmHeightMM: |
|
971 |
{ |
|
972 |
TInt twips = scr->VerticalPixelsToTwips(data->crect.height()); |
|
973 |
val = (int)(twips * (25.4/KTwipsPerInch)); |
|
974 |
break; |
|
975 |
} |
|
976 |
case PdmNumColors: |
|
977 |
val = TDisplayModeUtils::NumDisplayModeColors(scr->DisplayMode()); |
|
978 |
break; |
|
979 |
case PdmDepth: |
|
980 |
val = TDisplayModeUtils::NumDisplayModeBitsPerPixel(scr->DisplayMode()); |
|
981 |
break; |
|
982 |
default: |
|
983 |
val = 0; |
|
984 |
qWarning("QWidget::metric: Invalid metric command"); |
|
985 |
} |
|
986 |
} |
|
987 |
return val; |
|
988 |
} |
|
989 |
||
990 |
QPaintEngine *QWidget::paintEngine() const |
|
991 |
{ |
|
992 |
return 0; |
|
993 |
} |
|
994 |
||
995 |
QPoint QWidget::mapToGlobal(const QPoint &pos) const |
|
996 |
{ |
|
997 |
Q_D(const QWidget); |
|
998 |
if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { |
|
999 |
||
1000 |
QPoint p = pos + data->crect.topLeft(); |
|
1001 |
return (isWindow() || !parentWidget()) ? p : parentWidget()->mapToGlobal(p); |
|
1002 |
||
1003 |
} else if ((d->data.window_flags & Qt::Window) && internalWinId()) { //toplevel |
|
1004 |
QPoint tp = geometry().topLeft(); |
|
1005 |
return pos + tp; |
|
1006 |
} |
|
1007 |
||
1008 |
// Native window case |
|
1009 |
const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); |
|
1010 |
const QPoint globalPos = QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY) + pos; |
|
1011 |
return globalPos; |
|
1012 |
} |
|
1013 |
||
1014 |
QPoint QWidget::mapFromGlobal(const QPoint &pos) const |
|
1015 |
{ |
|
1016 |
Q_D(const QWidget); |
|
1017 |
if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { |
|
1018 |
QPoint p = (isWindow() || !parentWidget()) ? pos : parentWidget()->mapFromGlobal(pos); |
|
1019 |
return p - data->crect.topLeft(); |
|
1020 |
} else if ((d->data.window_flags & Qt::Window) && internalWinId()) { //toplevel |
|
1021 |
QPoint tp = geometry().topLeft(); |
|
1022 |
return pos - tp; |
|
1023 |
} |
|
1024 |
||
1025 |
// Native window case |
|
1026 |
const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); |
|
1027 |
const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY); |
|
1028 |
return widgetPos; |
|
1029 |
} |
|
1030 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1031 |
static Qt::WindowStates effectiveState(Qt::WindowStates state) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1032 |
{ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1033 |
if (state & Qt::WindowMinimized) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1034 |
return Qt::WindowMinimized; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1035 |
else if (state & Qt::WindowFullScreen) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1036 |
return Qt::WindowFullScreen; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1037 |
else if (state & Qt::WindowMaximized) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1038 |
return Qt::WindowMaximized; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1039 |
return Qt::WindowNoState; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1040 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1041 |
|
0 | 1042 |
void QWidget::setWindowState(Qt::WindowStates newstate) |
1043 |
{ |
|
1044 |
Q_D(QWidget); |
|
1045 |
||
1046 |
Qt::WindowStates oldstate = windowState(); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1047 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1048 |
const TBool isFullscreen = newstate & Qt::WindowFullScreen; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1049 |
const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1050 |
const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1051 |
const TBool softkeyVisibilityChange = isFullscreen && (cbaRequested != cbaVisible); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1052 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1053 |
if (oldstate == newstate && !softkeyVisibilityChange) |
0 | 1054 |
return; |
1055 |
||
1056 |
if (isWindow()) { |
|
12
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1057 |
createWinId(); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1058 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1059 |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1060 |
const bool wasResized = testAttribute(Qt::WA_Resized); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1061 |
const bool wasMoved = testAttribute(Qt::WA_Moved); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1062 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1063 |
QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId()); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1064 |
if (window && newstate & Qt::WindowMinimized) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1065 |
window->setFocusSafely(false); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1066 |
window->MakeVisible(false); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1067 |
} else if (window && oldstate & Qt::WindowMinimized) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1068 |
window->setFocusSafely(true); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1069 |
window->MakeVisible(true); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1070 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1071 |
|
0 | 1072 |
#ifdef Q_WS_S60 |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1073 |
// Hide window decoration when switching to fullsccreen / minimized otherwise show decoration. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1074 |
// The window decoration visibility has to be changed before doing actual window state |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1075 |
// change since in that order the availableGeometry will return directly the right size and |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1076 |
// we will avoid unnecessarty redraws |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1077 |
CEikStatusPane *statusPane = S60->statusPane(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1078 |
CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1079 |
TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1080 |
if (statusPane) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1081 |
statusPane->MakeVisible(visible); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1082 |
if (buttonGroup) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1083 |
// Visibility |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1084 |
buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested)); |
0 | 1085 |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1086 |
// Responsiviness |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1087 |
CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1088 |
TUint cbaFlags = cba->ButtonGroupFlags(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1089 |
if(windowFlags() & Qt::WindowSoftkeysRespondHint) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1090 |
cbaFlags |= EAknCBAFlagRespondWhenInvisible; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1091 |
else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1092 |
cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1093 |
cba->SetButtonGroupFlags(cbaFlags); |
0 | 1094 |
} |
1095 |
#endif // Q_WS_S60 |
|
1096 |
||
1097 |
// Ensure the initial size is valid, since we store it as normalGeometry below. |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1098 |
if (!wasResized && !isVisible()) |
0 | 1099 |
adjustSize(); |
1100 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1101 |
QTLWExtra *top = d->topData(); |
12
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1102 |
QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; |
0 | 1103 |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1104 |
const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; |
12
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1105 |
if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1106 |
window->SetExtentToWholeScreen(); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1107 |
} else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1108 |
TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1109 |
window->SetExtent(maxExtent.iTl, maxExtent.Size()); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1110 |
} else { |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1111 |
#ifdef Q_WS_S60 |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1112 |
// With delayed creation of S60 app panes, the normalGeometry calculated above is not |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1113 |
// accurate because it did not consider the status pane. This means that when returning |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1114 |
// normal mode after showing the status pane, the geometry would overlap so we should |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1115 |
// move it if it never had an explicit position. |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1116 |
if (!wasMoved && statusPane && visible) { |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1117 |
TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl; |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1118 |
normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1119 |
} |
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1120 |
#endif |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1121 |
setGeometry(normalGeometry); |
12
25a739ee40f4
3a438a6e0b41f1ef657ef0e648d352db636204aa
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1122 |
} |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1123 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1124 |
//restore normal geometry |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1125 |
top->normalGeometry = normalGeometry; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1126 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1127 |
// FixMe QTBUG-8977 |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1128 |
// In some platforms, WA_Resized and WA_Moved are also not set when application window state is |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1129 |
// anything else than normal. In Symbian we can restore them only for normal window state since |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1130 |
// restoring for other modes, will make fluidlauncher to be launched in wrong size (200x100) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1131 |
if (effectiveState(newstate) == Qt::WindowNoState) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1132 |
setAttribute(Qt::WA_Resized, wasResized); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1133 |
setAttribute(Qt::WA_Moved, wasMoved); |
0 | 1134 |
} |
1135 |
} |
|
1136 |
||
1137 |
data->window_state = newstate; |
|
1138 |
||
1139 |
if (newstate & Qt::WindowActive) |
|
1140 |
activateWindow(); |
|
1141 |
||
1142 |
QWindowStateChangeEvent e(oldstate); |
|
1143 |
QApplication::sendEvent(this, &e); |
|
1144 |
} |
|
1145 |
||
1146 |
||
1147 |
void QWidget::destroy(bool destroyWindow, bool destroySubWindows) |
|
1148 |
{ |
|
1149 |
Q_D(QWidget); |
|
1150 |
if (!isWindow() && parentWidget()) |
|
1151 |
parentWidget()->d_func()->invalidateBuffer(geometry()); |
|
1152 |
d->deactivateWidgetCleanup(); |
|
1153 |
QSymbianControl *id = static_cast<QSymbianControl *>(internalWinId()); |
|
1154 |
if (testAttribute(Qt::WA_WState_Created)) { |
|
1155 |
||
1156 |
#ifndef QT_NO_IM |
|
1157 |
if (d->ic) { |
|
1158 |
delete d->ic; |
|
1159 |
} else { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1160 |
QInputContext *ic = QApplicationPrivate::inputContext; |
0 | 1161 |
if (ic) { |
1162 |
ic->widgetDestroyed(this); |
|
1163 |
} |
|
1164 |
} |
|
1165 |
#endif |
|
1166 |
||
1167 |
if (QWidgetPrivate::mouseGrabber == this) |
|
1168 |
releaseMouse(); |
|
1169 |
if (QWidgetPrivate::keyboardGrabber == this) |
|
1170 |
releaseKeyboard(); |
|
1171 |
setAttribute(Qt::WA_WState_Created, false); |
|
1172 |
QObjectList childList = children(); |
|
1173 |
for (int i = 0; i < childList.size(); ++i) { // destroy all widget children |
|
1174 |
register QObject *obj = childList.at(i); |
|
1175 |
if (obj->isWidgetType()) |
|
1176 |
static_cast<QWidget*>(obj)->destroy(destroySubWindows, |
|
1177 |
destroySubWindows); |
|
1178 |
} |
|
1179 |
if (destroyWindow && !(windowType() == Qt::Desktop) && id) { |
|
1180 |
if (id->IsFocused()) // Avoid unnecessry calls to FocusChanged() |
|
1181 |
id->setFocusSafely(false); |
|
1182 |
id->ControlEnv()->AppUi()->RemoveFromStack(id); |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
QT_TRY { |
|
1187 |
d->setWinId(0); |
|
1188 |
} QT_CATCH (const std::bad_alloc &) { |
|
1189 |
// swallow - destructors must not throw |
|
1190 |
} |
|
1191 |
||
1192 |
if (destroyWindow) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1193 |
delete id; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1194 |
// At this point the backing store should already be destroyed |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1195 |
// so we flush the command buffer to ensure that the freeing of |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1196 |
// those resources and deleting the window can happen "atomically" |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1197 |
S60->wsSession().Flush(); |
0 | 1198 |
} |
1199 |
} |
|
1200 |
||
1201 |
QWidget *QWidget::mouseGrabber() |
|
1202 |
{ |
|
1203 |
return QWidgetPrivate::mouseGrabber; |
|
1204 |
} |
|
1205 |
||
1206 |
QWidget *QWidget::keyboardGrabber() |
|
1207 |
{ |
|
1208 |
return QWidgetPrivate::keyboardGrabber; |
|
1209 |
} |
|
1210 |
||
1211 |
void QWidget::grabKeyboard() |
|
1212 |
{ |
|
1213 |
if (!qt_nograb()) { |
|
1214 |
if (QWidgetPrivate::keyboardGrabber && QWidgetPrivate::keyboardGrabber != this) |
|
1215 |
QWidgetPrivate::keyboardGrabber->releaseKeyboard(); |
|
1216 |
||
1217 |
// ### TODO: Native keyboard grab |
|
1218 |
||
1219 |
QWidgetPrivate::keyboardGrabber = this; |
|
1220 |
} |
|
1221 |
} |
|
1222 |
||
1223 |
void QWidget::releaseKeyboard() |
|
1224 |
{ |
|
1225 |
if (!qt_nograb() && QWidgetPrivate::keyboardGrabber == this) { |
|
1226 |
// ### TODO: Native keyboard release |
|
1227 |
QWidgetPrivate::keyboardGrabber = 0; |
|
1228 |
} |
|
1229 |
} |
|
1230 |
||
1231 |
void QWidget::grabMouse() |
|
1232 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1233 |
if (isVisible() && !qt_nograb()) { |
0 | 1234 |
if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this) |
1235 |
QWidgetPrivate::mouseGrabber->releaseMouse(); |
|
1236 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
1237 |
WId id = effectiveWinId(); |
|
1238 |
id->SetPointerCapture(true); |
|
1239 |
QWidgetPrivate::mouseGrabber = this; |
|
1240 |
||
1241 |
#ifndef QT_NO_CURSOR |
|
1242 |
QApplication::setOverrideCursor(cursor()); |
|
1243 |
#endif |
|
1244 |
} |
|
1245 |
} |
|
1246 |
||
1247 |
#ifndef QT_NO_CURSOR |
|
1248 |
void QWidget::grabMouse(const QCursor &cursor) |
|
1249 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1250 |
if (isVisible() && !qt_nograb()) { |
0 | 1251 |
if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this) |
1252 |
QWidgetPrivate::mouseGrabber->releaseMouse(); |
|
1253 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
1254 |
WId id = effectiveWinId(); |
|
1255 |
id->SetPointerCapture(true); |
|
1256 |
QWidgetPrivate::mouseGrabber = this; |
|
1257 |
||
1258 |
QApplication::setOverrideCursor(cursor); |
|
1259 |
} |
|
1260 |
} |
|
1261 |
#endif |
|
1262 |
||
1263 |
void QWidget::releaseMouse() |
|
1264 |
{ |
|
1265 |
if (!qt_nograb() && QWidgetPrivate::mouseGrabber == this) { |
|
1266 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1267 |
if(!window()->isModal()) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1268 |
WId id = effectiveWinId(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1269 |
id->SetPointerCapture(false); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
1270 |
} |
0 | 1271 |
QWidgetPrivate::mouseGrabber = 0; |
1272 |
#ifndef QT_NO_CURSOR |
|
1273 |
QApplication::restoreOverrideCursor(); |
|
1274 |
#endif |
|
1275 |
} |
|
1276 |
} |
|
1277 |
||
1278 |
void QWidget::activateWindow() |
|
1279 |
{ |
|
1280 |
Q_D(QWidget); |
|
1281 |
||
1282 |
QWidget *tlw = window(); |
|
1283 |
if (tlw->isVisible()) { |
|
1284 |
window()->createWinId(); |
|
1285 |
QSymbianControl *id = static_cast<QSymbianControl *>(tlw->internalWinId()); |
|
1286 |
id->setFocusSafely(true); |
|
1287 |
} |
|
1288 |
} |
|
1289 |
||
1290 |
#ifndef QT_NO_CURSOR |
|
1291 |
||
1292 |
void QWidgetPrivate::setCursor_sys(const QCursor &cursor) |
|
1293 |
{ |
|
1294 |
Q_UNUSED(cursor); |
|
1295 |
Q_Q(QWidget); |
|
1296 |
qt_symbian_set_cursor(q, false); |
|
1297 |
} |
|
1298 |
||
1299 |
void QWidgetPrivate::unsetCursor_sys() |
|
1300 |
{ |
|
1301 |
Q_Q(QWidget); |
|
1302 |
qt_symbian_set_cursor(q, false); |
|
1303 |
} |
|
1304 |
#endif |
|
1305 |
||
1306 |
QT_END_NAMESPACE |