src/gui/kernel/qwidget_s60.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
   385             // Request mouse move events.
   385             // Request mouse move events.
   386             drawableWindow->PointerFilter(EPointerFilterEnterExit
   386             drawableWindow->PointerFilter(EPointerFilterEnterExit
   387                 | EPointerFilterMove | EPointerFilterDrag, 0);
   387                 | EPointerFilterMove | EPointerFilterDrag, 0);
   388             drawableWindow->EnableVisibilityChangeEvents();
   388             drawableWindow->EnableVisibilityChangeEvents();
   389 
   389 
   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         }
   390         }
   401 
   391 
   402         q->setAttribute(Qt::WA_WState_Created);
   392         q->setAttribute(Qt::WA_WState_Created);
   403 
   393 
   404         int x, y, w, h;
   394         int x, y, w, h;
   406         control->SetRect(TRect(TPoint(x, y), TSize(w, h)));
   396         control->SetRect(TRect(TPoint(x, y), TSize(w, h)));
   407 
   397 
   408         // We wait until the control is fully constructed before calling setWinId, because
   398         // We wait until the control is fully constructed before calling setWinId, because
   409         // this generates a WinIdChanged event.
   399         // this generates a WinIdChanged event.
   410         setWinId(control.take());
   400         setWinId(control.take());
       
   401 
       
   402         if (!desktop)
       
   403             s60UpdateIsOpaque(); // must be called after setWinId()
   411 
   404 
   412     } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
   405     } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
   413 
   406 
   414         QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
   407         QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
   415         QT_TRAP_THROWING(control->ConstructL(!parentWidget));
   408         QT_TRAP_THROWING(control->ConstructL(!parentWidget));
   485     if (q->internalWinId()) {
   478     if (q->internalWinId()) {
   486         if (!extra->activated)
   479         if (!extra->activated)
   487              activateSymbianWindow();
   480              activateSymbianWindow();
   488 
   481 
   489          QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
   482          QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
       
   483 
       
   484 #ifdef Q_WS_S60
       
   485         // Lazily initialize the S60 screen furniture when the first window is shown.
       
   486         if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)
       
   487                 && !S60->buttonGroupContainer() && !S60->statusPane()) {
       
   488 
       
   489             bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
       
   490             bool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint;
       
   491 
       
   492             // If the window is fullscreen and has not explicitly requested that the CBA be visible
       
   493             // we delay the creation even more.
       
   494             if ((!isFullscreen || cbaRequested) && !q->testAttribute(Qt::WA_DontShowOnScreen)) {
       
   495 
       
   496                 // Create the status pane and CBA here
       
   497                 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi());
       
   498                 MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory();
       
   499                 TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui));
       
   500                 if (S60->buttonGroupContainer())
       
   501                     S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
       
   502 
       
   503                 if (S60->statusPane()) {
       
   504                     // Use QDesktopWidget as the status pane observer to proxy for the AppUi.
       
   505                     // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver.
       
   506                     QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId());
       
   507                     S60->statusPane()->SetObserver(desktopControl);
       
   508 
       
   509                     // Hide the status pane if fullscreen OR
       
   510                     // Fill client area if maximized OR
       
   511                     // Put window below status pane unless the window has an explicit position.
       
   512                     if (isFullscreen) {
       
   513                         S60->statusPane()->MakeVisible(false);
       
   514                     } else if (q->windowState() & Qt::WindowMaximized) {
       
   515                         TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
       
   516                         id->SetExtent(r.iTl, r.Size());
       
   517                     } else if (!q->testAttribute(Qt::WA_Moved)) {
       
   518                         id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl);
       
   519                     }
       
   520                 }
       
   521             }
       
   522         }
       
   523 #endif
   490 
   524 
   491         id->MakeVisible(true);
   525         id->MakeVisible(true);
   492 
   526 
   493         if(q->isWindow())
   527         if(q->isWindow())
   494             id->setFocusSafely(true);
   528             id->setFocusSafely(true);
  1061 
  1095 
  1062     if (oldstate == newstate && !softkeyVisibilityChange)
  1096     if (oldstate == newstate && !softkeyVisibilityChange)
  1063         return;
  1097         return;
  1064 
  1098 
  1065     if (isWindow()) {
  1099     if (isWindow()) {
       
  1100         createWinId();
       
  1101         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
       
  1102 
  1066         const bool wasResized = testAttribute(Qt::WA_Resized);
  1103         const bool wasResized = testAttribute(Qt::WA_Resized);
  1067         const bool wasMoved = testAttribute(Qt::WA_Moved);
  1104         const bool wasMoved = testAttribute(Qt::WA_Moved);
  1068 
  1105 
  1069         QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
  1106         QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
  1070         if (window && newstate & Qt::WindowMinimized) {
  1107         if (window && newstate & Qt::WindowMinimized) {
  1086         if (statusPane)
  1123         if (statusPane)
  1087             statusPane->MakeVisible(visible);
  1124             statusPane->MakeVisible(visible);
  1088         if (buttonGroup) {
  1125         if (buttonGroup) {
  1089             // Visibility
  1126             // Visibility
  1090             buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested));
  1127             buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested));
  1091 
       
  1092             // Responsiviness
       
  1093             CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup
       
  1094             TUint cbaFlags = cba->ButtonGroupFlags();
       
  1095             if(windowFlags() & Qt::WindowSoftkeysRespondHint)
       
  1096                 cbaFlags |= EAknCBAFlagRespondWhenInvisible;
       
  1097             else
       
  1098                 cbaFlags &= ~EAknCBAFlagRespondWhenInvisible;
       
  1099             cba->SetButtonGroupFlags(cbaFlags);
       
  1100         }
  1128         }
  1101 #endif // Q_WS_S60
  1129 #endif // Q_WS_S60
  1102 
  1130 
  1103         createWinId();
       
  1104         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
       
  1105         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1131         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1106         if (!wasResized && !isVisible())
  1132         if (!wasResized && !isVisible())
  1107             adjustSize();
  1133             adjustSize();
  1108 
  1134 
  1109         QTLWExtra *top = d->topData();
  1135         QTLWExtra *top = d->topData();
  1110         const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1136         QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1111 
       
  1112 
  1137 
  1113         const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
  1138         const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
  1114         if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint)
  1139         if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) {
  1115             setGeometry(qApp->desktop()->screenGeometry(this));
  1140             window->SetExtentToWholeScreen();
  1116         else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint))
  1141         } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) {
  1117             setGeometry(qApp->desktop()->availableGeometry(this));
  1142             TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this));
  1118         else
  1143             window->SetExtent(maxExtent.iTl, maxExtent.Size());
       
  1144         } else {
       
  1145 #ifdef Q_WS_S60
       
  1146             // With delayed creation of S60 app panes, the normalGeometry calculated above is not
       
  1147             // accurate because it did not consider the status pane. This means that when returning
       
  1148             // normal mode after showing the status pane, the geometry would overlap so we should
       
  1149             // move it if it never had an explicit position.
       
  1150             if (!wasMoved && statusPane && visible) {
       
  1151                 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl;
       
  1152                 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY));
       
  1153             }
       
  1154 #endif
  1119             setGeometry(normalGeometry);
  1155             setGeometry(normalGeometry);
       
  1156         }
  1120 
  1157 
  1121         //restore normal geometry
  1158         //restore normal geometry
  1122         top->normalGeometry = normalGeometry;
  1159         top->normalGeometry = normalGeometry;
  1123 
  1160 
  1124         // FixMe QTBUG-8977
  1161         // FixMe QTBUG-8977