356 data.crect.setRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); |
356 data.crect.setRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); |
357 |
357 |
358 } else if (topLevel) { |
358 } else if (topLevel) { |
359 if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen)) |
359 if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen)) |
360 data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); |
360 data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); |
361 |
|
362 QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
361 QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
363 QT_TRAP_THROWING(control->ConstructL(true, desktop)); |
362 QT_TRAP_THROWING(control->ConstructL(true, desktop)); |
364 control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi())); |
363 control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi())); |
365 |
364 |
366 // Symbian windows are always created in an inactive state |
365 // Symbian windows are always created in an inactive state |
385 // Request mouse move events. |
384 // Request mouse move events. |
386 drawableWindow->PointerFilter(EPointerFilterEnterExit |
385 drawableWindow->PointerFilter(EPointerFilterEnterExit |
387 | EPointerFilterMove | EPointerFilterDrag, 0); |
386 | EPointerFilterMove | EPointerFilterDrag, 0); |
388 drawableWindow->EnableVisibilityChangeEvents(); |
387 drawableWindow->EnableVisibilityChangeEvents(); |
389 |
388 |
390 if (!isOpaque) { |
|
391 RWindow *const window = static_cast<RWindow *>(drawableWindow); |
|
392 #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE |
|
393 window->SetSurfaceTransparency(true); |
|
394 #else |
|
395 const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); |
|
396 if (window->SetTransparencyAlphaChannel() == KErrNone) |
|
397 window->SetBackgroundColor(TRgb(255, 255, 255, 0)); |
|
398 #endif |
|
399 } |
|
400 } |
389 } |
401 |
390 |
402 q->setAttribute(Qt::WA_WState_Created); |
391 q->setAttribute(Qt::WA_WState_Created); |
403 |
392 |
404 int x, y, w, h; |
393 int x, y, w, h; |
406 control->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
395 control->SetRect(TRect(TPoint(x, y), TSize(w, h))); |
407 |
396 |
408 // We wait until the control is fully constructed before calling setWinId, because |
397 // We wait until the control is fully constructed before calling setWinId, because |
409 // this generates a WinIdChanged event. |
398 // this generates a WinIdChanged event. |
410 setWinId(control.take()); |
399 setWinId(control.take()); |
|
400 if (!desktop) |
|
401 s60UpdateIsOpaque(); |
411 |
402 |
412 } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget |
403 } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget |
413 |
404 |
414 QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
405 QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) ); |
415 QT_TRAP_THROWING(control->ConstructL(!parentWidget)); |
406 QT_TRAP_THROWING(control->ConstructL(!parentWidget)); |
485 if (q->internalWinId()) { |
476 if (q->internalWinId()) { |
486 if (!extra->activated) |
477 if (!extra->activated) |
487 activateSymbianWindow(); |
478 activateSymbianWindow(); |
488 |
479 |
489 QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); |
480 QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); |
|
481 |
|
482 #ifdef Q_WS_S60 |
|
483 // Lazily initialize the S60 screen furniture when the first window is shown. |
|
484 if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) |
|
485 && !S60->buttonGroupContainer() && !S60->statusPane()) { |
|
486 |
|
487 bool isFullscreen = q->windowState() & Qt::WindowFullScreen; |
|
488 bool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint; |
|
489 |
|
490 // If the window is fullscreen and has not explicitly requested that the CBA be visible |
|
491 // we delay the creation even more. |
|
492 if ((!isFullscreen || cbaRequested) && !q->testAttribute(Qt::WA_DontShowOnScreen)) { |
|
493 |
|
494 // Create the status pane and CBA here |
|
495 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi()); |
|
496 MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory(); |
|
497 TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui)); |
|
498 if (S60->buttonGroupContainer()) |
|
499 S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); |
|
500 |
|
501 if (S60->statusPane()) { |
|
502 // Use QDesktopWidget as the status pane observer to proxy for the AppUi. |
|
503 // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver. |
|
504 QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId()); |
|
505 S60->statusPane()->SetObserver(desktopControl); |
|
506 |
|
507 // Hide the status pane if fullscreen OR |
|
508 // Fill client area if maximized OR |
|
509 // Put window below status pane unless the window has an explicit position. |
|
510 if (isFullscreen) { |
|
511 S60->statusPane()->MakeVisible(false); |
|
512 } else if (q->windowState() & Qt::WindowMaximized) { |
|
513 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
514 id->SetExtent(r.iTl, r.Size()); |
|
515 } else if (!q->testAttribute(Qt::WA_Moved)) { |
|
516 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); |
|
517 } |
|
518 } |
|
519 } |
|
520 } |
|
521 #endif |
490 |
522 |
491 id->MakeVisible(true); |
523 id->MakeVisible(true); |
492 |
524 |
493 if(q->isWindow()) |
525 if(q->isWindow()) |
494 id->setFocusSafely(true); |
526 id->setFocusSafely(true); |
1061 |
1093 |
1062 if (oldstate == newstate && !softkeyVisibilityChange) |
1094 if (oldstate == newstate && !softkeyVisibilityChange) |
1063 return; |
1095 return; |
1064 |
1096 |
1065 if (isWindow()) { |
1097 if (isWindow()) { |
|
1098 createWinId(); |
|
1099 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
1100 |
1066 const bool wasResized = testAttribute(Qt::WA_Resized); |
1101 const bool wasResized = testAttribute(Qt::WA_Resized); |
1067 const bool wasMoved = testAttribute(Qt::WA_Moved); |
1102 const bool wasMoved = testAttribute(Qt::WA_Moved); |
1068 |
1103 |
1069 QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId()); |
1104 QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId()); |
1070 if (window && newstate & Qt::WindowMinimized) { |
1105 if (window && newstate & Qt::WindowMinimized) { |
1098 cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; |
1133 cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; |
1099 cba->SetButtonGroupFlags(cbaFlags); |
1134 cba->SetButtonGroupFlags(cbaFlags); |
1100 } |
1135 } |
1101 #endif // Q_WS_S60 |
1136 #endif // Q_WS_S60 |
1102 |
1137 |
1103 createWinId(); |
|
1104 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
1105 // Ensure the initial size is valid, since we store it as normalGeometry below. |
1138 // Ensure the initial size is valid, since we store it as normalGeometry below. |
1106 if (!wasResized && !isVisible()) |
1139 if (!wasResized && !isVisible()) |
1107 adjustSize(); |
1140 adjustSize(); |
1108 |
1141 |
1109 QTLWExtra *top = d->topData(); |
1142 QTLWExtra *top = d->topData(); |
1110 const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; |
1143 QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; |
1111 |
|
1112 |
1144 |
1113 const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; |
1145 const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; |
1114 if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) |
1146 if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { |
1115 setGeometry(qApp->desktop()->screenGeometry(this)); |
1147 window->SetExtentToWholeScreen(); |
1116 else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) |
1148 } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { |
1117 setGeometry(qApp->desktop()->availableGeometry(this)); |
1149 TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); |
1118 else |
1150 window->SetExtent(maxExtent.iTl, maxExtent.Size()); |
|
1151 } else { |
|
1152 #ifdef Q_WS_S60 |
|
1153 // With delayed creation of S60 app panes, the normalGeometry calculated above is not |
|
1154 // accurate because it did not consider the status pane. This means that when returning |
|
1155 // normal mode after showing the status pane, the geometry would overlap so we should |
|
1156 // move it if it never had an explicit position. |
|
1157 if (!wasMoved && statusPane && visible) { |
|
1158 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl; |
|
1159 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); |
|
1160 } |
|
1161 #endif |
1119 setGeometry(normalGeometry); |
1162 setGeometry(normalGeometry); |
|
1163 } |
1120 |
1164 |
1121 //restore normal geometry |
1165 //restore normal geometry |
1122 top->normalGeometry = normalGeometry; |
1166 top->normalGeometry = normalGeometry; |
1123 |
1167 |
1124 // FixMe QTBUG-8977 |
1168 // FixMe QTBUG-8977 |