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 ** |
805 } |
805 } |
806 #endif |
806 #endif |
807 |
807 |
808 void QSymbianControl::Draw(const TRect& controlRect) const |
808 void QSymbianControl::Draw(const TRect& controlRect) const |
809 { |
809 { |
|
810 // Set flag to avoid calling DrawNow in window surface |
|
811 QWExtra *extra = qwidget->d_func()->extraData(); |
|
812 if (extra && !extra->inExpose) { |
|
813 extra->inExpose = true; |
|
814 QRect exposeRect = qt_TRect2QRect(controlRect); |
|
815 qwidget->d_func()->syncBackingStore(exposeRect); |
|
816 extra->inExpose = false; |
|
817 } |
|
818 |
810 QWindowSurface *surface = qwidget->windowSurface(); |
819 QWindowSurface *surface = qwidget->windowSurface(); |
811 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
820 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
812 |
821 |
813 if (!engine) |
822 if (!engine) |
814 return; |
823 return; |
928 } |
935 } |
929 } |
936 } |
930 |
937 |
931 void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) |
938 void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) |
932 { |
939 { |
933 if (m_ignoreFocusChanged) |
940 if (m_ignoreFocusChanged || (qwidget->windowType() & Qt::WindowType_Mask) == Qt::Desktop) |
934 return; |
941 return; |
935 |
942 |
936 // Popups never get focused, but still receive the FocusChanged when they are hidden. |
943 // Popups never get focused, but still receive the FocusChanged when they are hidden. |
937 if (QApplicationPrivate::popupWidgets != 0 |
944 if (QApplicationPrivate::popupWidgets != 0 |
938 || (qwidget->windowType() & Qt::Popup) == Qt::Popup) |
945 || (qwidget->windowType() & Qt::Popup) == Qt::Popup) |
1547 if (symbianEventFilter(event)) |
1563 if (symbianEventFilter(event)) |
1548 return 1; |
1564 return 1; |
1549 |
1565 |
1550 switch (event->type()) { |
1566 switch (event->type()) { |
1551 case QSymbianEvent::WindowServerEvent: |
1567 case QSymbianEvent::WindowServerEvent: |
1552 return d->symbianProcessWsEvent(event->windowServerEvent()); |
1568 return d->symbianProcessWsEvent(event); |
1553 case QSymbianEvent::CommandEvent: |
1569 case QSymbianEvent::CommandEvent: |
1554 return d->symbianHandleCommand(event->command()); |
1570 return d->symbianHandleCommand(event); |
1555 case QSymbianEvent::ResourceChangeEvent: |
1571 case QSymbianEvent::ResourceChangeEvent: |
1556 return d->symbianResourceChange(event->resourceChangeType()); |
1572 return d->symbianResourceChange(event); |
1557 default: |
1573 default: |
1558 return -1; |
1574 return -1; |
1559 } |
1575 } |
1560 } |
1576 } |
1561 |
1577 |
1562 int QApplicationPrivate::symbianProcessWsEvent(const TWsEvent *event) |
1578 int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent) |
1563 { |
1579 { |
1564 // Qt event handling. Handle some events regardless of if the handle is in our |
1580 // Qt event handling. Handle some events regardless of if the handle is in our |
1565 // widget map or not. |
1581 // widget map or not. |
|
1582 const TWsEvent *event = symbianEvent->windowServerEvent(); |
1566 CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle()); |
1583 CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle()); |
1567 const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control); |
1584 const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control); |
1568 switch (event->Type()) { |
1585 switch (event->Type()) { |
1569 case EEventPointerEnter: |
1586 case EEventPointerEnter: |
1570 if (controlInMap) |
1587 if (controlInMap) { |
|
1588 callSymbianEventFilters(symbianEvent); |
1571 return 1; // Qt::Enter will be generated in HandlePointerL |
1589 return 1; // Qt::Enter will be generated in HandlePointerL |
|
1590 } |
1572 break; |
1591 break; |
1573 case EEventPointerExit: |
1592 case EEventPointerExit: |
1574 if (controlInMap) { |
1593 if (controlInMap) { |
|
1594 if (callSymbianEventFilters(symbianEvent)) |
|
1595 return 1; |
1575 if (S60) { |
1596 if (S60) { |
1576 // mouseEvent outside our window, send leave event to last focused widget |
1597 // mouseEvent outside our window, send leave event to last focused widget |
1577 QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos, |
1598 QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos, |
1578 Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); |
1599 Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); |
1579 if (S60->lastPointerEventTarget) |
1600 if (S60->lastPointerEventTarget) |
1582 } |
1603 } |
1583 return 1; |
1604 return 1; |
1584 } |
1605 } |
1585 break; |
1606 break; |
1586 case EEventScreenDeviceChanged: |
1607 case EEventScreenDeviceChanged: |
|
1608 if (callSymbianEventFilters(symbianEvent)) |
|
1609 return 1; |
1587 if (S60) |
1610 if (S60) |
1588 S60->updateScreenSize(); |
1611 S60->updateScreenSize(); |
1589 if (qt_desktopWidget) { |
1612 if (qt_desktopWidget) { |
1590 QSize oldSize = qt_desktopWidget->size(); |
1613 QSize oldSize = qt_desktopWidget->size(); |
1591 qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels); |
1614 qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels); |
1594 QApplication::sendEvent(qt_desktopWidget, &e); |
1617 QApplication::sendEvent(qt_desktopWidget, &e); |
1595 } |
1618 } |
1596 return 0; // Propagate to CONE |
1619 return 0; // Propagate to CONE |
1597 case EEventWindowVisibilityChanged: |
1620 case EEventWindowVisibilityChanged: |
1598 if (controlInMap) { |
1621 if (controlInMap) { |
|
1622 if (callSymbianEventFilters(symbianEvent)) |
|
1623 return 1; |
1599 const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); |
1624 const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); |
1600 QWidget *w = QWidgetPrivate::mapper->value(control); |
1625 QWidget *w = QWidgetPrivate::mapper->value(control); |
1601 if (!w->d_func()->maybeTopData()) |
1626 if (!w->d_func()->maybeTopData()) |
1602 break; |
1627 break; |
1603 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { |
1628 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { |
1614 } |
1639 } |
1615 return 1; |
1640 return 1; |
1616 } |
1641 } |
1617 break; |
1642 break; |
1618 case EEventFocusGained: |
1643 case EEventFocusGained: |
|
1644 if (callSymbianEventFilters(symbianEvent)) |
|
1645 return 1; |
1619 #ifndef QT_NO_CURSOR |
1646 #ifndef QT_NO_CURSOR |
1620 //re-enable mouse interaction |
1647 //re-enable mouse interaction |
1621 if (S60->mouseInteractionEnabled) { |
1648 if (S60->mouseInteractionEnabled) { |
1622 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
1649 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
1623 if (S60->brokenPointerCursors) |
1650 if (S60->brokenPointerCursors) |
1627 S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); |
1654 S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); |
1628 } |
1655 } |
1629 #endif |
1656 #endif |
1630 break; |
1657 break; |
1631 case EEventFocusLost: |
1658 case EEventFocusLost: |
|
1659 if (callSymbianEventFilters(symbianEvent)) |
|
1660 return 1; |
1632 #ifndef QT_NO_CURSOR |
1661 #ifndef QT_NO_CURSOR |
1633 //disable mouse as may be moving to application that does not support it |
1662 //disable mouse as may be moving to application that does not support it |
1634 if (S60->mouseInteractionEnabled) { |
1663 if (S60->mouseInteractionEnabled) { |
1635 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
1664 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
1636 if (S60->brokenPointerCursors) |
1665 if (S60->brokenPointerCursors) |
1678 partially achieved by deriving from CAknAppUi. Currently, exit, |
1707 partially achieved by deriving from CAknAppUi. Currently, exit, |
1679 menu and softkey commands are handled. |
1708 menu and softkey commands are handled. |
1680 |
1709 |
1681 \sa s60EventFilter(), s60ProcessEvent() |
1710 \sa s60EventFilter(), s60ProcessEvent() |
1682 */ |
1711 */ |
1683 int QApplicationPrivate::symbianHandleCommand(int command) |
1712 int QApplicationPrivate::symbianHandleCommand(const QSymbianEvent *symbianEvent) |
1684 { |
1713 { |
1685 Q_Q(QApplication); |
1714 Q_Q(QApplication); |
1686 int ret = 0; |
1715 int ret = 0; |
|
1716 |
|
1717 if (callSymbianEventFilters(symbianEvent)) |
|
1718 return 1; |
|
1719 |
|
1720 int command = symbianEvent->command(); |
1687 |
1721 |
1688 switch (command) { |
1722 switch (command) { |
1689 #ifdef Q_WS_S60 |
1723 #ifdef Q_WS_S60 |
1690 case EAknSoftkeyExit: { |
1724 case EAknSoftkeyExit: { |
1691 QCloseEvent ev; |
1725 QCloseEvent ev; |
1722 Handles the resource change specified by \a type. |
1756 Handles the resource change specified by \a type. |
1723 |
1757 |
1724 Currently, KEikDynamicLayoutVariantSwitch and |
1758 Currently, KEikDynamicLayoutVariantSwitch and |
1725 KAknsMessageSkinChange are handled. |
1759 KAknsMessageSkinChange are handled. |
1726 */ |
1760 */ |
1727 int QApplicationPrivate::symbianResourceChange(int type) |
1761 int QApplicationPrivate::symbianResourceChange(const QSymbianEvent *symbianEvent) |
1728 { |
1762 { |
1729 int ret = 0; |
1763 int ret = 0; |
|
1764 |
|
1765 int type = symbianEvent->resourceChangeType(); |
1730 |
1766 |
1731 switch (type) { |
1767 switch (type) { |
1732 #ifdef Q_WS_S60 |
1768 #ifdef Q_WS_S60 |
1733 case KEikDynamicLayoutVariantSwitch: |
1769 case KEikDynamicLayoutVariantSwitch: |
1734 { |
1770 { |
|
1771 if (callSymbianEventFilters(symbianEvent)) |
|
1772 return 1; |
1735 if (S60) |
1773 if (S60) |
1736 S60->updateScreenSize(); |
1774 S60->updateScreenSize(); |
1737 |
1775 |
1738 #ifndef QT_NO_STYLE_S60 |
1776 #ifndef QT_NO_STYLE_S60 |
1739 QS60Style *s60Style = 0; |
1777 QS60Style *s60Style = 0; |