summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-06-01 17:40:53 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-06-01 17:40:53 (GMT)
commit5c6e671c8cbab281af4685d3698790ab566ed2f2 (patch)
tree0f3e15d12cf984d8f49c7adfaf056063cc726803 /src/gui/kernel
parent7165826d2e9ff77951a289c62746d6c87f725139 (diff)
parent0b034e816994f3c6ad5ba5e0e9f7c0c60ab9440d (diff)
downloadQt-5c6e671c8cbab281af4685d3698790ab566ed2f2.zip
Qt-5c6e671c8cbab281af4685d3698790ab566ed2f2.tar.gz
Qt-5c6e671c8cbab281af4685d3698790ab566ed2f2.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication.cpp52
-rw-r--r--src/gui/kernel/qapplication_p.h4
-rw-r--r--src/gui/kernel/qapplication_s60.cpp118
-rw-r--r--src/gui/kernel/qdnd_x11.cpp21
-rw-r--r--src/gui/kernel/qdrag.cpp4
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h5
-rw-r--r--src/gui/kernel/qt_s60_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp17
8 files changed, 192 insertions, 31 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 920000e..6caa7ee 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"
@@ -440,6 +444,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
@@ -664,7 +669,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.
@@ -772,6 +778,9 @@ void QApplicationPrivate::construct(
qt_is_gui_used = (qt_appType != QApplication::Tty);
process_cmdline();
+ // the environment variable has the lowest precedence of runtime graphicssystem switches
+ if (graphics_system_name.isEmpty())
+ graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM"));
// Must be called before initialize()
qt_init(this, qt_appType
#ifdef Q_WS_X11
@@ -1552,10 +1561,18 @@ QStyle* QApplication::setStyle(const QString& style)
on-screen widgets and QPixmaps. The available systems are \c{"native"},
\c{"raster"} and \c{"opengl"}.
- This function call overrides both the application commandline
- \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch.
+ There are several ways to set the graphics backend, in order of decreasing
+ precedence:
+ \list
+ \o the application commandline \c{-graphicssystem} switch
+ \o QApplication::setGraphicsSystem()
+ \o the QT_GRAPHICSSYSTEM environment variable
+ \o the Qt configure \c{-graphicssystem} switch
+ \endlist
+ If the highest precedence switch sets an invalid name, the error will be
+ ignored and the default backend will be used.
- \warning This function must be called before the QApplication constructor
+ \warning This function is only effective before the QApplication constructor
is called.
\note The \c{"opengl"} option is currently experimental.
@@ -1563,7 +1580,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;
}
/*!
@@ -2216,15 +2240,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;
@@ -5261,18 +5287,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 25dea1f..9a5714b 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!
@@ -579,7 +580,8 @@ public:
void _q_readRX71MultiTouchEvents();
#endif
-#if defined(Q_WS_S60)
+#if defined(Q_OS_SYMBIAN)
+ int pressureSupported;
int maxTouchPressure;
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
#endif
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 0058ff5..82c3545 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,25 +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);
- while (d->appAllTouchPoints.count() <= event->PointerNumber())
- d->appAllTouchPoints.append(QTouchEvent::TouchPoint(d->appAllTouchPoints.count()));
+ QApplicationPrivate *d = QApplicationPrivate::instance();
+
+ QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints;
+ while (points.count() <= pointerNumber)
+ points.append(QTouchEvent::TouchPoint(points.count()));
Qt::TouchPointStates allStates = 0;
- for (int i = 0; i < d->appAllTouchPoints.count(); ++i) {
- QTouchEvent::TouchPoint &touchPoint = d->appAllTouchPoints[i];
+ 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:
@@ -437,16 +463,15 @@ 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()));
- touchPoint.setPressure(event->Pressure() / qreal(d->maxTouchPressure));
+ touchPoint.setPressure(pressure);
} else if (touchPoint.state() != Qt::TouchPointReleased) {
// all other active touch points should be marked as stationary
touchPoint.setState(Qt::TouchPointStationary);
@@ -458,13 +483,14 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent
if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) {
// all touch points released
d->appAllTouchPoints.clear();
+ } else {
+ d->appAllTouchPoints = points;
}
QApplicationPrivate::translateRawTouchEvent(qwidget,
QTouchEvent::TouchScreen,
- d->appAllTouchPoints);
+ points);
}
-#endif
void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
{
@@ -538,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);
}
@@ -922,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();
@@ -1805,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;
}
@@ -1983,8 +2072,13 @@ TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym)
void QApplicationPrivate::initializeMultitouch_sys()
{
#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
+ if (HAL::Get(HALData::EPointer3DPressureSupported, pressureSupported) != KErrNone)
+ 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/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index b57615c..77f8fc0 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -253,7 +253,9 @@ Qt::DropAction QDrag::exec(Qt::DropActions supportedActions)
can take some time, but this function does not block the event
loop. Other events are still delivered to the application while
the operation is performed. On Windows, the Qt event loop is
- blocked while during the operation.
+ blocked during the operation. However, QDrag::exec() on
+ Windows causes processEvents() to be called frequently to keep the GUI responsive.
+ If any loops or operations are called while a drag operation is active, it will block the drag operation.
*/
Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction)
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index 6b005ca..57d2c90 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
// -------------
@@ -224,3 +227,5 @@ void qt_cocoaPostMessage(id target, SEL selector, int argCount=0, id arg1=0, id
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 6d48e0e..a891be0 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