src/gui/kernel/qwidget_s60.cpp
changeset 37 758a864f9613
parent 34 a33bf25e6f72
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   364         QT_TRAP_THROWING(control->ConstructL(true, desktop));
   364         QT_TRAP_THROWING(control->ConstructL(true, desktop));
   365         control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi()));
   365         control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi()));
   366 
   366 
   367         // Symbian windows are always created in an inactive state
   367         // Symbian windows are always created in an inactive state
   368         // We perform this assignment for the case where the window is being re-created
   368         // We perform this assignment for the case where the window is being re-created
   369         // as aa result of a call to setParent_sys, on either this widget or one of its
   369         // as a result of a call to setParent_sys, on either this widget or one of its
   370         // ancestors.
   370         // ancestors.
   371         extra->activated = 0;
   371         extra->activated = 0;
   372 
   372 
   373         if (!desktop) {
   373         if (!desktop) {
   374             TInt stackingFlags;
   374             TInt stackingFlags;
   408         QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
   408         QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
   409         QT_TRAP_THROWING(control->ConstructL(!parentWidget));
   409         QT_TRAP_THROWING(control->ConstructL(!parentWidget));
   410 
   410 
   411         // Symbian windows are always created in an inactive state
   411         // Symbian windows are always created in an inactive state
   412         // We perform this assignment for the case where the window is being re-created
   412         // We perform this assignment for the case where the window is being re-created
   413         // as aa result of a call to setParent_sys, on either this widget or one of its
   413         // as a result of a call to setParent_sys, on either this widget or one of its
   414         // ancestors.
   414         // ancestors.
   415         extra->activated = 0;
   415         extra->activated = 0;
   416 
   416 
   417         TInt stackingFlags;
   417         TInt stackingFlags;
   418         if ((q->windowType() & Qt::Popup) == Qt::Popup) {
   418         if ((q->windowType() & Qt::Popup) == Qt::Popup) {
   480     if (q->internalWinId()) {
   480     if (q->internalWinId()) {
   481         if (!extra->activated)
   481         if (!extra->activated)
   482              activateSymbianWindow();
   482              activateSymbianWindow();
   483 
   483 
   484          QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
   484          QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
       
   485          const bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
   485 
   486 
   486 #ifdef Q_WS_S60
   487 #ifdef Q_WS_S60
   487         // Lazily initialize the S60 screen furniture when the first window is shown.
   488         // Lazily initialize the S60 screen furniture when the first window is shown.
   488         if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)
   489         if (q->isWindow() && !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)
   489                 && !S60->buttonGroupContainer() && !S60->statusPane()) {
   490                 && !S60->buttonGroupContainer() && !S60->statusPane()) {
   490 
       
   491             bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
       
   492 
   491 
   493             if (!q->testAttribute(Qt::WA_DontShowOnScreen)) {
   492             if (!q->testAttribute(Qt::WA_DontShowOnScreen)) {
   494 
   493 
   495                 // Create the status pane and CBA here
   494                 // Create the status pane and CBA here
   496                 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi());
   495                 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi());
   502                 if (S60->statusPane()) {
   501                 if (S60->statusPane()) {
   503                     // Use QDesktopWidget as the status pane observer to proxy for the AppUi.
   502                     // Use QDesktopWidget as the status pane observer to proxy for the AppUi.
   504                     // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver.
   503                     // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver.
   505                     QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId());
   504                     QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId());
   506                     S60->statusPane()->SetObserver(desktopControl);
   505                     S60->statusPane()->SetObserver(desktopControl);
   507 
       
   508                     // Hide the status pane if fullscreen OR
       
   509                     // Fill client area if maximized OR
       
   510                     // Put window below status pane unless the window has an explicit position.
       
   511                     if (isFullscreen) {
   506                     if (isFullscreen) {
   512                         S60->statusPane()->MakeVisible(false);
   507                         const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible();
   513                     } else if (q->windowState() & Qt::WindowMaximized) {
   508                         S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible);
   514                         TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
       
   515                         id->SetExtent(r.iTl, r.Size());
       
   516                     } else if (!q->testAttribute(Qt::WA_Moved)) {
       
   517                         id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl);
       
   518                     }
   509                     }
   519                 }
   510                 }
   520             }
   511             }
   521         }
   512         }
   522 #endif
   513 #endif
       
   514 
       
   515         // Fill client area if maximized OR
       
   516         // Put window below status pane unless the window has an explicit position.
       
   517         if (!isFullscreen) {
       
   518             if (q->windowState() & Qt::WindowMaximized) {
       
   519                 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
       
   520                 id->SetExtent(r.iTl, r.Size());
       
   521             } else if (!q->testAttribute(Qt::WA_Moved)) {
       
   522                 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl);
       
   523             }
       
   524         }
   523 
   525 
   524         id->MakeVisible(true);
   526         id->MakeVisible(true);
   525 
   527 
   526         if(q->isWindow())
   528         if(q->isWindow())
   527             id->setFocusSafely(true);
   529             id->setFocusSafely(true);
   682         q->setAttribute(Qt::WA_DropSiteRegistered, false);
   684         q->setAttribute(Qt::WA_DropSiteRegistered, false);
   683 
   685 
   684     QSymbianControl *old_winid = static_cast<QSymbianControl *>(wasCreated ? data.winid : 0);
   686     QSymbianControl *old_winid = static_cast<QSymbianControl *>(wasCreated ? data.winid : 0);
   685     if ((q->windowType() == Qt::Desktop))
   687     if ((q->windowType() == Qt::Desktop))
   686         old_winid = 0;
   688         old_winid = 0;
       
   689 
       
   690     // old_winid may not have received a 'not visible' visibility
       
   691     // changed event before being destroyed; make sure that it is
       
   692     // removed from the backing store's list of visible windows.
       
   693     S60->controlVisibilityChanged(old_winid, false);
       
   694 
   687     setWinId(0);
   695     setWinId(0);
   688 
   696 
   689     // hide and reparent our own window away. Otherwise we might get
   697     // hide and reparent our own window away. Otherwise we might get
   690     // destroyed when emitting the child remove event below. See QWorkspace.
   698     // destroyed when emitting the child remove event below. See QWorkspace.
   691     if (wasCreated && old_winid) {
   699     if (wasCreated && old_winid) {
   946 {
   954 {
   947 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
   955 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
   948     Q_Q(QWidget);
   956     Q_Q(QWidget);
   949     if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) {
   957     if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) {
   950         RWindow *rwindow = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow());
   958         RWindow *rwindow = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow());
   951         rwindow->EnableAdvancedPointers();
   959         QSymbianControl *window = static_cast<QSymbianControl *>(q->effectiveWinId());
       
   960         //Enabling advanced pointer events for controls that already have active windows causes a panic.
       
   961         if (!window->isControlActive())
       
   962             rwindow->EnableAdvancedPointers();
   952     }
   963     }
   953 #endif
   964 #endif
   954 }
   965 }
   955 
   966 
   956 int QWidget::metric(PaintDeviceMetric m) const
   967 int QWidget::metric(PaintDeviceMetric m) const
  1111 #ifdef Q_WS_S60
  1122 #ifdef Q_WS_S60
  1112         // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
  1123         // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
  1113         // The window decoration visibility has to be changed before doing actual window state
  1124         // The window decoration visibility has to be changed before doing actual window state
  1114         // change since in that order the availableGeometry will return directly the right size and
  1125         // change since in that order the availableGeometry will return directly the right size and
  1115         // we will avoid unnecessarty redraws
  1126         // we will avoid unnecessarty redraws
  1116         CEikStatusPane *statusPane = S60->statusPane();
  1127         const bool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
  1117         CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer();
  1128         const bool statusPaneVisibility = visible;
  1118         TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
  1129         const bool buttonGroupVisibility = (visible || (isFullscreen && cbaRequested));
  1119         if (statusPane)
  1130         S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility);
  1120             statusPane->MakeVisible(visible);
       
  1121         if (buttonGroup) {
       
  1122             // Visibility
       
  1123             buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested));
       
  1124         }
       
  1125 #endif // Q_WS_S60
  1131 #endif // Q_WS_S60
  1126 
  1132 
  1127         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1133         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1128         if (!wasResized && !isVisible())
  1134         if (!wasResized && !isVisible())
  1129             adjustSize();
  1135             adjustSize();
  1131         QTLWExtra *top = d->topData();
  1137         QTLWExtra *top = d->topData();
  1132         QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1138         QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1133 
  1139 
  1134         const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
  1140         const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
  1135         if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) {
  1141         if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) {
       
  1142             setAttribute(Qt::WA_OutsideWSRange, false);
  1136             window->SetExtentToWholeScreen();
  1143             window->SetExtentToWholeScreen();
  1137         } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) {
  1144         } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) {
       
  1145             setAttribute(Qt::WA_OutsideWSRange, false);
  1138             TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this));
  1146             TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this));
  1139             window->SetExtent(maxExtent.iTl, maxExtent.Size());
  1147             window->SetExtent(maxExtent.iTl, maxExtent.Size());
  1140         } else {
  1148         } else {
  1141 #ifdef Q_WS_S60
  1149 #ifdef Q_WS_S60
  1142             // With delayed creation of S60 app panes, the normalGeometry calculated above is not
  1150             // With delayed creation of S60 app panes, the normalGeometry calculated above is not
  1143             // accurate because it did not consider the status pane. This means that when returning
  1151             // accurate because it did not consider the status pane. This means that when returning
  1144             // normal mode after showing the status pane, the geometry would overlap so we should
  1152             // normal mode after showing the status pane, the geometry would overlap so we should
  1145             // move it if it never had an explicit position.
  1153             // move it if it never had an explicit position.
  1146             if (!wasMoved && statusPane && visible) {
  1154             if (!wasMoved && S60->statusPane() && visible) {
  1147                 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl;
  1155                 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl;
  1148                 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY));
  1156                 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY));
  1149             }
  1157             }
  1150 #endif
  1158 #endif
  1151             setGeometry(normalGeometry);
  1159             setGeometry(normalGeometry);