src/gui/kernel/qapplication_s60.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    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
    69 # if !defined(QT_NO_IM)
    70 # if !defined(QT_NO_IM)
    70 #  include "qinputcontext.h"
    71 #  include "qinputcontext.h"
    71 #  include <private/qcoefepinputcontext_p.h>
    72 #  include <private/qcoefepinputcontext_p.h>
    72 # endif
    73 # endif
    73 # include <private/qs60mainapplication_p.h>
    74 # include <private/qs60mainapplication_p.h>
       
    75 # include <centralrepository.h>
    74 #endif
    76 #endif
    75 
    77 
    76 #include "private/qstylesheetstyle_p.h"
    78 #include "private/qstylesheetstyle_p.h"
    77 
    79 
    78 #include <hal.h>
    80 #include <hal.h>
   594         */
   596         */
   595 
   597 
   596         TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode,
   598         TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode,
   597                 keyEvent.iCode);
   599                 keyEvent.iCode);
   598         int keyCode;
   600         int keyCode;
   599         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) {
   600             // Normal characters keys.
   604             // Normal characters keys.
   601             keyCode = s60Keysym;
   605             keyCode = s60Keysym;
   602         } else {
   606         } else {
   603             // Special S60 keys.
   607             // Special S60 keys.
   604             keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym);
   608             keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym);
   805 }
   809 }
   806 #endif
   810 #endif
   807 
   811 
   808 void QSymbianControl::Draw(const TRect& controlRect) const
   812 void QSymbianControl::Draw(const TRect& controlRect) const
   809 {
   813 {
       
   814     // Set flag to avoid calling DrawNow in window surface
       
   815     QWidget *window = qwidget->window();
       
   816     Q_ASSERT(window);
       
   817     QTLWExtra *topExtra = window->d_func()->maybeTopData();
       
   818     Q_ASSERT(topExtra);
       
   819     if (!topExtra->inExpose) {
       
   820         topExtra->inExpose = true;
       
   821         QRect exposeRect = qt_TRect2QRect(controlRect);
       
   822         qwidget->d_func()->syncBackingStore(exposeRect);
       
   823         topExtra->inExpose = false;
       
   824     }
       
   825 
   810     QWindowSurface *surface = qwidget->windowSurface();
   826     QWindowSurface *surface = qwidget->windowSurface();
   811     QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL;
   827     QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL;
   812 
   828 
   813     if (!engine)
   829     if (!engine)
   814         return;
   830         return;
   853             break;
   869             break;
   854 
   870 
   855         default:
   871         default:
   856             Q_ASSERT(false);
   872             Q_ASSERT(false);
   857         }
   873         }
   858     } else {
       
   859         surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint());
       
   860     }
   874     }
   861 
   875 
   862     if (sendNativePaintEvents) {
   876     if (sendNativePaintEvents) {
   863         const QRect r = qt_TRect2QRect(controlRect);
   877         const QRect r = qt_TRect2QRect(controlRect);
   864         // The draw ops aren't actually sent to WSERV until the graphics
   878         // The draw ops aren't actually sent to WSERV until the graphics
   914     if (oldPos != newPos) {
   928     if (oldPos != newPos) {
   915         QRect cr = qwidget->geometry();
   929         QRect cr = qwidget->geometry();
   916         cr.moveTopLeft(newPos);
   930         cr.moveTopLeft(newPos);
   917         qwidget->data->crect = cr;
   931         qwidget->data->crect = cr;
   918         QTLWExtra *top = qwidget->d_func()->maybeTopData();
   932         QTLWExtra *top = qwidget->d_func()->maybeTopData();
   919         if (top)
   933         if (top && (qwidget->windowState() & (~Qt::WindowActive)) == Qt::WindowNoState)
   920             top->normalGeometry = cr;
   934             top->normalGeometry.moveTopLeft(newPos);
   921         if (qwidget->isVisible()) {
   935         if (qwidget->isVisible()) {
   922             QMoveEvent e(newPos, oldPos);
   936             QMoveEvent e(newPos, oldPos);
   923             qt_sendSpontaneousEvent(qwidget, &e);
   937             qt_sendSpontaneousEvent(qwidget, &e);
   924         } else {
   938         } else {
   925             QMoveEvent * e = new QMoveEvent(newPos, oldPos);
   939             QMoveEvent * e = new QMoveEvent(newPos, oldPos);
   928     }
   942     }
   929 }
   943 }
   930 
   944 
   931 void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
   945 void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
   932 {
   946 {
   933     if (m_ignoreFocusChanged)
   947     if (m_ignoreFocusChanged || (qwidget->windowType() & Qt::WindowType_Mask) == Qt::Desktop)
   934         return;
   948         return;
   935 
   949 
   936     // Popups never get focused, but still receive the FocusChanged when they are hidden.
   950     // Popups never get focused, but still receive the FocusChanged when they are hidden.
   937     if (QApplicationPrivate::popupWidgets != 0
   951     if (QApplicationPrivate::popupWidgets != 0
   938             || (qwidget->windowType() & Qt::Popup) == Qt::Popup)
   952             || (qwidget->windowType() & Qt::Popup) == Qt::Popup)
   950 
   964 
   951         QApplication::setActiveWindow(qwidget->window());
   965         QApplication::setActiveWindow(qwidget->window());
   952         qwidget->d_func()->setWindowIcon_sys(true);
   966         qwidget->d_func()->setWindowIcon_sys(true);
   953         qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
   967         qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
   954 #ifdef Q_WS_S60
   968 #ifdef Q_WS_S60
   955         // 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.
   956         // otherwise show them.
   970         CEikStatusPane *statusPane = S60->statusPane();
   957         CEikStatusPane* statusPane = S60->statusPane();
   971         CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer();
   958         CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
   972         TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized));
   959         bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen;
   973         if (statusPane)
   960         if (statusPane && (bool)statusPane->IsVisible() == isFullscreen)
   974             statusPane->MakeVisible(visible);
   961             statusPane->MakeVisible(!isFullscreen);
   975         if (buttonGroup) {
   962         if (buttonGroup && (bool)buttonGroup->IsVisible() == isFullscreen)
   976             // Visibility
   963             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         }
   964 #endif
   990 #endif
   965     } else if (QApplication::activeWindow() == qwidget->window()) {
   991     } else if (QApplication::activeWindow() == qwidget->window()) {
   966         if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) {
   992         if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) {
   967             QWidget *fw = QApplication::focusWidget();
   993             QWidget *fw = QApplication::focusWidget();
   968             if (fw) {
   994             if (fw) {
   976         QApplication::setActiveWindow(0);
  1002         QApplication::setActiveWindow(0);
   977     }
  1003     }
   978     // 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 }
   979 }
  1005 }
   980 
  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 
   981 void QSymbianControl::HandleResourceChange(int resourceType)
  1028 void QSymbianControl::HandleResourceChange(int resourceType)
   982 {
  1029 {
   983     switch (resourceType) {
  1030     switch (resourceType) {
   984     case KInternalStatusPaneChange:
  1031     case KInternalStatusPaneChange:
   985         if (qwidget->isFullScreen()) {
  1032         handleClientAreaChange();
   986             SetExtentToWholeScreen();
       
   987         } else if (qwidget->isMaximized()) {
       
   988             TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
       
   989             SetExtent(r.iTl, r.Size());
       
   990         }
       
   991         if (IsFocused() && IsVisible()) {
  1033         if (IsFocused() && IsVisible()) {
   992             qwidget->d_func()->setWindowIcon_sys(true);
  1034             qwidget->d_func()->setWindowIcon_sys(true);
   993             qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
  1035             qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
   994         }
  1036         }
   995         break;
  1037         break;
   997         // font change event
  1039         // font change event
   998         break;
  1040         break;
   999 #ifdef Q_WS_S60
  1041 #ifdef Q_WS_S60
  1000     case KEikDynamicLayoutVariantSwitch:
  1042     case KEikDynamicLayoutVariantSwitch:
  1001     {
  1043     {
  1002         if (qwidget->isFullScreen()) {
  1044         handleClientAreaChange();
  1003             SetExtentToWholeScreen();
       
  1004         } else if (qwidget->isMaximized()) {
       
  1005             TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
       
  1006             SetExtent(r.iTl, r.Size());
       
  1007         }
       
  1008         break;
  1045         break;
  1009     }
  1046     }
  1010 #endif
  1047 #endif
  1011     default:
  1048     default:
  1012         break;
  1049         break;
  1133 
  1170 
  1134 #ifdef QT_NO_DEBUG
  1171 #ifdef QT_NO_DEBUG
  1135     if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty())
  1172     if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty())
  1136 #endif
  1173 #endif
  1137         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
  1138 
  1179 
  1139     S60->updateScreenSize();
  1180     S60->updateScreenSize();
  1140 
  1181 
  1141 
  1182 
  1142     TDisplayMode mode = S60->screenDevice()->DisplayMode();
  1183     TDisplayMode mode = S60->screenDevice()->DisplayMode();
  1195     else {
  1236     else {
  1196         S60->hasTouchscreen = true;
  1237         S60->hasTouchscreen = true;
  1197         S60->virtualMouseRequired = false;
  1238         S60->virtualMouseRequired = false;
  1198     }
  1239     }
  1199 
  1240 
       
  1241     S60->avkonComponentsSupportTransparency = false;
       
  1242 
       
  1243 #ifdef Q_WS_S60
       
  1244     TUid KCRUidAvkon = { 0x101F876E };
       
  1245     TUint32 KAknAvkonTransparencyEnabled = 0x0000000D;
       
  1246 
       
  1247     CRepository* repository = 0;
       
  1248     TRAP(err, repository = CRepository::NewL(KCRUidAvkon));
       
  1249 
       
  1250     if(err == KErrNone) {
       
  1251         TInt value = 0;
       
  1252         err = repository->Get(KAknAvkonTransparencyEnabled, value);
       
  1253         if(err == KErrNone) {
       
  1254             S60->avkonComponentsSupportTransparency = (value==1) ? true : false;
       
  1255         }
       
  1256     }
       
  1257 #endif
       
  1258 
  1200     if (touch) {
  1259     if (touch) {
  1201         QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
  1260         QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
  1202     } else {
  1261     } else {
  1203         QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
  1262         QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
  1204     }
  1263     }
  1348     app_do_modal = qt_modal_stack != 0;
  1407     app_do_modal = qt_modal_stack != 0;
  1349 }
  1408 }
  1350 
  1409 
  1351 void QApplicationPrivate::openPopup(QWidget *popup)
  1410 void QApplicationPrivate::openPopup(QWidget *popup)
  1352 {
  1411 {
       
  1412     if (popup && qobject_cast<QComboBox *>(popup->parentWidget()))
       
  1413         static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(ETrue);
       
  1414 
  1353     if (!QApplicationPrivate::popupWidgets)
  1415     if (!QApplicationPrivate::popupWidgets)
  1354         QApplicationPrivate::popupWidgets = new QWidgetList;
  1416         QApplicationPrivate::popupWidgets = new QWidgetList;
  1355     QApplicationPrivate::popupWidgets->append(popup);
  1417     QApplicationPrivate::popupWidgets->append(popup);
  1356 
       
  1357 
  1418 
  1358     // Cancel focus widget pointer capture and long tap timer
  1419     // Cancel focus widget pointer capture and long tap timer
  1359     if (QApplication::focusWidget()) {
  1420     if (QApplication::focusWidget()) {
  1360         static_cast<QSymbianControl*>(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer();
  1421         static_cast<QSymbianControl*>(QApplication::focusWidget()->effectiveWinId())->CancelLongTapTimer();
  1361         QApplication::focusWidget()->effectiveWinId()->SetPointerCapture(false);
  1422         QApplication::focusWidget()->effectiveWinId()->SetPointerCapture(false);
  1391     }
  1452     }
  1392 }
  1453 }
  1393 
  1454 
  1394 void QApplicationPrivate::closePopup(QWidget *popup)
  1455 void QApplicationPrivate::closePopup(QWidget *popup)
  1395 {
  1456 {
       
  1457     if (popup && qobject_cast<QComboBox *>(popup->parentWidget()))
       
  1458         static_cast<QSymbianControl *>(popup->effectiveWinId())->FadeBehindPopup(EFalse);
       
  1459 
  1396     if (!QApplicationPrivate::popupWidgets)
  1460     if (!QApplicationPrivate::popupWidgets)
  1397         return;
  1461         return;
  1398     QApplicationPrivate::popupWidgets->removeAll(popup);
  1462     QApplicationPrivate::popupWidgets->removeAll(popup);
  1399 
  1463 
  1400     // Cancel pointer capture and long tap for this popup
  1464     // Cancel pointer capture and long tap for this popup
  1414                 QWidgetPrivate::keyboardGrabber->grabKeyboard();
  1478                 QWidgetPrivate::keyboardGrabber->grabKeyboard();
  1415 
  1479 
  1416         QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget()
  1480         QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget()
  1417               : q_func()->focusWidget();
  1481               : q_func()->focusWidget();
  1418           if (fw) {
  1482           if (fw) {
       
  1483               if(fw->window()->isModal()) // restore pointer capture for modal window
       
  1484                   fw->effectiveWinId()->SetPointerCapture(true);
       
  1485 
  1419               if (fw != q_func()->focusWidget()) {
  1486               if (fw != q_func()->focusWidget()) {
  1420                   fw->setFocus(Qt::PopupFocusReason);
  1487                   fw->setFocus(Qt::PopupFocusReason);
  1421               } else {
  1488               } else {
  1422                   QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
  1489                   QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
  1423                   q_func()->sendEvent(fw, &e);
  1490                   q_func()->sendEvent(fw, &e);
  1519     }
  1586     }
  1520     if (qt_S60Beep)
  1587     if (qt_S60Beep)
  1521         qt_S60Beep->Play();
  1588         qt_S60Beep->Play();
  1522 }
  1589 }
  1523 
  1590 
       
  1591 static inline bool callSymbianEventFilters(const QSymbianEvent *event)
       
  1592 {
       
  1593     long unused;
       
  1594     return qApp->filterEvent(const_cast<QSymbianEvent *>(event), &unused);
       
  1595 }
       
  1596 
  1524 /*!
  1597 /*!
  1525     \warning This function is only available on Symbian.
  1598     \warning This function is only available on Symbian.
  1526     \since 4.6
  1599     \since 4.6
  1527 
  1600 
  1528     This function processes an individual Symbian event
  1601     This function processes an individual Symbian event
  1535 {
  1608 {
  1536     Q_D(QApplication);
  1609     Q_D(QApplication);
  1537 
  1610 
  1538     QScopedLoopLevelCounter counter(d->threadData);
  1611     QScopedLoopLevelCounter counter(d->threadData);
  1539 
  1612 
       
  1613     if (d->eventDispatcher->filterEvent(const_cast<QSymbianEvent *>(event)))
       
  1614         return 1;
       
  1615 
  1540     QWidget *w = qApp ? qApp->focusWidget() : 0;
  1616     QWidget *w = qApp ? qApp->focusWidget() : 0;
  1541     if (w) {
  1617     if (w) {
  1542         QInputContext *ic = w->inputContext();
  1618         QInputContext *ic = w->inputContext();
  1543         if (ic && ic->symbianFilterEvent(w, event))
  1619         if (ic && ic->symbianFilterEvent(w, event))
  1544             return 1;
  1620             return 1;
  1547     if (symbianEventFilter(event))
  1623     if (symbianEventFilter(event))
  1548         return 1;
  1624         return 1;
  1549 
  1625 
  1550     switch (event->type()) {
  1626     switch (event->type()) {
  1551     case QSymbianEvent::WindowServerEvent:
  1627     case QSymbianEvent::WindowServerEvent:
  1552         return d->symbianProcessWsEvent(event->windowServerEvent());
  1628         return d->symbianProcessWsEvent(event);
  1553     case QSymbianEvent::CommandEvent:
  1629     case QSymbianEvent::CommandEvent:
  1554         return d->symbianHandleCommand(event->command());
  1630         return d->symbianHandleCommand(event);
  1555     case QSymbianEvent::ResourceChangeEvent:
  1631     case QSymbianEvent::ResourceChangeEvent:
  1556         return d->symbianResourceChange(event->resourceChangeType());
  1632         return d->symbianResourceChange(event);
  1557     default:
  1633     default:
  1558         return -1;
  1634         return -1;
  1559     }
  1635     }
  1560 }
  1636 }
  1561 
  1637 
  1562 int QApplicationPrivate::symbianProcessWsEvent(const TWsEvent *event)
  1638 int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent)
  1563 {
  1639 {
  1564     // Qt event handling. Handle some events regardless of if the handle is in our
  1640     // Qt event handling. Handle some events regardless of if the handle is in our
  1565     // widget map or not.
  1641     // widget map or not.
       
  1642     const TWsEvent *event = symbianEvent->windowServerEvent();
  1566     CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle());
  1643     CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle());
  1567     const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control);
  1644     const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control);
  1568     switch (event->Type()) {
  1645     switch (event->Type()) {
  1569     case EEventPointerEnter:
  1646     case EEventPointerEnter:
  1570         if (controlInMap)
  1647         if (controlInMap) {
       
  1648             callSymbianEventFilters(symbianEvent);
  1571             return 1; // Qt::Enter will be generated in HandlePointerL
  1649             return 1; // Qt::Enter will be generated in HandlePointerL
       
  1650         }
  1572         break;
  1651         break;
  1573     case EEventPointerExit:
  1652     case EEventPointerExit:
  1574         if (controlInMap) {
  1653         if (controlInMap) {
       
  1654             if (callSymbianEventFilters(symbianEvent))
       
  1655                 return 1;
  1575             if (S60) {
  1656             if (S60) {
  1576                 // mouseEvent outside our window, send leave event to last focused widget
  1657                 // mouseEvent outside our window, send leave event to last focused widget
  1577                 QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos,
  1658                 QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos,
  1578                     Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier);
  1659                     Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier);
  1579                 if (S60->lastPointerEventTarget)
  1660                 if (S60->lastPointerEventTarget)
  1582             }
  1663             }
  1583             return 1;
  1664             return 1;
  1584         }
  1665         }
  1585         break;
  1666         break;
  1586     case EEventScreenDeviceChanged:
  1667     case EEventScreenDeviceChanged:
       
  1668         if (callSymbianEventFilters(symbianEvent))
       
  1669             return 1;
  1587         if (S60)
  1670         if (S60)
  1588             S60->updateScreenSize();
  1671             S60->updateScreenSize();
  1589         if (qt_desktopWidget) {
  1672         if (qt_desktopWidget) {
  1590             QSize oldSize = qt_desktopWidget->size();
  1673             QSize oldSize = qt_desktopWidget->size();
  1591             qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
  1674             qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
  1594             QApplication::sendEvent(qt_desktopWidget, &e);
  1677             QApplication::sendEvent(qt_desktopWidget, &e);
  1595         }
  1678         }
  1596         return 0; // Propagate to CONE
  1679         return 0; // Propagate to CONE
  1597     case EEventWindowVisibilityChanged:
  1680     case EEventWindowVisibilityChanged:
  1598         if (controlInMap) {
  1681         if (controlInMap) {
       
  1682             if (callSymbianEventFilters(symbianEvent))
       
  1683                 return 1;
  1599             const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged();
  1684             const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged();
  1600             QWidget *w = QWidgetPrivate::mapper->value(control);
  1685             QWidget *w = QWidgetPrivate::mapper->value(control);
  1601             if (!w->d_func()->maybeTopData())
  1686             if (!w->d_func()->maybeTopData())
  1602                 break;
  1687                 break;
  1603             if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) {
  1688             if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) {
  1604                 delete w->d_func()->topData()->backingStore;
  1689                 delete w->d_func()->topData()->backingStore;
  1605                 w->d_func()->topData()->backingStore = 0;
  1690                 w->d_func()->topData()->backingStore = 0;
  1606                 // :QTP:QT-2506:remove this when QT-2506 is fixed
  1691                 // In order to ensure that any resources used by the window surface
  1607                 if (S60)
  1692                 // are immediately freed, we flush the WSERV command buffer.
  1608                     S60->wsSession().Flush();
  1693                 S60->wsSession().Flush();
  1609             } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible)
  1694             } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible)
  1610                        && !w->d_func()->maybeBackingStore()) {
  1695                        && !w->d_func()->maybeBackingStore()) {
  1611                 w->d_func()->topData()->backingStore = new QWidgetBackingStore(w);
  1696                 w->d_func()->topData()->backingStore = new QWidgetBackingStore(w);
  1612                 w->d_func()->invalidateBuffer(w->rect());
  1697                 w->d_func()->invalidateBuffer(w->rect());
  1613                 w->repaint();
  1698                 w->repaint();
  1614             }
  1699             }
  1615             return 1;
  1700             return 1;
  1616         }
  1701         }
  1617         break;
  1702         break;
  1618     case EEventFocusGained:
  1703     case EEventFocusGained:
       
  1704         if (callSymbianEventFilters(symbianEvent))
       
  1705             return 1;
  1619 #ifndef QT_NO_CURSOR
  1706 #ifndef QT_NO_CURSOR
  1620         //re-enable mouse interaction
  1707         //re-enable mouse interaction
  1621         if (S60->mouseInteractionEnabled) {
  1708         if (S60->mouseInteractionEnabled) {
  1622 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
  1709 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
  1623             if (S60->brokenPointerCursors)
  1710             if (S60->brokenPointerCursors)
  1627                 S60->wsSession().SetPointerCursorMode(EPointerCursorNormal);
  1714                 S60->wsSession().SetPointerCursorMode(EPointerCursorNormal);
  1628         }
  1715         }
  1629 #endif
  1716 #endif
  1630         break;
  1717         break;
  1631     case EEventFocusLost:
  1718     case EEventFocusLost:
       
  1719         if (callSymbianEventFilters(symbianEvent))
       
  1720             return 1;
  1632 #ifndef QT_NO_CURSOR
  1721 #ifndef QT_NO_CURSOR
  1633         //disable mouse as may be moving to application that does not support it
  1722         //disable mouse as may be moving to application that does not support it
  1634         if (S60->mouseInteractionEnabled) {
  1723         if (S60->mouseInteractionEnabled) {
  1635 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
  1724 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
  1636             if (S60->brokenPointerCursors)
  1725             if (S60->brokenPointerCursors)
  1678   partially achieved by deriving from CAknAppUi. Currently, exit,
  1767   partially achieved by deriving from CAknAppUi. Currently, exit,
  1679   menu and softkey commands are handled.
  1768   menu and softkey commands are handled.
  1680 
  1769 
  1681   \sa s60EventFilter(), s60ProcessEvent()
  1770   \sa s60EventFilter(), s60ProcessEvent()
  1682 */
  1771 */
  1683 int QApplicationPrivate::symbianHandleCommand(int command)
  1772 int QApplicationPrivate::symbianHandleCommand(const QSymbianEvent *symbianEvent)
  1684 {
  1773 {
  1685     Q_Q(QApplication);
  1774     Q_Q(QApplication);
  1686     int ret = 0;
  1775     int ret = 0;
       
  1776 
       
  1777     if (callSymbianEventFilters(symbianEvent))
       
  1778         return 1;
       
  1779 
       
  1780     int command = symbianEvent->command();
  1687 
  1781 
  1688     switch (command) {
  1782     switch (command) {
  1689 #ifdef Q_WS_S60
  1783 #ifdef Q_WS_S60
  1690     case EAknSoftkeyExit: {
  1784     case EAknSoftkeyExit: {
  1691         QCloseEvent ev;
  1785         QCloseEvent ev;
  1722   Handles the resource change specified by \a type.
  1816   Handles the resource change specified by \a type.
  1723 
  1817 
  1724   Currently, KEikDynamicLayoutVariantSwitch and
  1818   Currently, KEikDynamicLayoutVariantSwitch and
  1725   KAknsMessageSkinChange are handled.
  1819   KAknsMessageSkinChange are handled.
  1726  */
  1820  */
  1727 int QApplicationPrivate::symbianResourceChange(int type)
  1821 int QApplicationPrivate::symbianResourceChange(const QSymbianEvent *symbianEvent)
  1728 {
  1822 {
  1729     int ret = 0;
  1823     int ret = 0;
       
  1824 
       
  1825     int type = symbianEvent->resourceChangeType();
  1730 
  1826 
  1731     switch (type) {
  1827     switch (type) {
  1732 #ifdef Q_WS_S60
  1828 #ifdef Q_WS_S60
  1733     case KEikDynamicLayoutVariantSwitch:
  1829     case KEikDynamicLayoutVariantSwitch:
  1734         {
  1830         {
       
  1831         if (callSymbianEventFilters(symbianEvent))
       
  1832             return 1;
  1735         if (S60)
  1833         if (S60)
  1736             S60->updateScreenSize();
  1834             S60->updateScreenSize();
  1737 
  1835 
  1738 #ifndef QT_NO_STYLE_S60
  1836 #ifndef QT_NO_STYLE_S60
  1739         QS60Style *s60Style = 0;
  1837         QS60Style *s60Style = 0;
  1754         }
  1852         }
  1755         break;
  1853         break;
  1756 
  1854 
  1757 #ifndef QT_NO_STYLE_S60
  1855 #ifndef QT_NO_STYLE_S60
  1758     case KAknsMessageSkinChange:
  1856     case KAknsMessageSkinChange:
       
  1857         if (callSymbianEventFilters(symbianEvent))
       
  1858             return 1;
  1759         if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style())) {
  1859         if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style())) {
  1760             s60Style->d_func()->handleSkinChange();
  1860             s60Style->d_func()->handleSkinChange();
  1761             ret = 1;
  1861             ret = 1;
  1762         }
  1862         }
  1763         break;
  1863         break;