src/gui/kernel/qwidget_s60.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 23 89e065397ea6
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
  1035     const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen();
  1035     const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen();
  1036     const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY);
  1036     const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY);
  1037     return widgetPos;
  1037     return widgetPos;
  1038 }
  1038 }
  1039 
  1039 
       
  1040 static Qt::WindowStates effectiveState(Qt::WindowStates state)
       
  1041 {
       
  1042     if (state & Qt::WindowMinimized)
       
  1043         return Qt::WindowMinimized;
       
  1044     else if (state & Qt::WindowFullScreen)
       
  1045         return Qt::WindowFullScreen;
       
  1046     else if (state & Qt::WindowMaximized)
       
  1047         return Qt::WindowMaximized;
       
  1048     return Qt::WindowNoState;
       
  1049 }
       
  1050 
  1040 void QWidget::setWindowState(Qt::WindowStates newstate)
  1051 void QWidget::setWindowState(Qt::WindowStates newstate)
  1041 {
  1052 {
  1042     Q_D(QWidget);
  1053     Q_D(QWidget);
  1043 
  1054 
  1044     Qt::WindowStates oldstate = windowState();
  1055     Qt::WindowStates oldstate = windowState();
  1045     if (oldstate == newstate)
  1056 
       
  1057     const TBool isFullscreen = newstate & Qt::WindowFullScreen;
       
  1058     const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint;
       
  1059     const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false;
       
  1060     const TBool softkeyVisibilityChange = isFullscreen && (cbaRequested != cbaVisible);
       
  1061 
       
  1062     if (oldstate == newstate && !softkeyVisibilityChange)
  1046         return;
  1063         return;
  1047 
  1064 
  1048     if (isWindow()) {
  1065     if (isWindow()) {
       
  1066         const bool wasResized = testAttribute(Qt::WA_Resized);
       
  1067         const bool wasMoved = testAttribute(Qt::WA_Moved);
  1049 
  1068 
  1050         QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
  1069         QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
  1051         if (window && newstate & Qt::WindowMinimized) {
  1070         if (window && newstate & Qt::WindowMinimized) {
  1052             window->setFocusSafely(false);
  1071             window->setFocusSafely(false);
  1053             window->MakeVisible(false);
  1072             window->MakeVisible(false);
  1056             window->MakeVisible(true);
  1075             window->MakeVisible(true);
  1057         }
  1076         }
  1058 
  1077 
  1059 #ifdef Q_WS_S60
  1078 #ifdef Q_WS_S60
  1060         // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
  1079         // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
  1061         // The window decoration visibility has to be changed before doing actual window state 
  1080         // The window decoration visibility has to be changed before doing actual window state
  1062         // change since in that order the availableGeometry will return directly the right size and 
  1081         // change since in that order the availableGeometry will return directly the right size and
  1063         // we will avoid unnecessarty redraws
  1082         // we will avoid unnecessarty redraws
  1064         CEikStatusPane* statusPane = S60->statusPane();
  1083         CEikStatusPane *statusPane = S60->statusPane();
  1065         CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
  1084         CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer();
  1066         TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); 
  1085         TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
  1067         if (statusPane)
  1086         if (statusPane)
  1068             statusPane->MakeVisible(visible);
  1087             statusPane->MakeVisible(visible);
  1069         if (buttonGroup)
  1088         if (buttonGroup) {
  1070             buttonGroup->MakeVisible(visible);
  1089             // Visibility
       
  1090             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         }
  1071 #endif // Q_WS_S60
  1101 #endif // Q_WS_S60
  1072 
  1102 
  1073         createWinId();
  1103         createWinId();
  1074         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
  1104         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
  1075         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1105         // Ensure the initial size is valid, since we store it as normalGeometry below.
  1076         if (!testAttribute(Qt::WA_Resized) && !isVisible())
  1106         if (!wasResized && !isVisible())
  1077             adjustSize();
  1107             adjustSize();
  1078 
  1108 
  1079         QTLWExtra *top = d->topData();
  1109         QTLWExtra *top = d->topData();
  1080         const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1110         const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
  1081 
  1111 
  1082         if (newstate & Qt::WindowFullScreen)
  1112 
       
  1113         const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
       
  1114         if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint)
  1083             setGeometry(qApp->desktop()->screenGeometry(this));
  1115             setGeometry(qApp->desktop()->screenGeometry(this));
  1084         else if (newstate & Qt::WindowMaximized)
  1116         else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint))
  1085             setGeometry(qApp->desktop()->availableGeometry(this));
  1117             setGeometry(qApp->desktop()->availableGeometry(this));
  1086         else
  1118         else
  1087             setGeometry(normalGeometry);
  1119             setGeometry(normalGeometry);
  1088 
  1120 
  1089         //restore normal geometry
  1121         //restore normal geometry
  1090         top->normalGeometry = normalGeometry;
  1122         top->normalGeometry = normalGeometry;
       
  1123 
       
  1124         // FixMe QTBUG-8977
       
  1125         // In some platforms, WA_Resized and WA_Moved are also not set when application window state is
       
  1126         // anything else than normal. In Symbian we can restore them only for normal window state since
       
  1127         // restoring for other modes, will make fluidlauncher to be launched in wrong size (200x100)
       
  1128         if (effectiveState(newstate) == Qt::WindowNoState) {
       
  1129             setAttribute(Qt::WA_Resized, wasResized);
       
  1130             setAttribute(Qt::WA_Moved, wasMoved);
       
  1131         }
  1091     }
  1132     }
  1092 
  1133 
  1093     data->window_state = newstate;
  1134     data->window_state = newstate;
  1094 
  1135 
  1095     if (newstate & Qt::WindowActive)
  1136     if (newstate & Qt::WindowActive)
  1218 
  1259 
  1219 void QWidget::releaseMouse()
  1260 void QWidget::releaseMouse()
  1220 {
  1261 {
  1221     if (!qt_nograb() && QWidgetPrivate::mouseGrabber == this) {
  1262     if (!qt_nograb() && QWidgetPrivate::mouseGrabber == this) {
  1222         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
  1263         Q_ASSERT(testAttribute(Qt::WA_WState_Created));
  1223         WId id = effectiveWinId();
  1264         if(!window()->isModal()) {
  1224         id->SetPointerCapture(false);
  1265             WId id = effectiveWinId();
       
  1266             id->SetPointerCapture(false);
       
  1267         }
  1225         QWidgetPrivate::mouseGrabber = 0;
  1268         QWidgetPrivate::mouseGrabber = 0;
  1226 #ifndef QT_NO_CURSOR
  1269 #ifndef QT_NO_CURSOR
  1227         QApplication::restoreOverrideCursor();
  1270         QApplication::restoreOverrideCursor();
  1228 #endif
  1271 #endif
  1229     }
  1272     }