Changeset 846 for trunk/src/gui/kernel/qwidget_s60.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qwidget_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 55 55 #ifdef Q_WS_S60 56 56 #include <aknappui.h> 57 #include <eikbtgpc.h> 57 58 #endif 58 59 59 // This is necessary in order to be able to perform delayed invo kation on slots60 // This is necessary in order to be able to perform delayed invocation on slots 60 61 // which take arguments of type WId. One example is 61 62 // QWidgetPrivate::_q_delayedDestroy, which is used to delay destruction of … … 63 64 Q_DECLARE_METATYPE(WId) 64 65 66 // Workaround for the fact that S60 SDKs 3.x do not contain the akntoolbar.h 67 // header, even though the documentation says that it should be there, and indeed 68 // it is present in the library. 69 class CAknToolbar : public CAknControl, 70 public MCoeControlObserver, 71 public MCoeControlBackground, 72 public MEikCommandObserver, 73 public MAknFadedComponent 74 { 75 public: 76 IMPORT_C void SetToolbarVisibility(const TBool visible); 77 }; 78 65 79 QT_BEGIN_NAMESPACE 66 80 … … 69 83 QWidget *QWidgetPrivate::mouseGrabber = 0; 70 84 QWidget *QWidgetPrivate::keyboardGrabber = 0; 85 CEikButtonGroupContainer *QS60Data::cba = 0; 71 86 72 87 static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b) … … 366 381 // Symbian windows are always created in an inactive state 367 382 // We perform this assignment for the case where the window is being re-created 368 // as a aresult of a call to setParent_sys, on either this widget or one of its383 // as a result of a call to setParent_sys, on either this widget or one of its 369 384 // ancestors. 370 385 extra->activated = 0; … … 410 425 // Symbian windows are always created in an inactive state 411 426 // We perform this assignment for the case where the window is being re-created 412 // as a aresult of a call to setParent_sys, on either this widget or one of its427 // as a result of a call to setParent_sys, on either this widget or one of its 413 428 // ancestors. 414 429 extra->activated = 0; … … 434 449 drawableWindow->PointerFilter(EPointerFilterEnterExit 435 450 | EPointerFilterMove | EPointerFilterDrag, 0); 451 drawableWindow->EnableVisibilityChangeEvents(); 436 452 437 453 if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { … … 481 497 482 498 QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); 499 const bool isFullscreen = q->windowState() & Qt::WindowFullScreen; 500 const TBool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint; 483 501 484 502 #ifdef Q_WS_S60 485 503 // Lazily initialize the S60 screen furniture when the first window is shown. 486 if ( !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)504 if (q->isWindow() && !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) 487 505 && !S60->buttonGroupContainer() && !S60->statusPane()) { 488 489 bool isFullscreen = q->windowState() & Qt::WindowFullScreen;490 506 491 507 if (!q->testAttribute(Qt::WA_DontShowOnScreen)) { … … 494 510 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi()); 495 511 MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory(); 496 TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui)); 497 if (S60->buttonGroupContainer()) 498 S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); 512 513 QT_TRAP_THROWING( 514 factory->CreateResourceIndependentFurnitureL(ui); 515 516 TRect boundingRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 517 518 CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, 519 CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); 520 if (isFullscreen && !cbaRequested) 521 cba->MakeVisible(false); 522 523 CEikButtonGroupContainer *oldCba = factory->SwapButtonGroup(cba); 524 Q_ASSERT(!oldCba); 525 S60->setButtonGroupContainer(cba); 526 527 // If the creation of the first widget is delayed, for example by doing it 528 // inside the event loop, S60 somehow "forgets" to set the visibility of the 529 // toolbar (the three middle softkeys) when you flip the phone over, so we 530 // need to do it ourselves to avoid a "hole" in the application, even though 531 // Qt itself does not use the toolbar directly.. 532 CAknAppUi *appui = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi()); 533 if (appui) { 534 CAknToolbar *toolbar = appui->PopupToolbar(); 535 if (toolbar && !toolbar->IsVisible()) 536 toolbar->SetToolbarVisibility(ETrue); 537 } 538 539 CEikMenuBar *menuBar = new(ELeave) CEikMenuBar; 540 menuBar->ConstructL(ui, 0, R_AVKON_MENUPANE_EMPTY); 541 menuBar->SetMenuType(CEikMenuBar::EMenuOptions); 542 S60->appUi()->AddToStackL(menuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); 543 544 CEikMenuBar *oldMenu = factory->SwapMenuBar(menuBar); 545 Q_ASSERT(!oldMenu); 546 ) 499 547 500 548 if (S60->statusPane()) { … … 503 551 QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId()); 504 552 S60->statusPane()->SetObserver(desktopControl); 505 506 // Hide the status pane if fullscreen OR507 // Fill client area if maximized OR508 // Put window below status pane unless the window has an explicit position.509 553 if (isFullscreen) { 510 S60->statusPane()->MakeVisible(false); 511 } else if (q->windowState() & Qt::WindowMaximized) { 512 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 513 id->SetExtent(r.iTl, r.Size()); 514 } else if (!q->testAttribute(Qt::WA_Moved)) { 515 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); 554 const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible(); 555 S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible); 516 556 } 517 557 } … … 520 560 #endif 521 561 562 // Fill client area if maximized OR 563 // Put window below status pane unless the window has an explicit position. 564 if (!isFullscreen) { 565 if (q->windowState() & Qt::WindowMaximized) { 566 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 567 id->SetExtent(r.iTl, r.Size()); 568 } else if (!q->testAttribute(Qt::WA_Moved) && q->windowType() != Qt::Dialog) { 569 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); 570 } 571 } 572 522 573 id->MakeVisible(true); 523 574 524 if(q->isWindow() )575 if(q->isWindow()&&!q->testAttribute(Qt::WA_ShowWithoutActivating)) 525 576 id->setFocusSafely(true); 526 577 } … … 555 606 556 607 if (id) { 557 //Incorrect optimi sation - for popup windows, Qt's focus is moved before608 //Incorrect optimization - for popup windows, Qt's focus is moved before 558 609 //hide_sys is called, resulting in the popup window keeping its elevated 559 610 //position in the CONE control stack. … … 683 734 if ((q->windowType() == Qt::Desktop)) 684 735 old_winid = 0; 736 737 // old_winid may not have received a 'not visible' visibility 738 // changed event before being destroyed; make sure that it is 739 // removed from the backing store's list of visible windows. 740 if (old_winid) 741 S60->controlVisibilityChanged(old_winid, false); 742 685 743 setWinId(0); 686 744 … … 738 796 return; 739 797 740 if ((data.window_flags & Qt::FramelessWindowHint) == 0) 741 return; 798 createTLExtra(); 742 799 743 800 RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); … … 745 802 #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE 746 803 window->SetSurfaceTransparency(!isOpaque); 804 extra->topextra->nativeWindowTransparencyEnabled = !isOpaque; 747 805 #else 748 806 if (!isOpaque) { 749 807 const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); 750 if (window->SetTransparencyAlphaChannel() == KErrNone) 808 if (window->SetTransparencyAlphaChannel() == KErrNone) { 751 809 window->SetBackgroundColor(TRgb(255, 255, 255, 0)); 752 } else 810 extra->topextra->nativeWindowTransparencyEnabled = 1; 811 812 if (extra->topextra->backingStore.data() && 813 QApplicationPrivate::graphics_system_name == QLatin1String("openvg")) { 814 // Semi-transparent EGL surfaces aren't supported. We need to 815 // recreate backing store to get translucent surface (raster surface). 816 extra->topextra->backingStore.create(q); 817 extra->topextra->backingStore.registerWidget(q); 818 } 819 } 820 } else if (extra->topextra->nativeWindowTransparencyEnabled) { 753 821 window->SetTransparentRegion(TRegionFix<1>()); 822 extra->topextra->nativeWindowTransparencyEnabled = 0; 823 } 754 824 #endif 755 825 } … … 909 979 void QWidgetPrivate::createTLSysExtra() 910 980 { 911 extra->topextra->backingStore = 0;912 981 extra->topextra->inExpose = 0; 982 extra->topextra->nativeWindowTransparencyEnabled = 0; 913 983 } 914 984 915 985 void QWidgetPrivate::deleteTLSysExtra() 916 986 { 917 delete extra->topextra->backingStore; 918 extra->topextra->backingStore = 0; 987 extra->topextra->backingStore.destroy(); 919 988 } 920 989 … … 952 1021 if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) { 953 1022 RWindow *rwindow = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); 954 rwindow->EnableAdvancedPointers(); 1023 QSymbianControl *window = static_cast<QSymbianControl *>(q->effectiveWinId()); 1024 //Enabling advanced pointer events for controls that already have active windows causes a panic. 1025 if (!window->isControlActive()) 1026 rwindow->EnableAdvancedPointers(); 955 1027 } 956 1028 #endif … … 1087 1159 1088 1160 const TBool isFullscreen = newstate & Qt::WindowFullScreen; 1161 #ifdef Q_WS_S60 1089 1162 const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint; 1090 1163 const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false; … … 1093 1166 if (oldstate == newstate && !softkeyVisibilityChange) 1094 1167 return; 1168 #endif // Q_WS_S60 1095 1169 1096 1170 if (isWindow()) { … … 1111 1185 1112 1186 #ifdef Q_WS_S60 1113 // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration. 1114 // The window decoration visibility has to be changed before doing actual window state 1115 // change since in that order the availableGeometry will return directly the right size and 1116 // we will avoid unnecessarty redraws 1117 CEikStatusPane *statusPane = S60->statusPane(); 1118 CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); 1119 TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1120 if (statusPane) 1121 statusPane->MakeVisible(visible); 1122 if (buttonGroup) { 1123 // Visibility 1124 buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested)); 1187 bool decorationsVisible(false); 1188 if (!parentWidget()) { // Only top level native windows have control over cba/status pane 1189 // Hide window decoration when switching to fullscreen / minimized otherwise show decoration. 1190 // The window decoration visibility has to be changed before doing actual window state 1191 // change since in that order the availableGeometry will return directly the right size and 1192 // we will avoid unnecessary redraws 1193 decorationsVisible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1194 const bool statusPaneVisibility = decorationsVisible; 1195 const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaRequested)); 1196 S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); 1125 1197 } 1126 1198 #endif // Q_WS_S60 … … 1135 1207 const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; 1136 1208 if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { 1209 setAttribute(Qt::WA_OutsideWSRange, false); 1137 1210 window->SetExtentToWholeScreen(); 1138 1211 } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { 1212 setAttribute(Qt::WA_OutsideWSRange, false); 1139 1213 TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); 1140 1214 window->SetExtent(maxExtent.iTl, maxExtent.Size()); … … 1145 1219 // normal mode after showing the status pane, the geometry would overlap so we should 1146 1220 // move it if it never had an explicit position. 1147 if (!wasMoved && statusPane && visible) {1221 if (!wasMoved && S60->statusPane() && decorationsVisible) { 1148 1222 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl; 1149 1223 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); … … 1179 1253 { 1180 1254 Q_D(QWidget); 1255 d->aboutToDestroy(); 1181 1256 if (!isWindow() && parentWidget()) 1182 1257 parentWidget()->d_func()->invalidateBuffer(geometry()); … … 1226 1301 // so we flush the command buffer to ensure that the freeing of 1227 1302 // those resources and deleting the window can happen "atomically" 1228 S60->wsSession().Flush(); 1303 if (qApp) 1304 S60->wsSession().Flush(); 1229 1305 } 1230 1306 }
Note:
See TracChangeset
for help on using the changeset viewer.