diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 35 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 97 | ||||
-rw-r--r-- | src/gui/kernel/qdnd_x11.cpp | 21 | ||||
-rw-r--r-- | src/gui/kernel/qt_cocoa_helpers_mac_p.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 17 |
7 files changed, 157 insertions, 21 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 7b62de1..a2c058a 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -70,6 +70,10 @@ #include "qmessagebox.h" #include <QtGui/qgraphicsproxywidget.h> +#ifdef QT_GRAPHICSSYSTEM_RUNTIME +#include "private/qgraphicssystem_runtime_p.h" +#endif + #include "qinputcontext.h" #include "qkeymapper_p.h" @@ -442,6 +446,7 @@ QPalette *QApplicationPrivate::set_pal = 0; // default palette set by pro QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization +bool QApplicationPrivate::runtime_graphics_system = false; Q_GLOBAL_STATIC(QMutex, applicationFontMutex) QFont *QApplicationPrivate::app_font = 0; // default application font @@ -666,7 +671,8 @@ void QApplicationPrivate::process_cmdline() \o -geometry \e geometry, sets the client geometry of the first window that is shown. \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. + should be specified using an X logical font description. Note that + this option is ignored when Qt is built with fontconfig support enabled. \o -bg or \c -background \e color, sets the default background color and an application palette (light and dark shades are calculated). \o -fg or \c -foreground \e color, sets the default foreground color. @@ -1565,7 +1571,14 @@ QStyle* QApplication::setStyle(const QString& style) void QApplication::setGraphicsSystem(const QString &system) { - QApplicationPrivate::graphics_system_name = system; +#ifdef QT_GRAPHICSSYSTEM_RUNTIME + if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) { + QRuntimeGraphicsSystem *r = + static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system); + r->setGraphicsSystem(system); + } else +#endif + QApplicationPrivate::graphics_system_name = system; } /*! @@ -2218,15 +2231,17 @@ void QApplication::closeAllWindows() { bool did_close = true; QWidget *w; - while((w = activeModalWidget()) && did_close) { - if(!w->isVisible()) + while ((w = activeModalWidget()) && did_close) { + if (!w->isVisible() || w->data->is_closing) break; did_close = w->close(); } QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; did_close && i < list.size(); ++i) { w = list.at(i); - if (w->isVisible() && w->windowType() != Qt::Desktop) { + if (w->isVisible() + && w->windowType() != Qt::Desktop + && !w->data->is_closing) { did_close = w->close(); list = QApplication::topLevelWidgets(); i = -1; @@ -5268,18 +5283,20 @@ bool QApplication::keypadNavigationEnabled() This function replaces the QInputContext instance used by the application with \a inputContext. + Qt takes ownership of the given \a inputContext. + \sa inputContext() */ void QApplication::setInputContext(QInputContext *inputContext) { - Q_D(QApplication); - Q_UNUSED(d);// only static members being used. + if (inputContext == QApplicationPrivate::inputContext) + return; if (!inputContext) { qWarning("QApplication::setInputContext: called with 0 input context"); return; } - delete d->inputContext; - d->inputContext = inputContext; + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = inputContext; } /*! diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index e30b6be..e83cd71 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -412,6 +412,7 @@ public: static QPalette *set_pal; static QGraphicsSystem *graphics_system; static QString graphics_system_name; + static bool runtime_graphics_system; private: static QFont *app_font; // private for a reason! Always use QApplication::font() instead! diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index dc8d8f7..8ab82c9 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -62,6 +62,9 @@ #include "qpaintengine.h" #include "private/qmenubar_p.h" #include "private/qsoftkeymanager_p.h" +#ifdef QT_GRAPHICSSYSTEM_RUNTIME +#include "private/qgraphicssystem_runtime_p.h" +#endif #include "apgwgnam.h" // For CApaWindowGroupName #include <mdaaudiotoneplayer.h> // For CMdaAudioToneUtility @@ -83,6 +86,10 @@ QT_BEGIN_NAMESPACE +// Goom Events through Window Server +static const int KGoomMemoryLowEvent = 0x10282DBF; +static const int KGoomMemoryGoodEvent = 0x20026790; + #if defined(QT_DEBUG) static bool appNoGrab = false; // Grabbing enabled #endif @@ -408,32 +415,44 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent *event) { QApplicationPrivate *d = QApplicationPrivate::instance(); + QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); qreal pressure; if(d->pressureSupported && event->Pressure() > 0) //workaround for misconfigured HAL pressure = event->Pressure() / qreal(d->maxTouchPressure); else pressure = qreal(1.0); + processTouchEvent(event->PointerNumber(), event->iType, screenPos, pressure); +} +#endif +void QSymbianControl::processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure) +{ QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget); + QApplicationPrivate *d = QApplicationPrivate::instance(); + QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints; - while (points.count() <= event->PointerNumber()) + while (points.count() <= pointerNumber) points.append(QTouchEvent::TouchPoint(points.count())); Qt::TouchPointStates allStates = 0; for (int i = 0; i < points.count(); ++i) { QTouchEvent::TouchPoint &touchPoint = points[i]; - if (touchPoint.id() == event->PointerNumber()) { + if (touchPoint.id() == pointerNumber) { Qt::TouchPointStates state; - switch (event->iType) { + switch (type) { case TPointerEvent::EButton1Down: +#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER case TPointerEvent::EEnterHighPressure: +#endif state = Qt::TouchPointPressed; break; case TPointerEvent::EButton1Up: +#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER case TPointerEvent::EExitCloseProximity: +#endif state = Qt::TouchPointReleased; break; case TPointerEvent::EDrag: @@ -444,11 +463,10 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent state = Qt::TouchPointStationary; break; } - if (event->PointerNumber() == 0) + if (pointerNumber == 0) state |= Qt::TouchPointPrimary; touchPoint.setState(state); - QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); touchPoint.setScreenPos(screenPos); touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), screenPos.y() / screenGeometry.height())); @@ -473,7 +491,6 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent QTouchEvent::TouchScreen, points); } -#endif void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) { @@ -547,6 +564,13 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) qt_symbian_move_cursor_sprite(); #endif +//Generate single touch event for S60 5.0 (has touchscreen, does not have advanced pointers) +#ifndef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER + if (S60->hasTouchscreen) { + processTouchEvent(0, pEvent.iType, QPointF(globalPos), 1.0); + } +#endif + sendMouseEvent(receiver, type, globalPos, button, modifiers); } @@ -931,7 +955,16 @@ void QSymbianControl::Draw(const TRect& controlRect) const const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size()); if (engine->type() == QPaintEngine::Raster) { - QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); + QS60WindowSurface *s60Surface; +#ifdef QT_GRAPHICSSYSTEM_RUNTIME + if (QApplicationPrivate::runtime_graphics_system) { + QRuntimeWindowSurface *rtSurface = + static_cast<QRuntimeWindowSurface*>(qwidget->windowSurface()); + s60Surface = static_cast<QS60WindowSurface *>(rtSurface->m_windowSurface); + } else +#endif + s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); + CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); @@ -1814,6 +1847,53 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent } #endif break; + case KGoomMemoryLowEvent: +#ifdef QT_DEBUG + qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryLowEvent"; +#endif + if (callSymbianEventFilters(symbianEvent)) + return 1; +#ifdef QT_GRAPHICSSYSTEM_RUNTIME + if(QApplicationPrivate::runtime_graphics_system) { + bool switchToSwRendering(false); + + foreach (QWidget *w, QApplication::topLevelWidgets()) { + if(w->d_func()->topData()->backingStore) { + switchToSwRendering = true; + break; + } + } + + if (switchToSwRendering) { + QRuntimeGraphicsSystem *gs = + static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system); + + uint memoryUsage = gs->memoryUsage(); + uint memoryForFullscreen = ( S60->screenDepth / 8 ) + * S60->screenWidthInPixels + * S60->screenHeightInPixels; + + S60->memoryLimitForHwRendering = memoryUsage - memoryForFullscreen; + gs->setGraphicsSystem(QLatin1String("raster")); + } + } +#endif + break; + case KGoomMemoryGoodEvent: +#ifdef QT_DEBUG + qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryGoodEvent"; +#endif + if (callSymbianEventFilters(symbianEvent)) + return 1; +#ifdef QT_GRAPHICSSYSTEM_RUNTIME + if(QApplicationPrivate::runtime_graphics_system) { + QRuntimeGraphicsSystem *gs = + static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system); + gs->setGraphicsSystem(QLatin1String("openvg"), S60->memoryLimitForHwRendering); + S60->memoryLimitForHwRendering = 0; + } +#endif + break; default: break; } @@ -1996,6 +2076,9 @@ void QApplicationPrivate::initializeMultitouch_sys() pressureSupported = 0; if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone) maxTouchPressure = KMaxTInt; +#else + pressureSupported = 0; + maxTouchPressure = KMaxTInt; #endif } diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 2b12317..92dd0a1 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -64,6 +64,7 @@ #include "qtextcodec.h" #include "qdnd_p.h" +#include "qapplication_p.h" #include "qt_x11_p.h" #include "qx11info_x11.h" @@ -1111,7 +1112,20 @@ void qt_xdnd_send_leave() waiting_for_status = false; } - +// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8. +static Qt::KeyboardModifiers currentKeyboardModifiers() +{ + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint keybstate; + for (int i = 0; i < ScreenCount(X11->display); ++i) { + if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child, + &root_x, &root_y, &win_x, &win_y, &keybstate)) + return X11->translateModifiers(keybstate & 0x00ff); + } + return 0; +} void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) { @@ -1159,6 +1173,11 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) if (!dropData) dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData; + // Drop coming from another app? Update keyboard modifiers. + if (!qt_xdnd_dragging) { + QApplicationPrivate::modifier_buttons = currentKeyboardModifiers(); + } + QDropEvent de(qt_xdnd_current_position, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers()); QApplication::sendEvent(qt_xdnd_current_widget, &de); diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 5db121a..44fb4f0 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -73,6 +73,9 @@ ** ****************************************************************************/ +#ifndef QT_COCOA_HELPERS_MAC_P_H +#define QT_COCOA_HELPERS_MAC_P_H + // // W A R N I N G // ------------- @@ -216,3 +219,5 @@ bool qt_cocoaPostMessage(id target, SEL selector); void qt_mac_post_retranslateAppMenu(); QT_END_NAMESPACE + +#endif // QT_COCOA_HELPERS_MAC_P_H diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index f560458..fe3fa57 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -129,6 +129,7 @@ public: int supportsPremultipliedAlpha : 1; int avkonComponentsSupportTransparency : 1; int menuBeingConstructed : 1; + int memoryLimitForHwRendering; QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type static inline void updateScreenSize(); static inline RWsSession& wsSession(); @@ -216,6 +217,7 @@ private: const QPoint &globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers); + void processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 1f2cd8c..b5879ae 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -248,9 +248,14 @@ QWidgetPrivate::~QWidgetPrivate() QWindowSurface *QWidgetPrivate::createDefaultWindowSurface() { Q_Q(QWidget); + + QWindowSurface *surface; if (QApplicationPrivate::graphicsSystem()) - return QApplicationPrivate::graphicsSystem()->createWindowSurface(q); - return createDefaultWindowSurface_sys(); + surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q); + else + surface = createDefaultWindowSurface_sys(); + + return surface; } /*! @@ -312,6 +317,8 @@ QInputContext *QWidget::inputContext() This function sets the input context \a context on this widget. + Qt takes ownership of the given input \a context. + \sa inputContext() */ void QWidget::setInputContext(QInputContext *context) @@ -320,6 +327,8 @@ void QWidget::setInputContext(QInputContext *context) if (!testAttribute(Qt::WA_InputMethodEnabled)) return; #ifndef QT_NO_IM + if (context == d->ic) + return; if (d->ic) delete d->ic; d->ic = context; @@ -670,8 +679,8 @@ void QWidget::setAutoFillBackground(bool enabled) (to move the keyboard focus), and passes on most of the other events to one of the more specialized handlers above. - Events and the mechanism used to deliver them are covered in the - \l{Events and Event Filters} document. + Events and the mechanism used to deliver them are covered in + \l{The Event System}. \section1 Groups of Functions and Properties |