diff options
Diffstat (limited to 'src')
80 files changed, 1307 insertions, 255 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 897dcea..6a781e8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2386,6 +2386,11 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #if defined(Q_OS_SYMBIAN) +#ifdef SYMBIAN_GRAPHICS_USE_GCE +//RWsPointerCursor is fixed, so don't use low performance sprites +#define Q_SYMBIAN_FIXED_POINTER_CURSORS +#endif + //Symbian does not support data imports from a DLL #define Q_NO_DATA_RELOCATION diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c8e30d4..c39e602 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1618,6 +1618,14 @@ public: GestureFinished = 3 }; + enum NavigationMode + { + NavigationModeNone, + NavigationModeKeypadTabOrder, + NavigationModeKeypadDirectional, + NavigationModeCursorAuto, + NavigationModeCursorForceVisible + }; } #ifdef Q_MOC_RUN ; diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 52fed47..314dfb2 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2781,3 +2781,29 @@ \sa QGesture */ + +/*! + \enum Qt::NavigationMode + \since 4.6 + + This enum type describes the mode for moving focus. + + \value NavigationModeNone Only the touch screen is used. + \value NavigationModeKeypadTabOrder Qt::Key_Up and Qt::Key_Down are used to change focus. + \value NavigationModeKeypadDirectional Qt::Key_Up, Qt::Key_Down, Qt::Key_Left and Qt::Key_Right are used to change focus. + \value NavigationModeCursorAuto The mouse cursor is used to change focus, + it is displayed only on non touchscreen devices. + The keypad is used to implement a virtual cursor, unless + the device has an analog mouse type of input device (e.g. touchpad). + This is the recommended setting for an application such as a web browser that + needs pointer control on both touch and non-touch devices. + \value NavigationModeCursorForceVisible The mouse cursor is used to change focus, + it is displayed regardless of device type. + The keypad is used to implement a virtual cursor, unless + the device has an analog mouse type of input device (e.g. touchpad) + + \note: in 4.6, cursor navigation is only implemented for Symbian OS. + On other platforms, it behaves as NavigationModeNone. + \sa QApplication::setNavigationMode + \sa QApplication::navigationMode +*/ diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 06f6688..b65f1d3 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -52,7 +52,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -#undef QT_QHASH_DEBUG QT_MODULE(Core) class QBitArray; diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 18d1f5c..c1be49a 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -51,7 +51,6 @@ #endif #include <new> -#undef QT_MAP_DEBUG QT_BEGIN_HEADER diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 493e440..666e557 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -178,7 +178,12 @@ CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const return 0; } - const QImage converted = img.convertToFormat(destFormat); + QImage converted = img.convertToFormat(destFormat); + + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + if (mode == EGray2) + converted.invertPixels(); bitmap->LockHeap(); const uchar *sptr = converted.bits(); @@ -220,6 +225,9 @@ QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) image.setNumColors(2); image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + image.invertPixels(); } else if (displayMode == EGray256) { for (int i=0; i < 256; ++i) image.setColor(i, qRgb(i, i, i)); diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 4fa2e6c..4fb650f 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -418,13 +418,12 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q return; QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? - static_cast<QPaintEngineEx *>(painter->paintEngine())->createPixmapFilter(type()) : 0; + static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter); if (convolutionFilter) { convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight); convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha; convolutionFilter->draw(painter, p, src, srcRect); - delete convolutionFilter; return; } @@ -669,13 +668,12 @@ void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap } QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? - static_cast<QPaintEngineEx *>(painter->paintEngine())->createPixmapFilter(type()) : 0; + static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter); if (blurFilter) { blurFilter->setRadius(d->radius); blurFilter->setQuality(d->quality); blurFilter->draw(painter, p, src, srcRect); - delete blurFilter; return; } @@ -836,13 +834,12 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q { Q_D(const QPixmapColorizeFilter); QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? - static_cast<QPaintEngineEx *>(painter->paintEngine())->createPixmapFilter(type()) : 0; + static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter); if (colorizeFilter) { colorizeFilter->setColor(d->color); colorizeFilter->setStrength(d->strength); colorizeFilter->draw(painter, dest, src, srcRect); - delete colorizeFilter; return; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index a19e022..1fd2d39 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -458,10 +458,10 @@ bool QApplicationPrivate::widgetCount = false; bool QApplicationPrivate::inSizeMove = false; #endif #ifdef QT_KEYPAD_NAVIGATION -# if defined(Q_OS_SYMBIAN) -bool QApplicationPrivate::keypadNavigation = true; +# ifdef Q_OS_SYMBIAN +Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; # else -bool QApplicationPrivate::keypadNavigation = false; +Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder; # endif QWidget *QApplicationPrivate::oldEditFocus = 0; #endif @@ -2521,12 +2521,6 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool Creates the proper Enter/Leave event when widget \a enter is entered and widget \a leave is left. */ -#if defined(Q_WS_WIN) - extern void qt_win_set_cursor(QWidget *, bool); -#elif defined(Q_WS_X11) - extern void qt_x11_enforce_cursor(QWidget *, bool); -#endif - void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { #if 0 if (leave) { @@ -2676,6 +2670,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { qt_win_set_cursor(cursorWidget, true); #elif defined(Q_WS_X11) qt_x11_enforce_cursor(cursorWidget, true); +#elif defined(Q_WS_S60) + qt_symbian_set_cursor(cursorWidget, true); #endif } } @@ -4777,10 +4773,36 @@ void QApplicationPrivate::emitLastWindowClosed() #ifdef QT_KEYPAD_NAVIGATION /*! - Sets whether Qt should use focus navigation suitable for use with a - minimal keypad. + Sets what kind of focus navigation Qt should use. + + This feature is available in Qt for Embedded Linux, Symbian and Windows CE + only. + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. + + \note On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a + virtual mouse cursor on non touchscreen devices, which is controlled + by the cursor keys if there is no analog pointer device. + On other platforms and on touchscreen devices, it has the same + meaning as Qt::NavigationModeNone. + + \since 4.6 + + \sa keypadNavigationEnabled() +*/ +void QApplication::setNavigationMode(Qt::NavigationMode mode) +{ +#ifdef Q_OS_SYMBIAN + QApplicationPrivate::setNavigationMode(mode); +#else + QApplicationPrivate::navigationMode = mode; +#endif +} - If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus. +/*! + Returns what kind of focus navigation Qt is using. This feature is available in Qt for Embedded Linux, Symbian and Windows CE only. @@ -4788,12 +4810,47 @@ void QApplicationPrivate::emitLastWindowClosed() \note On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined. + + \note On Symbian, the default mode is Qt::NavigationModeNone for touch + devices, and Qt::NavigationModeKeypadDirectional. + + \since 4.6 \sa keypadNavigationEnabled() */ +Qt::NavigationMode QApplication::navigationMode() +{ + return QApplicationPrivate::navigationMode; +} + +/*! + Sets whether Qt should use focus navigation suitable for use with a + minimal keypad. + + This feature is available in Qt for Embedded Linux, Symbian and Windows CE + only. + + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. + + \deprecated + + \sa setNavigationMode() +*/ void QApplication::setKeypadNavigationEnabled(bool enable) { - QApplicationPrivate::keypadNavigation = enable; + if (enable) { +#ifdef Q_OS_SYMBIAN + QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional); +#else + QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder); +#endif + } + else { + QApplication::setNavigationMode(Qt::NavigationModeNone); + } } /*! @@ -4806,12 +4863,15 @@ void QApplication::setKeypadNavigationEnabled(bool enable) \note On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined. + + \deprecated - \sa setKeypadNavigationEnabled() + \sa navigationMode() */ bool QApplication::keypadNavigationEnabled() { - return QApplicationPrivate::keypadNavigation; + return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder || + QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional; } #endif diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 216cfff..0562251 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -272,8 +272,10 @@ public: static bool quitOnLastWindowClosed(); #ifdef QT_KEYPAD_NAVIGATION - static void setKeypadNavigationEnabled(bool); + static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool); static bool keypadNavigationEnabled(); + static void setNavigationMode(Qt::NavigationMode mode); + static Qt::NavigationMode navigationMode(); #endif Q_SIGNALS: diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index c33eb1a..707caaa 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -71,6 +71,9 @@ #include "QtGui/qscreen_qws.h" #include <private/qgraphicssystem_qws_p.h> #endif +#ifdef Q_OS_SYMBIAN +#include <w32std.h> +#endif QT_BEGIN_NAMESPACE @@ -492,8 +495,8 @@ public: static int app_compile_version; #ifdef QT_KEYPAD_NAVIGATION - static bool keypadNavigation; static QWidget *oldEditFocus; + static Qt::NavigationMode navigationMode; #endif #if defined(Q_WS_MAC) || defined(Q_WS_X11) @@ -511,7 +514,9 @@ public: QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver, bool spontaneous = true); #ifdef Q_OS_SYMBIAN + static void setNavigationMode(Qt::NavigationMode mode); static TUint resolveS60ScanCode(TInt scanCode, TUint keysym); + QSet<WId> nativeWindows; #endif #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) void sendSyntheticEnterLeave(QWidget *widget); @@ -595,6 +600,15 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QTouchEvent::DeviceType deviceType, const QList<QTouchEvent::TouchPoint> &touchPoints); +#if defined(Q_WS_WIN) + extern void qt_win_set_cursor(QWidget *, bool); +#elif defined(Q_WS_X11) + extern void qt_x11_enforce_cursor(QWidget *, bool); + extern void qt_x11_enforce_cursor(QWidget *); +#elif defined(Q_OS_SYMBIAN) + extern void qt_symbian_set_cursor(QWidget *, bool); +#endif + QT_END_NAMESPACE #endif // QAPPLICATION_P_H diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 00932a0..fd889fc 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -73,6 +73,9 @@ #include "private/qstylesheetstyle_p.h" +#include <hal.h> +#include <hal_data.h> + QT_BEGIN_NAMESPACE #if defined(QT_DEBUG) @@ -151,21 +154,21 @@ void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) void QS60Beep::Play() { - if(iState!=EBeepNotPrepared){ - if(iState==EBeepPlaying) { + if (iState != EBeepNotPrepared) { + if (iState == EBeepPlaying) { iToneUtil->CancelPlay(); - iState=EBeepPrepared; + iState = EBeepPrepared; } } iToneUtil->Play(); - iState=EBeepPlaying; + iState = EBeepPlaying; } void QS60Beep::MatoPrepareComplete(TInt aError) { - if(aError==KErrNone) { - iState=EBeepPrepared; + if (aError == KErrNone) { + iState = EBeepPrepared; } } @@ -320,8 +323,9 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) { if (!desktop) { - if (topLevel) + if (topLevel) { CreateWindowL(S60->windowGroup()); + } SetFocusing(true); m_longTapDetector = QLongTapTimer::NewL(this); @@ -330,6 +334,8 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop) QSymbianControl::~QSymbianControl() { + if (S60->curWin == this) + S60->curWin = 0; S60->appUi()->RemoveFromStack(this); delete m_longTapDetector; } @@ -392,14 +398,15 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) TPoint controlScreenPos = PositionRelativeToScreen(); QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos; - if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick) + if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove) { - // get the button press target + // get the widget where the event happened alienWidget = qwidget->childAt(widgetPos); if (!alienWidget) alienWidget = qwidget; S60->mousePressTarget = alienWidget; } + alienWidget = S60->mousePressTarget; if (alienWidget != S60->lastPointerEventTarget) @@ -412,12 +419,30 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); events.append(Event(S60->lastPointerEventTarget,mEventLeave)); } - QMouseEvent mEventEnter(QEvent::Enter, alienWidget->mapFromGlobal(globalPos), globalPos, - button, QApplicationPrivate::mouse_buttons, mapToQtModifiers(pEvent.iModifiers)); - - events.append(Event(alienWidget,mEventEnter)); + if (alienWidget) { + QMouseEvent mEventEnter(QEvent::Enter, alienWidget->mapFromGlobal(globalPos), + globalPos, button, QApplicationPrivate::mouse_buttons, mapToQtModifiers( + pEvent.iModifiers)); + + events.append(Event(alienWidget, mEventEnter)); +#ifndef QT_NO_CURSOR + S60->curWin = alienWidget->effectiveWinId(); + if (!QApplication::overrideCursor()) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_set_pointer_sprite(alienWidget->cursor()); + else +#endif + qt_symbian_setWindowCursor(alienWidget->cursor(), S60->curWin); + } +#endif + } } S60->lastCursorPos = globalPos; +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_move_cursor_sprite(); +#endif S60->lastPointerEventPos = widgetPos; S60->lastPointerEventTarget = alienWidget; if (alienWidget) @@ -494,6 +519,82 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod // Special S60 keys. keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); } + +#ifndef QT_NO_CURSOR + if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { + //translate keys to pointer + if (keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down || keyCode == Qt::Key_Select) { + /*Explanation about virtualMouseAccel: + Tapping an arrow key allows precise pixel positioning + Holding an arrow key down, acceleration is applied to allow cursor + to be quickly moved to another part of the screen by key repeats. + */ + if (S60->virtualMouseLastKey == keyCode) { + S60->virtualMouseAccel *= 2; + if (S60->virtualMouseAccel > S60->virtualMouseMaxAccel) + S60->virtualMouseAccel = S60->virtualMouseMaxAccel; + } + else + S60->virtualMouseAccel = 1; + S60->virtualMouseLastKey = keyCode; + + QPoint pos = QCursor::pos(); + TPointerEvent fakeEvent; + TInt x = pos.x(); + TInt y = pos.y(); + if (type == EEventKeyUp) { + if (keyCode == Qt::Key_Select) + fakeEvent.iType = TPointerEvent::EButton1Up; + S60->virtualMouseAccel = 1; + S60->virtualMouseLastKey = 0; + } + else if (type == EEventKey) { + switch (keyCode) { + case Qt::Key_Left: + x -= S60->virtualMouseAccel; + fakeEvent.iType = TPointerEvent::EMove; + break; + case Qt::Key_Right: + x += S60->virtualMouseAccel; + fakeEvent.iType = TPointerEvent::EMove; + break; + case Qt::Key_Up: + y -= S60->virtualMouseAccel; + fakeEvent.iType = TPointerEvent::EMove; + break; + case Qt::Key_Down: + y += S60->virtualMouseAccel; + fakeEvent.iType = TPointerEvent::EMove; + break; + case Qt::Key_Select: + fakeEvent.iType = TPointerEvent::EButton1Down; + break; + } + } + //clip to screen size (window server allows a sprite hotspot to be outside the screen) + if (x < 0) + x = 0; + else if (x >= S60->screenWidthInPixels) + x = S60->screenWidthInPixels - 1; + if (y < 0) + y = 0; + else if (y >= S60->screenHeightInPixels) + y = S60->screenHeightInPixels - 1; + TPoint epos(x, y); + TPoint cpos = epos - PositionRelativeToScreen(); + fakeEvent.iModifiers = keyEvent.iModifiers; + fakeEvent.iPosition = cpos; + fakeEvent.iParentPosition = epos; + HandlePointerEvent(fakeEvent); + return EKeyWasConsumed; + } + else { + S60->virtualMouseLastKey = keyCode; + S60->virtualMouseAccel = 1; + } + } +#endif + Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), @@ -557,7 +658,7 @@ TKeyResponse QSymbianControl::sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent) #if !defined(QT_NO_IM) && defined(Q_WS_S60) if (widget && widget->isEnabled() && widget->testAttribute(Qt::WA_InputMethodEnabled)) { QInputContext *qic = widget->inputContext(); - if(qic && qic->filterEvent(keyEvent)) + if (qic && qic->filterEvent(keyEvent)) return EKeyWasConsumed; } #endif // !defined(QT_NO_IM) && defined(Q_WS_S60) @@ -574,11 +675,10 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const { QWidget *w = 0; - if(qwidget->hasFocus()) { + if (qwidget->hasFocus()) w = qwidget; - } else { + else w = qwidget->focusWidget(); - } QCoeFepInputContext *ic; if (w && w->isEnabled() && w->testAttribute(Qt::WA_InputMethodEnabled) @@ -749,6 +849,70 @@ void qt_init(QApplicationPrivate * /* priv */, int) TSecureId securId = me.SecureId(); S60->uid = securId.operator TUid(); + // enable focus events - used to re-enable mouse after focus changed between mouse and non mouse app, + // and for dimming behind modal windows + S60->windowGroup().EnableFocusChangeEvents(); + + //Check if mouse interaction is supported (either EMouse=1 in the HAL, or EMachineUID is one of the phones known to support this) + const TInt KMachineUidSamsungI8510 = 0x2000C51E; + const TInt KMachineUidSamsungI550 = 0x2000A678; + TInt machineUID; + TInt mouse; + TInt touch; + TInt err; + err = HAL::Get(HALData::EMouse, mouse); + if (err != KErrNone) + mouse = 0; + err = HAL::Get(HALData::EMachineUid, machineUID); + if (err != KErrNone) + machineUID = 0; + err = HAL::Get(HALData::EPen, touch); + if (err != KErrNone) + touch = 0; + if (mouse || machineUID == KMachineUidSamsungI8510) { + S60->hasTouchscreen = false; + S60->virtualMouseRequired = false; + } + else if (!touch) { + S60->hasTouchscreen = false; + S60->virtualMouseRequired = true; + } + else { + S60->hasTouchscreen = true; + S60->virtualMouseRequired = false; + } + + if (touch) { + QApplicationPrivate::navigationMode = Qt::NavigationModeNone; + } else { + QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; + } + + //Check if window server pointer cursors are supported or not +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + //In generic binary, use the HAL and OS version + //Any other known good phones should be added here. + if (machineUID == KMachineUidSamsungI8510 || (QSysInfo::symbianVersion() != QSysInfo::SV_9_4 + && QSysInfo::symbianVersion() != QSysInfo::SV_9_3 && QSysInfo::symbianVersion() + != QSysInfo::SV_9_2)) { + S60->brokenPointerCursors = false; + qt_symbian_setWindowGroupCursor(Qt::ArrowCursor, S60->windowGroup()); + } + else + S60->brokenPointerCursors = true; +#endif + + if (S60->mouseInteractionEnabled) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) { + qt_symbian_set_pointer_sprite(Qt::ArrowCursor); + qt_symbian_show_pointer_sprite(); + } + else +#endif + S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); + } + /* ### Commented out for now as parameter handling not needed in SOS(yet). Code below will break testlib with -o flag int argc = priv->argc; @@ -785,6 +949,9 @@ void qt_cleanup() // it dies. delete QApplicationPrivate::inputContext; QApplicationPrivate::inputContext = 0; + + //Change mouse pointer back + S60->wsSession().SetPointerCursorMode(EPointerCursorNone); if (S60->qtOwnsS60Environment) { CEikonEnv* coe = CEikonEnv::Static(); @@ -1016,9 +1183,8 @@ void QApplication::beep() TTimeIntervalMicroSeconds duration(500000); QS60Beep* beep=NULL; TRAPD(err, beep=QS60Beep::NewL(frequency, duration)); - if(!err) { + if (!err) beep->Play(); - } delete beep; beep=NULL; } @@ -1108,7 +1274,31 @@ int QApplication::s60ProcessEvent(TWsEvent *event) return 1; } break; - default: + case EEventFocusGained: + RDebug::Printf("focus gained %x", control); + //re-enable mouse interaction + if (S60->mouseInteractionEnabled) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_show_pointer_sprite(); + else +#endif + S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); + } + break; + case EEventFocusLost: + RDebug::Printf("focus lost %x", control); + //disable mouse as may be moving to application that does not support it + if (S60->mouseInteractionEnabled) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_hide_pointer_sprite(); + else +#endif + S60->wsSession().SetPointerCursorMode(EPointerCursorNone); + } + break; + default: break; } @@ -1279,4 +1469,81 @@ void QSessionManager::cancel() } #endif //QT_NO_SESSIONMANAGER + +#ifdef QT_KEYPAD_NAVIGATION +/* + * Show/Hide the mouse cursor depending on phone type and chosen mode + */ +void QApplicationPrivate::setNavigationMode(Qt::NavigationMode mode) +{ +#ifndef QT_NO_CURSOR + const bool wasCursorOn = (QApplicationPrivate::navigationMode == Qt::NavigationModeCursorAuto + && !S60->hasTouchscreen) + || QApplicationPrivate::navigationMode == Qt::NavigationModeCursorForceVisible; + const bool isCursorOn = (mode == Qt::NavigationModeCursorAuto + && !S60->hasTouchscreen) + || mode == Qt::NavigationModeCursorForceVisible; + + if (!wasCursorOn && isCursorOn) { + //Show the cursor, when changing from another mode to cursor mode + qt_symbian_set_cursor_visible(true); + } + else if (wasCursorOn && !isCursorOn) { + //Hide the cursor, when leaving cursor mode + qt_symbian_set_cursor_visible(false); + } +#endif + QApplicationPrivate::navigationMode = mode; +} +#endif + +#ifndef QT_NO_CURSOR +/***************************************************************************** + QApplication cursor stack + *****************************************************************************/ + +void QApplication::setOverrideCursor(const QCursor &cursor) +{ + qApp->d_func()->cursor_list.prepend(cursor); + qt_symbian_setGlobalCursor(cursor); +} + +void QApplication::restoreOverrideCursor() +{ + if (qApp->d_func()->cursor_list.isEmpty()) + return; + qApp->d_func()->cursor_list.removeFirst(); + + if (!qApp->d_func()->cursor_list.isEmpty()) { + qt_symbian_setGlobalCursor(qApp->d_func()->cursor_list.first()); + } + else { + //determine which widget has focus + QWidget *w = QApplication::widgetAt(QCursor::pos()); +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) { + qt_symbian_set_pointer_sprite(w ? w->cursor() : Qt::ArrowCursor); + } + else +#endif + { + //because of the internals of window server, we need to force the cursor + //to be set in all child windows too, otherwise when the cursor is over + //the child window it may show a widget cursor or arrow cursor instead, + //depending on construction order. + QListIterator<WId> iter(QWidgetPrivate::mapper->uniqueKeys()); + while (iter.hasNext()) { + CCoeControl *ctrl = iter.next(); + ctrl->DrawableWindow()->ClearPointerCursor(); + } + if (w) + qt_symbian_setWindowCursor(w->cursor(), w->effectiveWinId()); + else + qt_symbian_setWindowGroupCursor(Qt::ArrowCursor, S60->windowGroup()); + } + } +} + +#endif // QT_NO_CURSOR + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 1ce799c..601cd11 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -2820,8 +2820,6 @@ void QApplicationPrivate::applyX11SpecificCommandLineArguments(QWidget *main_wid QApplication cursor stack *****************************************************************************/ -extern void qt_x11_enforce_cursor(QWidget * w); - void QApplication::setOverrideCursor(const QCursor &cursor) { qApp->d_func()->cursor_list.prepend(cursor); diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index 389a110..2b2aa4a 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -72,13 +72,19 @@ private: #ifndef QT_NO_CURSOR -struct QCursorData; +class QCursorData; class QBitmap; class QPixmap; #if defined(Q_WS_MAC) void qt_mac_set_cursor(const QCursor *c, const QPoint &p); #endif +#if defined(Q_OS_SYMBIAN) +extern void qt_symbian_show_pointer_sprite(); +extern void qt_symbian_hide_pointer_sprite(); +extern void qt_symbian_set_pointer_sprite(const QCursor& cursor); +extern void qt_symbian_move_cursor_sprite(); +#endif class Q_GUI_EXPORT QCursor { @@ -103,7 +109,7 @@ public: static QPoint pos(); static void setPos(int x, int y); inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); } - + #ifdef qdoc HCURSOR_or_HANDLE handle() const; QCursor(HCURSOR cursor); @@ -122,6 +128,8 @@ public: Qt::HANDLE handle() const; #elif defined(Q_WS_QWS) int handle() const; +#elif defined(Q_OS_SYMBIAN) + Qt::HANDLE handle() const; #endif #endif @@ -131,6 +139,12 @@ private: friend void *qt_mac_nsCursorForQCursor(const QCursor &c); friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p); #endif +#if defined(Q_OS_SYMBIAN) + friend void qt_symbian_show_pointer_sprite(); + friend void qt_symbian_hide_pointer_sprite(); + friend void qt_symbian_set_pointer_sprite(const QCursor& cursor); + friend void qt_symbian_move_cursor_sprite(); +#endif }; #ifdef QT3_SUPPORT diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h index aa4f4b2..12166c8 100644 --- a/src/gui/kernel/qcursor_p.h +++ b/src/gui/kernel/qcursor_p.h @@ -64,6 +64,8 @@ # include "private/qt_x11_p.h" # elif defined(Q_WS_WIN) # include "QtCore/qt_windows.h" +# elif defined(Q_OS_SYMBIAN) +# include "private/qt_s60_p.h" #endif QT_BEGIN_NAMESPACE @@ -74,7 +76,8 @@ class QMacAnimateCursor; #endif class QBitmap; -struct QCursorData { +class QCursorData { +public: QCursorData(Qt::CursorShape s = Qt::ArrowCursor); ~QCursorData(); @@ -111,12 +114,21 @@ struct QCursorData { } curs; void initCursorFromBitmap(); void initCursorFromPixmap(); +#elif defined Q_OS_SYMBIAN + void loadShapeFromResource(RWsSpriteBase& target, QString resource, int hx, int hy, int interval=0); + void constructShapeSprite(RWsSpriteBase& target); + void constructCursorSprite(RWsSpriteBase& target); + RWsPointerCursor pcurs; + RWsSprite scurs; + RPointerArray<TSpriteMember> nativeSpriteMembers; #endif static bool initialized; void update(); static QCursorData *setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY); }; +extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp + QT_END_NAMESPACE #endif // QCURSOR_P_H diff --git a/src/gui/kernel/qcursor_qws.cpp b/src/gui/kernel/qcursor_qws.cpp index eda826b..0eeb187 100644 --- a/src/gui/kernel/qcursor_qws.cpp +++ b/src/gui/kernel/qcursor_qws.cpp @@ -78,8 +78,6 @@ QCursorData::~QCursorData() Global cursors *****************************************************************************/ -extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp - int QCursor::handle() const { return d->id; diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/gui/kernel/qcursor_s60.cpp index b812994..757eaa8 100644 --- a/src/gui/kernel/qcursor_s60.cpp +++ b/src/gui/kernel/qcursor_s60.cpp @@ -40,12 +40,22 @@ ****************************************************************************/ #include <private/qcursor_p.h> +#include <private/qwidget_p.h> +#include <private/qapplication_p.h> +#include <coecntrl.h> #include <qcursor.h> #include <qt_s60_p.h> +#include <qbitmap.h> +#include <w32std.h> +#include <qapplication.h> +#include <qwidget.h> -#ifdef QT_NO_CURSOR QT_BEGIN_NAMESPACE +static QCursor cursorSprite; +static int cursorSpriteVisible; + +//pos and setpos are required whether cursors are configured or not. QPoint QCursor::pos() { return S60->lastCursorPos; @@ -53,8 +63,467 @@ QPoint QCursor::pos() void QCursor::setPos(int x, int y) { + //clip to screen size (window server allows a sprite hotspot to be outside the screen) + if (x < 0) + x=0; + else if (x >= S60->screenWidthInPixels) + x = S60->screenWidthInPixels - 1; + if (y < 0) + y = 0; + else if (y >= S60->screenHeightInPixels) + y = S60->screenHeightInPixels - 1; + +#ifndef QT_NO_CURSOR +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors && cursorSpriteVisible) + cursorSprite.d->scurs.SetPosition(TPoint(x,y)); + else +#endif + S60->wsSession().SetPointerCursorPosition(TPoint(x, y)); +#endif S60->lastCursorPos = QPoint(x, y); + //send a fake mouse move event, so that enter/leave events go to the widget hierarchy + QWidget *w = QApplication::topLevelAt(S60->lastCursorPos); + if (w) { + CCoeControl* ctrl = w->effectiveWinId(); + TPoint epos(x, y); + TPoint cpos = epos - ctrl->PositionRelativeToScreen(); + TPointerEvent fakeEvent; + fakeEvent.iType = TPointerEvent::EMove; + fakeEvent.iModifiers = 0U; + fakeEvent.iPosition = cpos; + fakeEvent.iParentPosition = epos; + ctrl->HandlePointerEventL(fakeEvent); + } +} + +#ifndef QT_NO_CURSOR +/* + * Request cursor to be turned on or off. + * Reference counted, so 2 on + 1 off = on, for example + */ +void qt_symbian_set_cursor_visible(bool visible) { + if (visible) + cursorSpriteVisible++; + else + cursorSpriteVisible--; + Q_ASSERT(cursorSpriteVisible >=0); + + if (cursorSpriteVisible && !S60->mouseInteractionEnabled) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_show_pointer_sprite(); + else +#endif + S60->wsSession().SetPointerCursorMode(EPointerCursorNormal); + } else if (!cursorSpriteVisible && S60->mouseInteractionEnabled) { +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_hide_pointer_sprite(); + else +#endif + S60->wsSession().SetPointerCursorMode(EPointerCursorNone); + } + S60->mouseInteractionEnabled = ((cursorSpriteVisible > 0) ? true : false); +} + +/* + * Check if the cursor is on or off + */ +bool qt_symbian_is_cursor_visible() { + return S60->mouseInteractionEnabled; +} + +QCursorData::QCursorData(Qt::CursorShape s) : + cshape(s), bm(0), bmm(0), hx(0), hy(0), pcurs() +{ + ref = 1; +} + +QCursorData::~QCursorData() +{ + for(int i=0;i<nativeSpriteMembers.Count();i++) { + delete nativeSpriteMembers[i]->iBitmap; + delete nativeSpriteMembers[i]->iMaskBitmap; + } + nativeSpriteMembers.ResetAndDestroy(); + pcurs.Close(); + delete bm; + delete bmm; +} + +/* Create a bitmap cursor, this is called by public constructors in the + * generic QCursor code. + */ +QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) +{ + if (!QCursorData::initialized) + QCursorData::initialize(); + if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) { + qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)"); + QCursorData *c = qt_cursorTable[0]; + c->ref.ref(); + return c; + } + QCursorData *d = new QCursorData; + d->bm = new QBitmap(bitmap); + d->bmm = new QBitmap(mask); + d->cshape = Qt::BitmapCursor; + d->hx = hotX >= 0 ? hotX : bitmap.width() / 2; + d->hy = hotY >= 0 ? hotY : bitmap.height() / 2; + return d; +} + +/* + * returns an opaque native handle to a cursor. + * It happens to be the address of the native handle, as window server handles + * are not POD types. Note there is no QCursor(HANDLE) constructor on Symbian, + * Mac or QWS. + */ +Qt::HANDLE QCursor::handle() const +{ + if (d->pcurs.WsHandle()) + return reinterpret_cast<Qt::HANDLE> (&(d->pcurs)); + +#ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS + // don't construct shape cursors, QApplication_s60 will use the system cursor instead + if (!(d->bm)) + return 0; +#endif + + d->pcurs = RWsPointerCursor(S60->wsSession()); + d->pcurs.Construct(0); + d->constructCursorSprite(d->pcurs); + d->pcurs.Activate(); + + return reinterpret_cast<Qt::HANDLE> (&(d->pcurs)); +} + +#ifndef Q_SYMBIAN_HAS_SYSTEM_CURSORS +/* + * Loads a single cursor shape from resources and appends it to a native sprite. + * Animated cursors (e.g. the busy cursor) have multiple members. + */ +void QCursorData::loadShapeFromResource(RWsSpriteBase& target, QString resource, int hx, int hy, int interval) +{ + QPixmap pix; + CFbsBitmap* native; + QScopedPointer<TSpriteMember> member(new TSpriteMember); + member->iInterval = interval; + member->iInvertMask = false; + member->iMaskBitmap = 0; // all shapes are RGBA + member->iDrawMode = CGraphicsContext::EDrawModePEN; + member->iOffset = TPoint(-hx, -hy); + QString res(QLatin1String(":/trolltech/symbian/cursors/images/%1.png")); + pix.load(res.arg(resource)); + native = pix.toSymbianCFbsBitmap(); + member->iBitmap = native; + qt_symbian_throwIfError(nativeSpriteMembers.Append(member.data())); + target.AppendMember(*(member.take())); +} + +//TODO: after 4.6, connect with style & skins? +/* + * Constructs the native cursor from resources compiled into QtGui + * This is needed only when the platform doesn't have system cursors. + * + * System cursors are higher performance, since they are constructed once + * and shared by all applications by specifying the shape number. + * Due to symbian platform security considerations, and the fact most + * existing phones have a broken RWsPointerCursor, system cursors are not + * being used. + */ +void QCursorData::constructShapeSprite(RWsSpriteBase& target) +{ + int i; + switch (cshape) { + default: + qWarning("QCursorData::constructShapeSprite unknown shape %d", cshape); + //fall through and give arrow cursor + case Qt::ArrowCursor: + loadShapeFromResource(target, QLatin1String("pointer"), 1, 1); + break; + case Qt::UpArrowCursor: + loadShapeFromResource(target, QLatin1String("uparrow"), 4, 0); + break; + case Qt::CrossCursor: + loadShapeFromResource(target, QLatin1String("cross"), 7, 7); + break; + case Qt::WaitCursor: + for (i = 1; i <= 12; i++) { + loadShapeFromResource(target, QString(QLatin1String("wait%1")).arg(i), 7, 7, 1000000); + } + break; + case Qt::IBeamCursor: + loadShapeFromResource(target, QLatin1String("ibeam"), 3, 10); + break; + case Qt::SizeVerCursor: + loadShapeFromResource(target, QLatin1String("sizever"), 4, 8); + break; + case Qt::SizeHorCursor: + loadShapeFromResource(target, QLatin1String("sizehor"), 8, 4); + break; + case Qt::SizeBDiagCursor: + loadShapeFromResource(target, QLatin1String("sizebdiag"), 8, 8); + break; + case Qt::SizeFDiagCursor: + loadShapeFromResource(target, QLatin1String("sizefdiag"), 8, 8); + break; + case Qt::SizeAllCursor: + loadShapeFromResource(target, QLatin1String("sizeall"), 7, 7); + break; + case Qt::BlankCursor: + loadShapeFromResource(target, QLatin1String("blank"), 0, 0); + break; + case Qt::SplitVCursor: + loadShapeFromResource(target, QLatin1String("splitv"), 7, 7); + break; + case Qt::SplitHCursor: + loadShapeFromResource(target, QLatin1String("splith"), 7, 7); + break; + case Qt::PointingHandCursor: + loadShapeFromResource(target, QLatin1String("handpoint"), 5, 0); + break; + case Qt::ForbiddenCursor: + loadShapeFromResource(target, QLatin1String("forbidden"), 7, 7); + break; + case Qt::WhatsThisCursor: + loadShapeFromResource(target, QLatin1String("whatsthis"), 1, 1); + break; + case Qt::BusyCursor: + loadShapeFromResource(target, QLatin1String("busy3"), 1, 1, 1000000); + loadShapeFromResource(target, QLatin1String("busy6"), 1, 1, 1000000); + loadShapeFromResource(target, QLatin1String("busy9"), 1, 1, 1000000); + loadShapeFromResource(target, QLatin1String("busy12"), 1, 1, 1000000); + break; + case Qt::OpenHandCursor: + loadShapeFromResource(target, QLatin1String("openhand"), 7, 7); + break; + case Qt::ClosedHandCursor: + loadShapeFromResource(target, QLatin1String("closehand"), 7, 7); + break; + } +} +#endif + +/* + * Common code between the sprite workaround and standard modes of operation. + * RWsSpriteBase is the base class for both RWsSprite and RWsPointerCursor. + * It is called from both handle() and qt_s60_show_pointer_sprite() + */ +void QCursorData::constructCursorSprite(RWsSpriteBase& target) +{ + int count = nativeSpriteMembers.Count(); + if (count) { + // already constructed + for (int i = 0; i < count; i++) + target.AppendMember(*(nativeSpriteMembers[i])); + + return; + } + if (pixmap.isNull() && !bm) { +#ifndef Q_SYMBIAN_HAS_SYSTEM_CURSORS + //shape cursor + constructShapeSprite(target); +#endif + return; + } + QScopedPointer<TSpriteMember> member(new TSpriteMember); + if (pixmap.isNull()) { + //construct mono cursor + member->iBitmap = bm->toSymbianCFbsBitmap(); + member->iMaskBitmap = bmm->toSymbianCFbsBitmap(); + } + else { + //construct normal cursor + member->iBitmap = pixmap.toSymbianCFbsBitmap(); + if (pixmap.hasAlphaChannel()) { + member->iMaskBitmap = 0; //use alpha blending + } + else if (pixmap.hasAlpha()) { + member->iMaskBitmap = pixmap.mask().toSymbianCFbsBitmap(); + } + else { + member->iMaskBitmap = pixmap.createHeuristicMask().toSymbianCFbsBitmap(); + } + } + + member->iDrawMode = CGraphicsContext::EDrawModePEN; + member->iInvertMask = EFalse; + member->iInterval = 0; + member->iOffset = TPoint(-(hx), -(hy)); //Symbian hotspot coordinates are negative + qt_symbian_throwIfError(nativeSpriteMembers.Append(member.data())); + target.AppendMember(*(member.take())); +} + +/* + * shows the pointer sprite by constructing a native handle, and registering + * it with the window server. + * Only used when the sprite workaround is in use. + */ +void qt_symbian_show_pointer_sprite() +{ + if (cursorSprite.d) { + if (cursorSprite.d->scurs.WsHandle()) + cursorSprite.d->scurs.Close(); + } else { + cursorSprite = QCursor(Qt::ArrowCursor); + } + + cursorSprite.d->scurs = RWsSprite(S60->wsSession()); + QPoint pos = QCursor::pos(); + cursorSprite.d->scurs.Construct(S60->windowGroup(), TPoint(pos.x(), pos.y()), ESpriteNoChildClip | ESpriteNoShadows); + + cursorSprite.d->constructCursorSprite(cursorSprite.d->scurs); + cursorSprite.d->scurs.Activate(); +} + +/* + * hides the pointer sprite by closing the native handle. + * Only used when the sprite workaround is in use. + */ +void qt_symbian_hide_pointer_sprite() +{ + if (cursorSprite.d) { + cursorSprite.d->scurs.Close(); + } +} + +/* + * Changes the cursor sprite to the cursor specified. + * Only used when the sprite workaround is in use. + */ +void qt_symbian_set_pointer_sprite(const QCursor& cursor) +{ + if (S60->mouseInteractionEnabled) + qt_symbian_hide_pointer_sprite(); + cursorSprite = cursor; + if (S60->mouseInteractionEnabled) + qt_symbian_show_pointer_sprite(); +} + +/* + * When using sprites as a workaround on phones that have a broken + * RWsPointerCursor, this function is called in response to pointer events + * and when QCursor::setPos() is called. + * Performance is worse than a real pointer cursor, due to extra context + * switches vs. the window server moving the cursor by itself. + */ +void qt_symbian_move_cursor_sprite() +{ + if (S60->mouseInteractionEnabled) { + cursorSprite.d->scurs.SetPosition(TPoint(S60->lastCursorPos.x(), S60->lastCursorPos.y())); + } +} + +/* + * Translate from Qt::CursorShape to OS system pointer cursor list index. + * Currently we control the implementation of the system pointer cursor list, + * so this function is trivial. That may not always be the case. + */ +TInt qt_symbian_translate_cursor_shape(Qt::CursorShape shape) +{ + return (TInt) shape; +} + +/* + Internal function called from QWidget::setCursor() + force is true if this function is called from dispatchEnterLeave, it means that the + mouse is actually directly under this widget. +*/ +void qt_symbian_set_cursor(QWidget *w, bool force) +{ + static QPointer<QWidget> lastUnderMouse = 0; + if (force) { + lastUnderMouse = w; + } + else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse + && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { + w = lastUnderMouse; + } + + if (!S60->curWin && w && w->internalWinId()) + return; + QWidget* cW = w && !w->internalWinId() ? w : QWidget::find(S60->curWin); + if (!cW || cW->window() != w->window() || !cW->isVisible() || !cW->underMouse() + || QApplication::overrideCursor()) + return; + +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) + qt_symbian_set_pointer_sprite(cW->cursor()); + else +#endif + qt_symbian_setWindowCursor(cW->cursor(), w->effectiveWinId()); } +/* + * Makes the specified cursor appear above a specific native window group + * Called from QSymbianControl and QApplication::restoreOverrideCursor + * + * Window server is needed for this, so there is no equivalent when using + * the sprite workaround. + */ +void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node) +{ + Qt::HANDLE handle = cursor.handle(); + if (handle) { + RWsPointerCursor *pcurs = reinterpret_cast<RWsPointerCursor *> (handle); + node.SetCustomPointerCursor(*pcurs); + } +#ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS + else { + TInt shape = qt_symbian_translate_cursor_shape(cursor.shape()); + node.SetPointerCursor(shape); + } +#else + qWarning("qt_s60_setWindowGroupCursor - null handle"); +#endif +} + +/* + * Makes the specified cursor appear above a specific native window + * Called from QSymbianControl and QApplication::restoreOverrideCursor + * + * Window server is needed for this, so there is no equivalent when using + * the sprite workaround. + */ +void qt_symbian_setWindowCursor(const QCursor &cursor, const CCoeControl* wid) +{ + //find the window for this control + while (!wid->OwnsWindow()) { + wid = wid->Parent(); + if (!wid) + return; + } + RWindowTreeNode *node = wid->DrawableWindow(); + qt_symbian_setWindowGroupCursor(cursor, *node); +} + +/* + * Makes the specified cursor appear everywhere. + * Called from QApplication::setOverrideCursor + */ +void qt_symbian_setGlobalCursor(const QCursor &cursor) +{ +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + if (S60->brokenPointerCursors) { + qt_symbian_set_pointer_sprite(cursor); + } else +#endif + { + //because of the internals of window server, we need to force the cursor + //to be set in all child windows too, otherwise when the cursor is over + //the child window it may show a widget cursor or arrow cursor instead, + //depending on construction order. + QListIterator<WId> iter(QWidgetPrivate::mapper->uniqueKeys()); + while(iter.hasNext()) + { + CCoeControl *ctrl = iter.next(); + RWindowTreeNode *node = ctrl->DrawableWindow(); + qt_symbian_setWindowGroupCursor(cursor, *node); + } + } +} QT_END_NAMESPACE #endif // QT_NO_CURSOR diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp index 430f587..26cde1a 100644 --- a/src/gui/kernel/qcursor_win.cpp +++ b/src/gui/kernel/qcursor_win.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp - /***************************************************************************** Internal QCursorData class *****************************************************************************/ diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/gui/kernel/qcursor_x11.cpp index d8cc2fc..3e53f04 100644 --- a/src/gui/kernel/qcursor_x11.cpp +++ b/src/gui/kernel/qcursor_x11.cpp @@ -63,8 +63,6 @@ QT_BEGIN_NAMESPACE // Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to // use the ugly X11 cursors. -extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp - /***************************************************************************** Internal QCursorData class *****************************************************************************/ @@ -100,6 +98,7 @@ QCursor::QCursor(Qt::HANDLE cursor) d = new QCursorData(Qt::CustomCursor); d->hcurs = cursor; } + #endif QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 4ee484c..b635685 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -58,6 +58,7 @@ #include "QtGui/qmime.h" #include "QtGui/qdrag.h" #include "QtGui/qpixmap.h" +#include "QtGui/qcursor.h" #include "QtCore/qpoint.h" #include "private/qobject_p.h" #ifdef Q_WS_MAC @@ -265,7 +266,11 @@ private: #ifdef Q_WS_QWS Qt::DropAction currentActionForOverrideCursor; #endif - +#ifdef Q_OS_SYMBIAN +#ifndef QT_NO_CURSOR + QCursor overrideCursor; +#endif +#endif QWidget *currentDropTarget; static QDragManager *instance; diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp index fb2e426..2456185 100644 --- a/src/gui/kernel/qdnd_s60.cpp +++ b/src/gui/kernel/qdnd_s60.cpp @@ -50,11 +50,14 @@ #include "qevent.h" #include "qpainter.h" #include "qdnd_p.h" +#include "qt_s60_p.h" #include <COECNTRL.H> // pointer cursor #include <w32std.h> #include <gdi.h> +#include <QCursor> + QT_BEGIN_NAMESPACE //### artistic impression of Symbians default DnD cursor ? @@ -89,82 +92,24 @@ static bool qt_symbian_dnd_dragging = false; static Qt::KeyboardModifiers oldstate; -class QShapedPixmapWidget -{ -public: - QShapedPixmapWidget(RWsSession aWsSession,RWindowTreeNode* aNode) - { - sprite = RWsSprite(aWsSession); - cursorSprite.iBitmap = 0; - cursorSprite.iMaskBitmap = 0; - cursorSprite.iInvertMask = EFalse; - cursorSprite.iOffset = TPoint(0,0); - cursorSprite.iInterval = TTimeIntervalMicroSeconds32(0); - cursorSprite.iDrawMode = CGraphicsContext::EDrawModePEN; - sprite.Construct(*aNode,TPoint(0,0), ESpriteNoShadows | ESpriteNoChildClip); - sprite.AppendMember(cursorSprite); - sprite.Activate(); - } - ~QShapedPixmapWidget() - { - sprite.Close(); - cursorSprite.iBitmap = 0; - delete cursorBitmap; - cursorBitmap = 0; //redundant... - } - void disableCursor() - { - cursorSprite.iBitmap = 0; - sprite.UpdateMember(0,cursorSprite); - } - void enableCursor() - { - cursorSprite.iBitmap = cursorBitmap; - sprite.UpdateMember(0,cursorSprite); - } - void setPixmap(QPixmap pm) - { - //### heaplock centralized. - QImage temp = pm.toImage(); - QSize size = pm.size(); - temp.bits(); - CFbsBitmap *curbm = q_check_ptr(new CFbsBitmap()); // CBase derived object needs check on new - curbm->Create(TSize(size.width(),size.height()),EColor16MA); - curbm->LockHeap(ETrue); - memcpy((uchar*)curbm->DataAddress(),temp.bits(),temp.numBytes()); - curbm->UnlockHeap(ETrue); - delete cursorSprite.iBitmap; - cursorSprite.iBitmap = curbm; - cursorBitmap = curbm; - sprite.UpdateMember(0,cursorSprite); - } - CFbsBitmap *cursorBitmap; - RWsPointerCursor pointerCursor; - RWsSprite sprite; - TSpriteMember cursorSprite; - -}; - - -static QShapedPixmapWidget *qt_symbian_dnd_deco = 0; - void QDragManager::updatePixmap() { - if (qt_symbian_dnd_deco) { - QPixmap pm; - QPoint pm_hot(default_pm_hotx,default_pm_hoty); - if (drag_object) { - pm = drag_object->pixmap(); - if (!pm.isNull()) - pm_hot = drag_object->hotSpot(); - } - if (pm.isNull()) { - if (!defaultPm) - defaultPm = new QPixmap(default_pm); - pm = *defaultPm; - } - qt_symbian_dnd_deco->setPixmap(pm); + QPixmap pm; + QPoint pm_hot(default_pm_hotx,default_pm_hoty); + if (drag_object) { + pm = drag_object->pixmap(); + if (!pm.isNull()) + pm_hot = drag_object->hotSpot(); + } + if (pm.isNull()) { + if (!defaultPm) + defaultPm = new QPixmap(default_pm); + pm = *defaultPm; } +#ifndef QT_NO_CURSOR + QCursor cursor(pm, pm_hot.x(), pm_hot.y()); + overrideCursor = cursor; +#endif } void QDragManager::timerEvent(QTimerEvent *) { } @@ -174,6 +119,16 @@ void QDragManager::move(const QPoint&) { void QDragManager::updateCursor() { +#ifndef QT_NO_CURSOR + QCursor cursor = willDrop ? overrideCursor : Qt::ForbiddenCursor; + if (!restoreCursor) { + QApplication::setOverrideCursor(cursor); + restoreCursor = true; + } + else { + QApplication::changeOverrideCursor(cursor); + } +#endif } @@ -210,20 +165,19 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) // map the Coords relative to the window. if (!cw) return true; - TPoint windowPos = cw->effectiveWinId()->PositionRelativeToScreen(); - qt_symbian_dnd_deco->sprite.SetPosition(TPoint(me->globalX()- windowPos.iX,me->globalY()- windowPos.iY)); while (cw && !cw->acceptDrops() && !cw->isWindow()) cw = cw->parentWidget(); + bool oldWillDrop = willDrop; if (object->target() != cw) { if (object->target()) { QDragLeaveEvent dle; QApplication::sendEvent(object->target(), &dle); willDrop = false; global_accepted_action = Qt::IgnoreAction; - updateCursor(); - restoreCursor = true; + if (oldWillDrop != willDrop) + updateCursor(); object->d_func()->target = 0; } if (cw && cw->acceptDrops()) { @@ -233,8 +187,8 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) QApplication::sendEvent(object->target(), &dee); willDrop = dee.isAccepted() && dee.dropAction() != Qt::IgnoreAction; global_accepted_action = willDrop ? dee.dropAction() : Qt::IgnoreAction; - updateCursor(); - restoreCursor = true; + if (oldWillDrop != willDrop) + updateCursor(); } } else if (cw) { QDragMoveEvent dme(cw->mapFromGlobal(me->globalPos()), possible_actions, dropData, @@ -246,8 +200,10 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) QApplication::sendEvent(cw, &dme); willDrop = dme.isAccepted(); global_accepted_action = willDrop ? dme.dropAction() : Qt::IgnoreAction; - updatePixmap(); - updateCursor(); + if (oldWillDrop != willDrop) { + updatePixmap(); + updateCursor(); + } } if (global_accepted_action != prevAction) emitActionChanged(global_accepted_action); @@ -259,7 +215,7 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) { qApp->removeEventFilter(this); if (restoreCursor) { - qt_symbian_dnd_deco->disableCursor(); + QApplication::restoreOverrideCursor(); willDrop = false; restoreCursor = false; } @@ -305,23 +261,15 @@ Qt::DropAction QDragManager::drag(QDrag *o) } object = drag_object = o; - RWsSession winSession = o->source()->effectiveWinId()->ControlEnv()->WsSession(); - Q_ASSERT(!qt_symbian_dnd_deco); - qt_symbian_dnd_deco = new QShapedPixmapWidget(winSession, o->source()->effectiveWinId()->DrawableWindow()); oldstate = Qt::NoModifier; // #### Should use state that caused the drag willDrop = false; updatePixmap(); updateCursor(); - restoreCursor = true; - object->d_func()->target = 0; - TPoint windowPos = source()->effectiveWinId()->PositionRelativeToScreen(); - qt_symbian_dnd_deco->sprite.SetPosition(TPoint(QCursor::pos().x()- windowPos.iX ,QCursor::pos().y() - windowPos.iY)); + qt_symbian_set_cursor_visible(true); //force cursor on even for touch phone - QPoint hotspot = drag_object->hotSpot(); - qt_symbian_dnd_deco->cursorSprite.iOffset = TPoint(- hotspot.x(),- hotspot.y()); - qt_symbian_dnd_deco->sprite.UpdateMember(0,qt_symbian_dnd_deco->cursorSprite); + object->d_func()->target = 0; qApp->installEventFilter(this); @@ -334,11 +282,11 @@ Qt::DropAction QDragManager::drag(QDrag *o) delete eventLoop; eventLoop = 0; - delete qt_symbian_dnd_deco; - qt_symbian_dnd_deco = 0; + qt_symbian_set_cursor_visible(false); + + overrideCursor = QCursor(); //deref the cursor data qt_symbian_dnd_dragging = false; - return global_accepted_action; } @@ -358,8 +306,10 @@ void QDragManager::cancel(bool deleteSource) drag_object = object = 0; } - delete qt_symbian_dnd_deco; - qt_symbian_dnd_deco = 0; + if (restoreCursor) { + QApplication::restoreOverrideCursor(); + restoreCursor = false; + } global_accepted_action = Qt::IgnoreAction; } @@ -367,6 +317,10 @@ void QDragManager::cancel(bool deleteSource) void QDragManager::drop() { + if (restoreCursor) { + QApplication::restoreOverrideCursor(); + restoreCursor = false; + } } QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type type) const diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index d85023b..794d15a 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -83,6 +83,7 @@ const TInt KInternalStatusPaneChange = 0x50000000; class QS60Data { public: + QS60Data(); TUid uid; int screenDepth; QPoint lastCursorPos; @@ -95,6 +96,16 @@ public: int screenHeightInTwips; int defaultDpiX; int defaultDpiY; + WId curWin; + int virtualMouseLastKey; + int virtualMouseAccel; + int virtualMouseMaxAccel; +#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS + bool brokenPointerCursors; +#endif + bool hasTouchscreen; + bool mouseInteractionEnabled; + bool virtualMouseRequired; int qtOwnsS60Environment : 1; static inline void updateScreenSize(); static inline RWsSession& wsSession(); @@ -164,6 +175,11 @@ private: bool m_previousEventLongTap; }; +inline QS60Data::QS60Data() +{ + memclr(this, sizeof(QS60Data)); //zero init data +} + inline void QS60Data::updateScreenSize() { TPixelsTwipsAndRotation params; @@ -173,6 +189,8 @@ inline void QS60Data::updateScreenSize() S60->screenHeightInPixels = params.iPixelSize.iHeight; S60->screenWidthInTwips = params.iTwipsSize.iWidth; S60->screenHeightInTwips = params.iTwipsSize.iHeight; + + S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20; TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch; S60->defaultDpiY = S60->screenHeightInPixels / inches; @@ -286,6 +304,11 @@ static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode) return format; } +void qt_symbian_setWindowCursor(const QCursor &cursor, const CCoeControl* wid); +void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node); +void qt_symbian_setGlobalCursor(const QCursor &cursor); +void qt_symbian_set_cursor_visible(bool visible); +bool qt_symbian_is_cursor_visible(); QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fd89cb9..c86012d 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3048,7 +3048,6 @@ void QWidgetPrivate::setEnabled_helper(bool enable) if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) { // enforce the windows behavior of clearing the cursor on // disabled widgets - extern void qt_x11_enforce_cursor(QWidget * w); // defined in qwidget_x11.cpp qt_x11_enforce_cursor(q); } #endif diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 744d20f..522ce33 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -188,7 +188,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isResize) data.window_state &= ~Qt::WindowMaximized; - if(q->isWindow()) { + if (q->isWindow()) { if (w == 0 || h == 0) { q->setAttribute(Qt::WA_OutsideWSRange, true); if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) @@ -287,7 +287,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de TSize screenSize = S60->screenDevice()->SizeInPixels(); data.crect.setRect(0, 0, screenSize.iWidth, screenSize.iHeight); q->setAttribute(Qt::WA_DontShowOnScreen); - } else if(topLevel && !q->testAttribute(Qt::WA_Resized)){ + } else if (topLevel && !q->testAttribute(Qt::WA_Resized)){ int width = sw; int height = sh; if (extra) { @@ -300,7 +300,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de CCoeControl *destroyw = 0; createExtra(); - if(window) { + if (window) { if (destroyOldWindow) destroyw = data.winid; id = window; @@ -416,7 +416,7 @@ void QWidgetPrivate::hide_sys() deactivateWidgetCleanup(); WId id = q->internalWinId(); if (q->isWindow() && id) { - if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() + if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); if (QWidgetBackingStore *bs = maybeBackingStore()) @@ -432,7 +432,7 @@ void QWidgetPrivate::setFocus_sys() { Q_Q(QWidget); if (q->testAttribute(Qt::WA_WState_Created) && q->window()->windowType() != Qt::Popup) - if(!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged() + if (!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged() q->effectiveWinId()->SetFocus(true); } @@ -482,7 +482,7 @@ void QWidgetPrivate::lower_sys() if (q->internalWinId() && tlwExtra) { tlwExtra->rwindow->SetOrdinalPosition(-1); } - if(!q->isWindow()) + if (!q->isWindow()) invalidateBuffer(q->rect()); } @@ -499,7 +499,7 @@ void QWidgetPrivate::stackUnder_sys(QWidget* w) QTLWExtra *tlwExtraSibling = w->d_func()->maybeTopData(); if (q->internalWinId() && tlwExtra && w->internalWinId() && tlwExtraSibling) tlwExtra->rwindow->SetOrdinalPosition(tlwExtraSibling->rwindow->OrdinalPosition() + 1); - if(!q->isWindow() || !w->internalWinId()) + if (!q->isWindow() || !w->internalWinId()) invalidateBuffer(q->rect()); } @@ -553,7 +553,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) // destroyed when emitting the child remove event below. See QWorkspace. if (wasCreated && old_winid) { old_winid->MakeVisible(false); - if(old_winid->IsFocused()) // Avoid unnecessary calls to FocusChanged() + if (old_winid->IsFocused()) // Avoid unnecessary calls to FocusChanged() old_winid->SetFocus(false); old_winid->SetParent(0); } @@ -660,7 +660,7 @@ CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert) fbsBitmap->LockHeap(); QImage image = pixmap.toImage(); - if(invert) + if (invert) image.invertPixels(); int height = pixmap.size().height(); @@ -764,8 +764,8 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption) if (q->isWindow()) { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); CAknTitlePane* titlePane = S60->titlePane(); - if(titlePane) { - if(caption.isEmpty()) { + if (titlePane) { + if (caption.isEmpty()) { QT_TRAP_THROWING(titlePane->SetTextToDefaultL()); } else { QT_TRAP_THROWING(titlePane->SetTextL(qt_QString2TPtrC(caption))); @@ -996,7 +996,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) // The window decoration visibility has to be changed before doing actual // window state change since in that order the availableGeometry will return // directly the right size and we will avoid unnecessarty redraws - if((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen) || + if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen) || oldstate == Qt::WindowNoState) { CEikStatusPane* statusPane = S60->statusPane(); CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); @@ -1061,7 +1061,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) if (newstate & Qt::WindowMinimized) { if (isVisible()) { WId id = effectiveWinId(); - if(id->IsFocused()) // Avoid unnecessary calls to FocusChanged() + if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(false); id->MakeVisible(false); } @@ -1069,7 +1069,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) if (isVisible()) { WId id = effectiveWinId(); id->MakeVisible(true); - if(!id->IsFocused()) // Avoid unnecessary calls to FocusChanged() + if (!id->IsFocused()) // Avoid unnecessary calls to FocusChanged() id->SetFocus(true); } const QRect normalGeometry = geometry(); @@ -1111,6 +1111,10 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) } #endif + if (QWidgetPrivate::mouseGrabber == this) + releaseMouse(); + if (QWidgetPrivate::keyboardGrabber == this) + releaseKeyboard(); setAttribute(Qt::WA_WState_Created, false); QObjectList childList = children(); for (int i = 0; i < childList.size(); ++i) { // destroy all widget children @@ -1119,12 +1123,8 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) static_cast<QWidget*>(obj)->destroy(destroySubWindows, destroySubWindows); } - if (QWidgetPrivate::mouseGrabber == this) - releaseMouse(); - if (QWidgetPrivate::keyboardGrabber == this) - releaseKeyboard(); if (destroyWindow && !(windowType() == Qt::Desktop) && id) { - if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged() + if (id->IsFocused()) // Avoid unnecessry calls to FocusChanged() id->SetFocus(false); id->ControlEnv()->AppUi()->RemoveFromStack(id); @@ -1192,8 +1192,28 @@ void QWidget::grabMouse() WId id = effectiveWinId(); id->SetPointerCapture(true); QWidgetPrivate::mouseGrabber = this; + +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(cursor()); +#endif + } +} + +#ifndef QT_NO_CURSOR +void QWidget::grabMouse(const QCursor &cursor) +{ + if (!qt_nograb()) { + if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this) + QWidgetPrivate::mouseGrabber->releaseMouse(); + Q_ASSERT(testAttribute(Qt::WA_WState_Created)); + WId id = effectiveWinId(); + id->SetPointerCapture(true); + QWidgetPrivate::mouseGrabber = this; + + QApplication::setOverrideCursor(cursor); } } +#endif void QWidget::releaseMouse() { @@ -1202,6 +1222,8 @@ void QWidget::releaseMouse() WId id = effectiveWinId(); id->SetPointerCapture(false); QWidgetPrivate::mouseGrabber = 0; + + QApplication::restoreOverrideCursor(); } } @@ -1215,4 +1237,21 @@ void QWidget::activateWindow() id->SetFocus(true); } } + +#ifndef QT_NO_CURSOR + +void QWidgetPrivate::setCursor_sys(const QCursor &cursor) +{ + Q_UNUSED(cursor); + Q_Q(QWidget); + qt_symbian_set_cursor(q, false); +} + +void QWidgetPrivate::unsetCursor_sys() +{ + Q_Q(QWidget); + qt_symbian_set_cursor(q, false); +} +#endif + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index c9ebccf..211e9d4 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -722,8 +722,6 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const void QWidgetPrivate::updateSystemBackground() {} -extern void qt_win_set_cursor(QWidget *, bool); // qapplication_win.cpp - #ifndef QT_NO_CURSOR void QWidgetPrivate::setCursor_sys(const QCursor &cursor) { diff --git a/src/gui/kernel/symbian.pri b/src/gui/kernel/symbian.pri index d267a53..5497ccb 100644 --- a/src/gui/kernel/symbian.pri +++ b/src/gui/kernel/symbian.pri @@ -1,3 +1,4 @@ symbian { contains(QT_CONFIG, s60): LIBS+= $$QMAKE_LIBS_S60 + RESOURCES += symbian/symbianresources.qrc } diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 7be8e04..c4a9373 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -49,10 +49,17 @@ QT_BEGIN_NAMESPACE /*! + \headerfile <qdrawutil.h> + \title Drawing Utility Functions + + \sa QPainter +*/ + +/*! \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth) - \relates QPainter + \relates <qdrawutil.h> Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2) shaded line using the given \a painter. Note that nothing is @@ -166,7 +173,7 @@ void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> Draws the shaded rectangle beginning at (\a x, \a y) with the given \a width and \a height using the provided \a painter. @@ -270,7 +277,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, int lineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> Draws the shaded panel beginning at (\a x, \a y) with the given \a width and \a height using the provided \a painter and the given \a @@ -406,7 +413,7 @@ static void qDrawWinShades(QPainter *p, \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> Draws the Windows-style button specified by the given point (\a x, \a y}, \a width and \a height using the provided \a painter with a @@ -444,7 +451,7 @@ void qDrawWinButton(QPainter *p, int x, int y, int w, int h, \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> Draws the Windows-style panel specified by the given point(\a x, \a y), \a width and \a height using the provided \a painter with a @@ -483,7 +490,7 @@ void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, /*! \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor, int lineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> Draws the plain rectangle beginning at (\a x, \a y) with the given \a width and \a height, using the specified \a painter, \a lineColor @@ -532,7 +539,7 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, /*! \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth) - \relates QPainter + \relates <qdrawutil.h> \overload Draws a horizontal or vertical shaded line between \a p1 and \a p2 @@ -572,7 +579,7 @@ void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2, /*! \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> \overload Draws the shaded rectangle specified by \a rect using the given \a painter. @@ -612,7 +619,7 @@ void qDrawShadeRect(QPainter *p, const QRect &r, /*! \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, int lineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> \overload Draws the shaded panel at the rectangle specified by \a rect using the @@ -648,7 +655,7 @@ void qDrawShadePanel(QPainter *p, const QRect &r, /*! \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> \overload Draws the Windows-style button at the rectangle specified by \a rect using @@ -706,7 +713,7 @@ void qDrawWinPanel(QPainter *p, const QRect &r, /*! \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill) - \relates QPainter + \relates <qdrawutil.h> \overload Draws the plain rectangle specified by \a rect using the given \a painter, @@ -1044,7 +1051,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, Holds the rules used to draw a pixmap or image split into nine segments, similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}. - \sa Qt::TileRule, QMargins, qDrawBorderPixmap + \sa Qt::TileRule, QMargins */ /*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) @@ -1060,7 +1067,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, /*! \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap) \since 4.6 - \relates QPainter + \relates <qdrawutil.h> Draws the given \a pixmap into the given \a target rectangle, using the given \a painter. The pixmap will be split into nine segments and drawn @@ -1156,8 +1163,6 @@ static inline void qDrawHorizontallyRoundedPixmap(QPainter *painter, const QRect /*! \since 4.6 - \relates QPainter - Draws the indicated \a sourceRect rectangle from the given \a pixmap into the given \a targetRect rectangle, using the given \a painter. The pixmap will be split into nine segments according to the given \a targetMargins diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 9f0d84a..a12a71f 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -207,7 +207,12 @@ public: virtual void beginNativePainting() {} virtual void endNativePainting() {} - virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; } + // Return a pixmap filter of "type" that can render the parameters + // in "prototype". The returned filter is owned by the engine and + // will be destroyed when the engine is destroyed. The "prototype" + // allows the engine to pick different filters based on the parameters + // that will be requested, and not just the "type". + virtual QPixmapFilter *pixmapFilter(int /*type*/, const QPixmapFilter * /*prototype*/) { return 0; } // These flags are needed in the implementation of paint buffers. enum Flags diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index beda9d6..b3aef71 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1317,7 +1317,8 @@ void QPainterPrivate::updateState(QPainterState *newState) Another workaround is to convert the paths to polygons first and then draw the polygons instead. - \sa QPaintDevice, QPaintEngine, {QtSvg Module}, {Basic Drawing Example} + \sa QPaintDevice, QPaintEngine, {QtSvg Module}, {Basic Drawing Example}, + {Drawing Utility Functions} */ /*! diff --git a/src/gui/symbian/images/blank.png b/src/gui/symbian/images/blank.png Binary files differnew file mode 100644 index 0000000..bd396de --- /dev/null +++ b/src/gui/symbian/images/blank.png diff --git a/src/gui/symbian/images/busy12.png b/src/gui/symbian/images/busy12.png Binary files differnew file mode 100644 index 0000000..909e70f --- /dev/null +++ b/src/gui/symbian/images/busy12.png diff --git a/src/gui/symbian/images/busy3.png b/src/gui/symbian/images/busy3.png Binary files differnew file mode 100644 index 0000000..983f5d8 --- /dev/null +++ b/src/gui/symbian/images/busy3.png diff --git a/src/gui/symbian/images/busy6.png b/src/gui/symbian/images/busy6.png Binary files differnew file mode 100644 index 0000000..b2e8780 --- /dev/null +++ b/src/gui/symbian/images/busy6.png diff --git a/src/gui/symbian/images/busy9.png b/src/gui/symbian/images/busy9.png Binary files differnew file mode 100644 index 0000000..e093d01 --- /dev/null +++ b/src/gui/symbian/images/busy9.png diff --git a/src/gui/symbian/images/closehand.png b/src/gui/symbian/images/closehand.png Binary files differnew file mode 100644 index 0000000..05534f5 --- /dev/null +++ b/src/gui/symbian/images/closehand.png diff --git a/src/gui/symbian/images/cross.png b/src/gui/symbian/images/cross.png Binary files differnew file mode 100644 index 0000000..50da7aa --- /dev/null +++ b/src/gui/symbian/images/cross.png diff --git a/src/gui/symbian/images/forbidden.png b/src/gui/symbian/images/forbidden.png Binary files differnew file mode 100644 index 0000000..a3a0fd6 --- /dev/null +++ b/src/gui/symbian/images/forbidden.png diff --git a/src/gui/symbian/images/handpoint.png b/src/gui/symbian/images/handpoint.png Binary files differnew file mode 100644 index 0000000..a221548 --- /dev/null +++ b/src/gui/symbian/images/handpoint.png diff --git a/src/gui/symbian/images/ibeam.png b/src/gui/symbian/images/ibeam.png Binary files differnew file mode 100644 index 0000000..ace2fad --- /dev/null +++ b/src/gui/symbian/images/ibeam.png diff --git a/src/gui/symbian/images/openhand.png b/src/gui/symbian/images/openhand.png Binary files differnew file mode 100644 index 0000000..6f232f0 --- /dev/null +++ b/src/gui/symbian/images/openhand.png diff --git a/src/gui/symbian/images/pointer.png b/src/gui/symbian/images/pointer.png Binary files differnew file mode 100644 index 0000000..677404e --- /dev/null +++ b/src/gui/symbian/images/pointer.png diff --git a/src/gui/symbian/images/sizeall.png b/src/gui/symbian/images/sizeall.png Binary files differnew file mode 100644 index 0000000..2950067 --- /dev/null +++ b/src/gui/symbian/images/sizeall.png diff --git a/src/gui/symbian/images/sizebdiag.png b/src/gui/symbian/images/sizebdiag.png Binary files differnew file mode 100644 index 0000000..f565a3a --- /dev/null +++ b/src/gui/symbian/images/sizebdiag.png diff --git a/src/gui/symbian/images/sizefdiag.png b/src/gui/symbian/images/sizefdiag.png Binary files differnew file mode 100644 index 0000000..9493f12 --- /dev/null +++ b/src/gui/symbian/images/sizefdiag.png diff --git a/src/gui/symbian/images/sizehor.png b/src/gui/symbian/images/sizehor.png Binary files differnew file mode 100644 index 0000000..217bf39 --- /dev/null +++ b/src/gui/symbian/images/sizehor.png diff --git a/src/gui/symbian/images/sizever.png b/src/gui/symbian/images/sizever.png Binary files differnew file mode 100644 index 0000000..2c99038 --- /dev/null +++ b/src/gui/symbian/images/sizever.png diff --git a/src/gui/symbian/images/splith.png b/src/gui/symbian/images/splith.png Binary files differnew file mode 100644 index 0000000..343bed5 --- /dev/null +++ b/src/gui/symbian/images/splith.png diff --git a/src/gui/symbian/images/splitv.png b/src/gui/symbian/images/splitv.png Binary files differnew file mode 100644 index 0000000..69ee416 --- /dev/null +++ b/src/gui/symbian/images/splitv.png diff --git a/src/gui/symbian/images/uparrow.png b/src/gui/symbian/images/uparrow.png Binary files differnew file mode 100644 index 0000000..92dd933 --- /dev/null +++ b/src/gui/symbian/images/uparrow.png diff --git a/src/gui/symbian/images/wait1.png b/src/gui/symbian/images/wait1.png Binary files differnew file mode 100644 index 0000000..5aebaab --- /dev/null +++ b/src/gui/symbian/images/wait1.png diff --git a/src/gui/symbian/images/wait10.png b/src/gui/symbian/images/wait10.png Binary files differnew file mode 100644 index 0000000..3b549b0 --- /dev/null +++ b/src/gui/symbian/images/wait10.png diff --git a/src/gui/symbian/images/wait11.png b/src/gui/symbian/images/wait11.png Binary files differnew file mode 100644 index 0000000..24a943f --- /dev/null +++ b/src/gui/symbian/images/wait11.png diff --git a/src/gui/symbian/images/wait12.png b/src/gui/symbian/images/wait12.png Binary files differnew file mode 100644 index 0000000..15afd4d --- /dev/null +++ b/src/gui/symbian/images/wait12.png diff --git a/src/gui/symbian/images/wait2.png b/src/gui/symbian/images/wait2.png Binary files differnew file mode 100644 index 0000000..f2022b2 --- /dev/null +++ b/src/gui/symbian/images/wait2.png diff --git a/src/gui/symbian/images/wait3.png b/src/gui/symbian/images/wait3.png Binary files differnew file mode 100644 index 0000000..5b73e57 --- /dev/null +++ b/src/gui/symbian/images/wait3.png diff --git a/src/gui/symbian/images/wait4.png b/src/gui/symbian/images/wait4.png Binary files differnew file mode 100644 index 0000000..17a0339 --- /dev/null +++ b/src/gui/symbian/images/wait4.png diff --git a/src/gui/symbian/images/wait5.png b/src/gui/symbian/images/wait5.png Binary files differnew file mode 100644 index 0000000..16a5c23 --- /dev/null +++ b/src/gui/symbian/images/wait5.png diff --git a/src/gui/symbian/images/wait6.png b/src/gui/symbian/images/wait6.png Binary files differnew file mode 100644 index 0000000..2870093 --- /dev/null +++ b/src/gui/symbian/images/wait6.png diff --git a/src/gui/symbian/images/wait7.png b/src/gui/symbian/images/wait7.png Binary files differnew file mode 100644 index 0000000..54f75a1 --- /dev/null +++ b/src/gui/symbian/images/wait7.png diff --git a/src/gui/symbian/images/wait8.png b/src/gui/symbian/images/wait8.png Binary files differnew file mode 100644 index 0000000..1d370c7 --- /dev/null +++ b/src/gui/symbian/images/wait8.png diff --git a/src/gui/symbian/images/wait9.png b/src/gui/symbian/images/wait9.png Binary files differnew file mode 100644 index 0000000..c28096f --- /dev/null +++ b/src/gui/symbian/images/wait9.png diff --git a/src/gui/symbian/images/whatsthis.png b/src/gui/symbian/images/whatsthis.png Binary files differnew file mode 100644 index 0000000..3386ef0 --- /dev/null +++ b/src/gui/symbian/images/whatsthis.png diff --git a/src/gui/symbian/symbianresources.qrc b/src/gui/symbian/symbianresources.qrc new file mode 100644 index 0000000..0a4fc36 --- /dev/null +++ b/src/gui/symbian/symbianresources.qrc @@ -0,0 +1,37 @@ +<RCC> + <qresource prefix="/trolltech/symbian/cursors" > + <file>images/blank.png</file> + <file>images/busy3.png</file> + <file>images/busy6.png</file> + <file>images/busy9.png</file> + <file>images/busy12.png</file> + <file>images/closehand.png</file> + <file>images/cross.png</file> + <file>images/forbidden.png</file> + <file>images/handpoint.png</file> + <file>images/ibeam.png</file> + <file>images/openhand.png</file> + <file>images/pointer.png</file> + <file>images/sizeall.png</file> + <file>images/sizebdiag.png</file> + <file>images/sizefdiag.png</file> + <file>images/sizehor.png</file> + <file>images/sizever.png</file> + <file>images/splith.png</file> + <file>images/splitv.png</file> + <file>images/uparrow.png</file> + <file>images/wait1.png</file> + <file>images/wait2.png</file> + <file>images/wait3.png</file> + <file>images/wait4.png</file> + <file>images/wait5.png</file> + <file>images/wait6.png</file> + <file>images/wait7.png</file> + <file>images/wait8.png</file> + <file>images/wait9.png</file> + <file>images/wait10.png</file> + <file>images/wait11.png</file> + <file>images/wait12.png</file> + <file>images/whatsthis.png</file> + </qresource> +</RCC> diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 8ad0452..68898b6 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -220,6 +220,9 @@ public: QString cancelText() const; void setCancelText(const QString &text); + const QPalette &palette() const; + void setPalette(const QPalette &); + enum DrawFlags { DrawText = 0x01, DrawSelections = 0x02, @@ -741,6 +744,16 @@ inline void QLineControl::setCancelText(const QString &text) m_cancelText = text; } +inline const QPalette & QLineControl::palette() const +{ + return m_palette; +} + +inline void QLineControl::setPalette(const QPalette &p) +{ + m_palette = p; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 37e57cf..629e839 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1434,7 +1434,6 @@ void QLineEdit::mousePressEvent(QMouseEvent* e) #ifndef QT_NO_DRAGANDDROP if (!mark && d->dragEnabled && d->control->echoMode() == Normal && e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) { - d->control->moveCursor(cursor); d->dndPos = e->pos(); if (!d->dndTimer.isActive()) d->dndTimer.start(QApplication::startDragTime(), this); @@ -1851,8 +1850,12 @@ void QLineEdit::paintEvent(QPaintEvent *) #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled() || hasEditFocus()) #endif - if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())) + if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; + // Palette only used for selections/mask and may not be in sync + if(d->control->palette() != pal) + d->control->setPalette(pal); + } // Asian users see an IM selection text as cursor on candidate // selection phase of input method, so the ordinary cursor should be diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 70e7ef3..837d055 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1767,14 +1767,6 @@ QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() { } -QPixmapFilter *QGL2PaintEngineEx::createPixmapFilter(int type) const -{ - const QGLContext *ctx = QGLContext::currentContext(); - if (ctx) - return ctx->d_func()->createPixmapFilter(type); - return 0; -} - QT_END_NAMESPACE #include "qpaintengineex_opengl2.moc" diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 34f4eb8..a44be90 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -59,6 +59,7 @@ #include <private/qglengineshadermanager_p.h> #include <private/qgl2pexvertexarray_p.h> #include <private/qglpaintdevice_p.h> +#include <private/qglpixmapfilter_p.h> enum EngineMode { ImageDrawingMode, @@ -140,7 +141,7 @@ public: const QGLContext* context(); - QPixmapFilter *createPixmapFilter(int type) const; + QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype); void setRenderTextActive(bool); @@ -264,6 +265,10 @@ public: bool inRenderText; float textureInvertedY; + + QScopedPointer<QPixmapFilter> convolutionFilter; + QScopedPointer<QPixmapFilter> colorizeFilter; + QScopedPointer<QPixmapFilter> blurFilter; }; QT_END_NAMESPACE diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2b74e69..7269195 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -352,8 +352,6 @@ public: #endif static void setCurrentContext(QGLContext *context); - - QPixmapFilter *createPixmapFilter(int type) const; }; // ### make QGLContext a QObject in 5.0 and remove the proxy stuff diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 7876661..b48c497 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -71,13 +71,12 @@ void QGLPixmapFilterBase::drawImpl(QPainter *painter, const QPointF &pos, const class QGLPixmapColorizeFilter: public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapColorizeFilter> { public: + QGLPixmapColorizeFilter(); + void setUniforms(QGLShaderProgram *program); protected: bool processGL(QPainter *painter, const QPointF &pos, const QPixmap &pixmap, const QRectF &srcRect) const; - -private: - mutable QGLShader *m_shader; }; class QGLPixmapConvolutionFilter: public QGLPixmapFilter<QPixmapConvolutionFilter> @@ -103,6 +102,8 @@ private: class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapBlurFilter> { public: + QGLPixmapBlurFilter(); + void setUniforms(QGLShaderProgram *program); protected: @@ -111,32 +112,39 @@ protected: private: static QByteArray generateBlurShader(int radius, bool gaussianBlur); - mutable QGLShader *m_shader; - mutable QSize m_textureSize; mutable bool m_horizontalBlur; + + mutable bool m_haveCached; + mutable int m_cachedRadius; + mutable Qt::TransformationMode m_cachedQuality; }; extern QGLWidget *qt_gl_share_widget(); -QPixmapFilter *QGLContextPrivate::createPixmapFilter(int type) const +QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *prototype) { + Q_D(QGL2PaintEngineEx); switch (type) { case QPixmapFilter::ColorizeFilter: - return new QGLPixmapColorizeFilter; + if (!d->colorizeFilter) + d->colorizeFilter.reset(new QGLPixmapColorizeFilter); + return d->colorizeFilter.data(); case QPixmapFilter::BlurFilter: - return new QGLPixmapBlurFilter; + if (!d->blurFilter) + d->blurFilter.reset(new QGLPixmapBlurFilter); + return d->blurFilter.data(); case QPixmapFilter::ConvolutionFilter: - return new QGLPixmapConvolutionFilter; + if (!d->convolutionFilter) + d->convolutionFilter.reset(new QGLPixmapConvolutionFilter); + return d->convolutionFilter.data(); - default: - return 0; - break; + default: break; } - return 0; + return QPaintEngineEx::pixmapFilter(type, prototype); } extern void qt_add_rect_to_array(const QRectF &r, q_vertexType *array); @@ -187,10 +195,14 @@ static const char *qt_gl_colorize_filter = " return vec4(mix(srcPixel.rgb, colorized * srcPixel.a, colorizeStrength), srcPixel.a);" "}"; +QGLPixmapColorizeFilter::QGLPixmapColorizeFilter() +{ + setSource(qt_gl_colorize_filter); +} + bool QGLPixmapColorizeFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapColorizeFilter *filter = const_cast<QGLPixmapColorizeFilter *>(this); - filter->setSource(qt_gl_colorize_filter); filter->setOnPainter(painter); painter->drawPixmap(pos, src); @@ -297,10 +309,27 @@ bool QGLPixmapConvolutionFilter::processGL(QPainter *, const QPointF &pos, const return true; } +QGLPixmapBlurFilter::QGLPixmapBlurFilter() + : m_haveCached(false), m_cachedRadius(5), + m_cachedQuality(Qt::FastTransformation) +{ +} + bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapBlurFilter *filter = const_cast<QGLPixmapBlurFilter *>(this); - filter->setSource(generateBlurShader(radius(), quality() == Qt::SmoothTransformation)); + + int radius = this->radius(); + Qt::TransformationMode quality = this->quality(); + + if (!m_haveCached || radius != m_cachedRadius || + quality != m_cachedQuality) { + // Only regenerate the shader from source if parameters have changed. + m_haveCached = true; + m_cachedRadius = radius; + m_cachedQuality = quality; + filter->setSource(generateBlurShader(radius, quality == Qt::SmoothTransformation)); + } QGLFramebufferObjectFormat format; format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index d5398a9..3bc0d4f 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -98,7 +98,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize sz.setHeight(qMax(requestSize.height(), qRound(sz.height() * 1.5))); // wasting too much space? - if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 2.5) + if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 4) sz = requestSize; if (sz != fboSize) { @@ -162,12 +162,14 @@ void QGLPixmapGLPaintDevice::beginPaint() glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); - glMatrixMode(GL_MODELVIEW_MATRIX); +#if !defined(QT_OPENGL_ES_2) + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glMatrixMode(GL_PROJECTION_MATRIX); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, data->width(), data->height(), 0, -999999, 999999); +#endif glViewport(0, 0, data->width(), data->height()); @@ -183,12 +185,11 @@ void QGLPixmapGLPaintDevice::endPaint() data->copyBackFromRenderFbo(false); - data->m_renderFbo->release(); - qgl_fbo_pool()->release(data->m_renderFbo); - data->m_renderFbo = 0; - // Base's endPaint will restore the previous FBO binding QGLPaintDevice::endPaint(); + + qgl_fbo_pool()->release(data->m_renderFbo); + data->m_renderFbo = 0; } QGLContext* QGLPixmapGLPaintDevice::context() const @@ -466,8 +467,8 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const if (!ctx->d_ptr->fbo) glGenFramebuffers(1, &ctx->d_ptr->fbo); - glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture.id, 0); const int x0 = 0; @@ -475,7 +476,8 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const const int y0 = 0; const int y1 = h; - glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle()); + if (!m_renderFbo->isBound()) + glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle()); glDisable(GL_SCISSOR_TEST); diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 972f4a1..d87ac40 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -211,6 +211,11 @@ public: QVGFontEngineCleaner *fontEngineCleaner; #endif + QScopedPointer<QPixmapFilter> convolutionFilter; + QScopedPointer<QPixmapFilter> colorizeFilter; + QScopedPointer<QPixmapFilter> dropShadowFilter; + QScopedPointer<QPixmapFilter> blurFilter; + // Ensure that the path transform is properly set in the VG context // before we perform a vgDrawPath() operation. inline void ensurePathTransform() @@ -3110,20 +3115,31 @@ void QVGPaintEngine::endNativePainting() vgSetPaint(d->brushPaint, VG_FILL_PATH); } -QPixmapFilter *QVGPaintEngine::createPixmapFilter(int type) const +QPixmapFilter *QVGPaintEngine::pixmapFilter(int type, const QPixmapFilter *prototype) { #if !defined(QT_SHIVAVG) - if (type == QPixmapFilter::ConvolutionFilter) - return new QVGPixmapConvolutionFilter; - else if (type == QPixmapFilter::ColorizeFilter) - return new QVGPixmapColorizeFilter; - else if (type == QPixmapFilter::DropShadowFilter) - return new QVGPixmapDropShadowFilter; - else if (type == QPixmapFilter::BlurFilter) - return new QVGPixmapBlurFilter; - else + Q_D(QVGPaintEngine); + switch (type) { + case QPixmapFilter::ConvolutionFilter: + if (!d->convolutionFilter) + d->convolutionFilter.reset(new QVGPixmapConvolutionFilter); + return d->convolutionFilter.data(); + case QPixmapFilter::ColorizeFilter: + if (!d->colorizeFilter) + d->colorizeFilter.reset(new QVGPixmapColorizeFilter); + return d->colorizeFilter.data(); + case QPixmapFilter::DropShadowFilter: + if (!d->dropShadowFilter) + d->dropShadowFilter.reset(new QVGPixmapDropShadowFilter); + return d->dropShadowFilter.data(); + case QPixmapFilter::BlurFilter: + if (!d->blurFilter) + d->blurFilter.reset(new QVGPixmapBlurFilter); + return d->blurFilter.data(); + default: break; + } #endif - return QPaintEngineEx::createPixmapFilter(type); + return QPaintEngineEx::pixmapFilter(type, prototype); } void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty) diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h index 4ae06bc..5c0f525 100644 --- a/src/openvg/qpaintengine_vg_p.h +++ b/src/openvg/qpaintengine_vg_p.h @@ -143,7 +143,7 @@ public: void beginNativePainting(); void endNativePainting(); - QPixmapFilter *createPixmapFilter(int type) const; + QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype); QVGPaintEnginePrivate *vgPrivate() { Q_D(QVGPaintEngine); return d; } diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 1365344..06759d4 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -139,6 +139,10 @@ QVGSharedContext::QVGSharedContext() QVGSharedContext::~QVGSharedContext() { + // Don't accidentally destroy the QEglContext if the reference + // count falls to zero while deleting the paint engine. + ++refCount; + if (context) qt_vg_make_current(context, qt_vg_shared_surface()); delete engine; diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index d397050..0706f01 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -11,5 +11,5 @@ SOURCES += qdirectfbscreenplugin.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB -DEFINES += $$QT_DEFINES_DIRECTFB +DEFINES += $$QT_DEFINES_DIRECTFB QT_DIRECTFB_PLUGIN contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4413858..0f7a6de 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1652,6 +1652,19 @@ void QDirectFBScreen::waitIdle() d_ptr->dfb->WaitIdle(d_ptr->dfb); } +#ifdef QT_DIRECTFB_WM +IDirectFBWindow *QDirectFBScreen::windowForWidget(const QWidget *widget) const +{ + if (widget) { + const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface()); + if (surface && surface->key() == QLatin1String("directfb")) { + return static_cast<const QDirectFBWindowSurface*>(surface)->directFBWindow(); + } + } + return 0; +} +#endif + IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const { Q_ASSERT(widget); @@ -1687,6 +1700,26 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co } #endif +#ifndef QT_DIRECTFB_PLUGIN +Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_widget(const QWidget *widget, QRect *rect) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->surfaceForWidget(widget, rect) : 0; +} +#ifdef QT_DIRECTFB_SUBSURFACE +Q_GUI_EXPORT IDirectFBSurface *qt_directfb_subsurface_for_widget(const QWidget *widget, const QRect &area) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->subSurfaceForWidget(widget, area) : 0; +} +#endif +#ifdef QT_DIRECTFB_WM +Q_GUI_EXPORT IDirectFBWindow *qt_directfb_window_for_widget(const QWidget *widget) +{ + return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->windowForWidget(widget) : 0; +} + +#endif +#endif + QT_END_NAMESPACE #include "qdirectfbscreen.moc" diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 79a01d3..febb2b2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -174,9 +174,10 @@ public: #ifdef QT_DIRECTFB_SUBSURFACE IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; #endif - IDirectFB *dfb(); -#ifdef QT_NO_DIRECTFB_WM +#ifdef QT_DIRECTFB_WM + IDirectFBWindow *windowForWidget(const QWidget *widget) const; +#else IDirectFBSurface *primarySurface(); #endif #ifndef QT_NO_DIRECTFB_LAYER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index ff9f7bd..4cebc96 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -113,13 +113,17 @@ bool QDirectFBWindowSurface::isValid() const #ifdef QT_DIRECTFB_WM void QDirectFBWindowSurface::raise() { - if (dfbWindow) { - dfbWindow->RaiseToTop(dfbWindow); - } else if (sibling && (!sibling->sibling || sibling->dfbWindow)) { - sibling->raise(); + if (IDirectFBWindow *window = directFBWindow()) { + window->RaiseToTop(window); } } +IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const +{ + return (dfbWindow ? dfbWindow : (sibling ? sibling->dfbWindow : 0)); +} + + void QDirectFBWindowSurface::createWindow(const QRect &rect) { IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); @@ -411,7 +415,8 @@ IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget *rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size()); } } - Q_ASSERT(win == widget || widget->isAncestorOf(win)); + + Q_ASSERT(win == widget || win->isAncestorOf(widget)); return dfbSurface; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index 036830a..0dd3a3b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -93,6 +93,9 @@ public: IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; IDirectFBSurface *directFBSurface() const; +#ifdef QT_DIRECTFB_WM + IDirectFBWindow *directFBWindow() const; +#endif private: void updateFormat(); void releaseSurface(); diff --git a/src/qbase.pri b/src/qbase.pri index 27e4992..4639ca1 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -101,7 +101,15 @@ symbian { "DEFFILE ../s60installs/eabi/$${TARGET}.def" \ "$${LITERAL_HASH}endif" + #with defBlock enabled, removed exported symbols are treated as errors + #and there is binary compatibility between successive builds. + #with defBlock disabled, binary compatibility is broken every time you build #MMP_RULES += defBlock + + #with EXPORTUNFROZEN enabled, new exports are included in the dll without + #needing to run abld freeze, however binary compatibility is only maintained + #for symbols that are frozen (and only if defBlock is also enabled) + #the downside of EXPORTUNFROZEN is that the linker gets run twice MMP_RULES += EXPORTUNFROZEN } load(armcc_warnings) diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 5171d3a..f2d865b 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -252,7 +252,7 @@ int main(int argc, char *argv[]) \ #include <QtTest/qtest_gui.h> #ifdef QT_KEYPAD_NAVIGATION -# define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setKeypadNavigationEnabled(false); +# define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setNavigationMode(Qt::NavigationModeNone); #else # define QTEST_DISABLE_KEYPAD_NAVIGATION #endif diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index b7b2327..74c3af9 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -311,7 +311,7 @@ QT_BEGIN_NAMESPACE Example: \snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 11 - \sa QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setKeypadNavigationEnabled() + \sa QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setNavigationMode() */ /*! \macro QTEST_APPLESS_MAIN(TestClass) |