50 #include "qt_s60_p.h" |
50 #include "qt_s60_p.h" |
51 #include "private/qevent_p.h" |
51 #include "private/qevent_p.h" |
52 #include "qstring.h" |
52 #include "qstring.h" |
53 #include "qdebug.h" |
53 #include "qdebug.h" |
54 #include "qimage.h" |
54 #include "qimage.h" |
|
55 #include "qcombobox.h" |
55 #include "private/qkeymapper_p.h" |
56 #include "private/qkeymapper_p.h" |
56 #include "private/qfont_p.h" |
57 #include "private/qfont_p.h" |
57 #ifndef QT_NO_STYLE_S60 |
58 #ifndef QT_NO_STYLE_S60 |
58 #include "private/qs60style_p.h" |
59 #include "private/qs60style_p.h" |
59 #endif |
60 #endif |
595 */ |
596 */ |
596 |
597 |
597 TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, |
598 TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, |
598 keyEvent.iCode); |
599 keyEvent.iCode); |
599 int keyCode; |
600 int keyCode; |
600 if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { |
601 if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used |
|
602 keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); |
|
603 } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { |
601 // Normal characters keys. |
604 // Normal characters keys. |
602 keyCode = s60Keysym; |
605 keyCode = s60Keysym; |
603 } else { |
606 } else { |
604 // Special S60 keys. |
607 // Special S60 keys. |
605 keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); |
608 keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); |
807 #endif |
810 #endif |
808 |
811 |
809 void QSymbianControl::Draw(const TRect& controlRect) const |
812 void QSymbianControl::Draw(const TRect& controlRect) const |
810 { |
813 { |
811 // Set flag to avoid calling DrawNow in window surface |
814 // Set flag to avoid calling DrawNow in window surface |
812 QWExtra *extra = qwidget->d_func()->extraData(); |
815 QWidget *window = qwidget->window(); |
813 if (extra && !extra->inExpose) { |
816 Q_ASSERT(window); |
814 extra->inExpose = true; |
817 QTLWExtra *topExtra = window->d_func()->maybeTopData(); |
|
818 Q_ASSERT(topExtra); |
|
819 if (!topExtra->inExpose) { |
|
820 topExtra->inExpose = true; |
815 QRect exposeRect = qt_TRect2QRect(controlRect); |
821 QRect exposeRect = qt_TRect2QRect(controlRect); |
816 qwidget->d_func()->syncBackingStore(exposeRect); |
822 qwidget->d_func()->syncBackingStore(exposeRect); |
817 extra->inExpose = false; |
823 topExtra->inExpose = false; |
818 } |
824 } |
819 |
825 |
820 QWindowSurface *surface = qwidget->windowSurface(); |
826 QWindowSurface *surface = qwidget->windowSurface(); |
821 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
827 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
822 |
828 |
922 if (oldPos != newPos) { |
928 if (oldPos != newPos) { |
923 QRect cr = qwidget->geometry(); |
929 QRect cr = qwidget->geometry(); |
924 cr.moveTopLeft(newPos); |
930 cr.moveTopLeft(newPos); |
925 qwidget->data->crect = cr; |
931 qwidget->data->crect = cr; |
926 QTLWExtra *top = qwidget->d_func()->maybeTopData(); |
932 QTLWExtra *top = qwidget->d_func()->maybeTopData(); |
927 if (top) |
933 if (top && (qwidget->windowState() & (~Qt::WindowActive)) == Qt::WindowNoState) |
928 top->normalGeometry = cr; |
934 top->normalGeometry.moveTopLeft(newPos); |
929 if (qwidget->isVisible()) { |
935 if (qwidget->isVisible()) { |
930 QMoveEvent e(newPos, oldPos); |
936 QMoveEvent e(newPos, oldPos); |
931 qt_sendSpontaneousEvent(qwidget, &e); |
937 qt_sendSpontaneousEvent(qwidget, &e); |
932 } else { |
938 } else { |
933 QMoveEvent * e = new QMoveEvent(newPos, oldPos); |
939 QMoveEvent * e = new QMoveEvent(newPos, oldPos); |
958 |
964 |
959 QApplication::setActiveWindow(qwidget->window()); |
965 QApplication::setActiveWindow(qwidget->window()); |
960 qwidget->d_func()->setWindowIcon_sys(true); |
966 qwidget->d_func()->setWindowIcon_sys(true); |
961 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
967 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
962 #ifdef Q_WS_S60 |
968 #ifdef Q_WS_S60 |
963 // If widget is fullscreen, hide status pane and button container |
969 // If widget is fullscreen/minimized, hide status pane and button container otherwise show them. |
964 // otherwise show them. |
970 CEikStatusPane *statusPane = S60->statusPane(); |
965 CEikStatusPane* statusPane = S60->statusPane(); |
971 CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); |
966 CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); |
972 TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); |
967 bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; |
973 if (statusPane) |
968 if (statusPane && (bool)statusPane->IsVisible() == isFullscreen) |
974 statusPane->MakeVisible(visible); |
969 statusPane->MakeVisible(!isFullscreen); |
975 if (buttonGroup) { |
970 if (buttonGroup && (bool)buttonGroup->IsVisible() == isFullscreen) |
976 // Visibility |
971 buttonGroup->MakeVisible(!isFullscreen); |
977 const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; |
|
978 const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; |
|
979 buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint)); |
|
980 |
|
981 // Responsiviness |
|
982 CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup |
|
983 TUint cbaFlags = cba->ButtonGroupFlags(); |
|
984 if(qwidget->windowFlags() & Qt::WindowSoftkeysRespondHint) |
|
985 cbaFlags |= EAknCBAFlagRespondWhenInvisible; |
|
986 else |
|
987 cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; |
|
988 cba->SetButtonGroupFlags(cbaFlags); |
|
989 } |
972 #endif |
990 #endif |
973 } else if (QApplication::activeWindow() == qwidget->window()) { |
991 } else if (QApplication::activeWindow() == qwidget->window()) { |
974 if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) { |
992 if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) { |
975 QWidget *fw = QApplication::focusWidget(); |
993 QWidget *fw = QApplication::focusWidget(); |
976 if (fw) { |
994 if (fw) { |
984 QApplication::setActiveWindow(0); |
1002 QApplication::setActiveWindow(0); |
985 } |
1003 } |
986 // else { We don't touch the active window unless we were explicitly activated or deactivated } |
1004 // else { We don't touch the active window unless we were explicitly activated or deactivated } |
987 } |
1005 } |
988 |
1006 |
|
1007 void QSymbianControl::handleClientAreaChange() |
|
1008 { |
|
1009 const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; |
|
1010 if (qwidget->isFullScreen() && !cbaVisibilityHint) { |
|
1011 SetExtentToWholeScreen(); |
|
1012 } else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) { |
|
1013 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
1014 SetExtent(r.iTl, r.Size()); |
|
1015 } else if (!qwidget->isMinimized()) { // Normal geometry |
|
1016 if (!qwidget->testAttribute(Qt::WA_Resized)) { |
|
1017 qwidget->adjustSize(); |
|
1018 qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize |
|
1019 } |
|
1020 if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { |
|
1021 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
1022 SetPosition(r.iTl); |
|
1023 qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position |
|
1024 } |
|
1025 } |
|
1026 } |
|
1027 |
989 void QSymbianControl::HandleResourceChange(int resourceType) |
1028 void QSymbianControl::HandleResourceChange(int resourceType) |
990 { |
1029 { |
991 switch (resourceType) { |
1030 switch (resourceType) { |
992 case KInternalStatusPaneChange: |
1031 case KInternalStatusPaneChange: |
993 if (qwidget->isFullScreen()) { |
1032 handleClientAreaChange(); |
994 SetExtentToWholeScreen(); |
|
995 } else if (qwidget->isMaximized()) { |
|
996 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
997 SetExtent(r.iTl, r.Size()); |
|
998 } |
|
999 if (IsFocused() && IsVisible()) { |
1033 if (IsFocused() && IsVisible()) { |
1000 qwidget->d_func()->setWindowIcon_sys(true); |
1034 qwidget->d_func()->setWindowIcon_sys(true); |
1001 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
1035 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
1002 } |
1036 } |
1003 break; |
1037 break; |
1005 // font change event |
1039 // font change event |
1006 break; |
1040 break; |
1007 #ifdef Q_WS_S60 |
1041 #ifdef Q_WS_S60 |
1008 case KEikDynamicLayoutVariantSwitch: |
1042 case KEikDynamicLayoutVariantSwitch: |
1009 { |
1043 { |
1010 if (qwidget->isFullScreen()) { |
1044 handleClientAreaChange(); |
1011 SetExtentToWholeScreen(); |
|
1012 } else if (qwidget->isMaximized()) { |
|
1013 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
1014 SetExtent(r.iTl, r.Size()); |
|
1015 } |
|
1016 break; |
1045 break; |
1017 } |
1046 } |
1018 #endif |
1047 #endif |
1019 default: |
1048 default: |
1020 break; |
1049 break; |
1141 |
1170 |
1142 #ifdef QT_NO_DEBUG |
1171 #ifdef QT_NO_DEBUG |
1143 if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty()) |
1172 if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty()) |
1144 #endif |
1173 #endif |
1145 S60->wsSession().SetAutoFlush(ETrue); |
1174 S60->wsSession().SetAutoFlush(ETrue); |
|
1175 |
|
1176 #ifdef Q_SYMBIAN_WINDOW_SIZE_CACHE |
|
1177 TRAP_IGNORE(S60->wsSession().EnableWindowSizeCacheL()); |
|
1178 #endif |
1146 |
1179 |
1147 S60->updateScreenSize(); |
1180 S60->updateScreenSize(); |
1148 |
1181 |
1149 |
1182 |
1150 TDisplayMode mode = S60->screenDevice()->DisplayMode(); |
1183 TDisplayMode mode = S60->screenDevice()->DisplayMode(); |
1219 err = repository->Get(KAknAvkonTransparencyEnabled, value); |
1252 err = repository->Get(KAknAvkonTransparencyEnabled, value); |
1220 if(err == KErrNone) { |
1253 if(err == KErrNone) { |
1221 S60->avkonComponentsSupportTransparency = (value==1) ? true : false; |
1254 S60->avkonComponentsSupportTransparency = (value==1) ? true : false; |
1222 } |
1255 } |
1223 } |
1256 } |
1224 #endif |
1257 #endif |
1225 |
1258 |
1226 if (touch) { |
1259 if (touch) { |
1227 QApplicationPrivate::navigationMode = Qt::NavigationModeNone; |
1260 QApplicationPrivate::navigationMode = Qt::NavigationModeNone; |
1228 } else { |
1261 } else { |
1229 QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; |
1262 QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; |
1374 app_do_modal = qt_modal_stack != 0; |
1407 app_do_modal = qt_modal_stack != 0; |
1375 } |
1408 } |
1376 |
1409 |
1377 void QApplicationPrivate::openPopup(QWidget *popup) |
1410 void QApplicationPrivate::openPopup(QWidget *popup) |
1378 { |
1411 { |
|
1412 if (popup && qobject_cast<QComboBox *>(popup->parentWidget())) |
|
1413 static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(ETrue); |
|
1414 |
1379 if (!QApplicationPrivate::popupWidgets) |
1415 if (!QApplicationPrivate::popupWidgets) |
1380 QApplicationPrivate::popupWidgets = new QWidgetList; |
1416 QApplicationPrivate::popupWidgets = new QWidgetList; |
1381 QApplicationPrivate::popupWidgets->append(popup); |
1417 QApplicationPrivate::popupWidgets->append(popup); |
1382 |
|
1383 |
1418 |
1384 // Cancel focus widget pointer capture and long tap timer |
1419 // Cancel focus widget pointer capture and long tap timer |
1385 if (QApplication::focusWidget()) { |
1420 if (QApplication::focusWidget()) { |
1386 static_cast<QSymbianControl*>(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer(); |
1421 static_cast<QSymbianControl*>(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer(); |
1387 QApplication::focusWidget()->effectiveWinId()->SetPointerCapture(false); |
1422 QApplication::focusWidget()->effectiveWinId()->SetPointerCapture(false); |
1417 } |
1452 } |
1418 } |
1453 } |
1419 |
1454 |
1420 void QApplicationPrivate::closePopup(QWidget *popup) |
1455 void QApplicationPrivate::closePopup(QWidget *popup) |
1421 { |
1456 { |
|
1457 if (popup && qobject_cast<QComboBox *>(popup->parentWidget())) |
|
1458 static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(EFalse); |
|
1459 |
1422 if (!QApplicationPrivate::popupWidgets) |
1460 if (!QApplicationPrivate::popupWidgets) |
1423 return; |
1461 return; |
1424 QApplicationPrivate::popupWidgets->removeAll(popup); |
1462 QApplicationPrivate::popupWidgets->removeAll(popup); |
1425 |
1463 |
1426 // Cancel pointer capture and long tap for this popup |
1464 // Cancel pointer capture and long tap for this popup |
1440 QWidgetPrivate::keyboardGrabber->grabKeyboard(); |
1478 QWidgetPrivate::keyboardGrabber->grabKeyboard(); |
1441 |
1479 |
1442 QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() |
1480 QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget() |
1443 : q_func()->focusWidget(); |
1481 : q_func()->focusWidget(); |
1444 if (fw) { |
1482 if (fw) { |
|
1483 if(fw->window()->isModal()) // restore pointer capture for modal window |
|
1484 fw->effectiveWinId()->SetPointerCapture(true); |
|
1485 |
1445 if (fw != q_func()->focusWidget()) { |
1486 if (fw != q_func()->focusWidget()) { |
1446 fw->setFocus(Qt::PopupFocusReason); |
1487 fw->setFocus(Qt::PopupFocusReason); |
1447 } else { |
1488 } else { |
1448 QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); |
1489 QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); |
1449 q_func()->sendEvent(fw, &e); |
1490 q_func()->sendEvent(fw, &e); |
1645 if (!w->d_func()->maybeTopData()) |
1686 if (!w->d_func()->maybeTopData()) |
1646 break; |
1687 break; |
1647 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { |
1688 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { |
1648 delete w->d_func()->topData()->backingStore; |
1689 delete w->d_func()->topData()->backingStore; |
1649 w->d_func()->topData()->backingStore = 0; |
1690 w->d_func()->topData()->backingStore = 0; |
1650 // :QTP:QT-2506:remove this when QT-2506 is fixed |
1691 // In order to ensure that any resources used by the window surface |
1651 if (S60) |
1692 // are immediately freed, we flush the WSERV command buffer. |
1652 S60->wsSession().Flush(); |
1693 S60->wsSession().Flush(); |
1653 } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) |
1694 } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) |
1654 && !w->d_func()->maybeBackingStore()) { |
1695 && !w->d_func()->maybeBackingStore()) { |
1655 w->d_func()->topData()->backingStore = new QWidgetBackingStore(w); |
1696 w->d_func()->topData()->backingStore = new QWidgetBackingStore(w); |
1656 w->d_func()->invalidateBuffer(w->rect()); |
1697 w->d_func()->invalidateBuffer(w->rect()); |
1657 w->repaint(); |
1698 w->repaint(); |