diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-16 23:09:00 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-16 23:09:00 (GMT) |
commit | 8c216aee5d2e52b6fa36e256615374b9435bb4c9 (patch) | |
tree | c65554b66874dae21a0876f804926254073aedd0 /src/gui/kernel | |
parent | 3340b23699f0286876f1e237a66bdc85076fe191 (diff) | |
parent | 3849cd0cca618fac88a54861a3ec30780711ce75 (diff) | |
download | Qt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.zip Qt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.tar.gz Qt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 17 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_win.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qdnd_qws.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qdnd_x11.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 33 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qsound_mac.mm | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 60 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 30 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_win.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_wince.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_x11.cpp | 2 |
12 files changed, 112 insertions, 61 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index ec635d4..7b62de1 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -788,6 +788,10 @@ void QApplicationPrivate::construct( qt_gui_eval_init(application_type); #endif +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + symbianInit(); +#endif + #ifndef QT_NO_LIBRARY if(load_testability) { QLibrary testLib(QLatin1String("qttestability")); @@ -2364,6 +2368,19 @@ bool QApplication::event(QEvent *e) if (!(w->windowType() == Qt::Desktop)) postEvent(w, new QEvent(QEvent::LanguageChange)); } +#ifndef Q_OS_WIN + } else if (e->type() == QEvent::LocaleChange) { + // on Windows the event propagation is taken care by the + // WM_SETTINGCHANGE event handler. + QWidgetList list = topLevelWidgets(); + for (int i = 0; i < list.size(); ++i) { + QWidget *w = list.at(i); + if (!(w->windowType() == Qt::Desktop)) { + if (!w->testAttribute(Qt::WA_SetLocale)) + w->d_func()->setLocale_helper(QLocale(), true); + } + } +#endif } else if (e->type() == QEvent::Timer) { QTimerEvent *te = static_cast<QTimerEvent*>(e); Q_ASSERT(te != 0); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index fb2837e..50b9759 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1936,6 +1936,8 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa QLocalePrivate::updateSystemPrivate(); if (!widget->testAttribute(Qt::WA_SetLocale)) widget->dptr()->setLocale_helper(QLocale(), true); + QEvent e(QEvent::LocaleChange); + QApplication::sendEvent(qApp, &e); } } else if (msg.wParam == SPI_SETICONTITLELOGFONT) { diff --git a/src/gui/kernel/qdnd_qws.cpp b/src/gui/kernel/qdnd_qws.cpp index e47de00..7e5afc7 100644 --- a/src/gui/kernel/qdnd_qws.cpp +++ b/src/gui/kernel/qdnd_qws.cpp @@ -192,6 +192,10 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) return false; switch(e->type()) { + case QEvent::ShortcutOverride: + // prevent accelerators from firing while dragging + e->accept(); + return true; case QEvent::KeyPress: case QEvent::KeyRelease: diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 0a05d8e..2b12317 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -1299,6 +1299,12 @@ bool QDragManager::eventFilter(QObject * o, QEvent * e) return true; } + if (e->type() == QEvent::ShortcutOverride) { + // prevent accelerators from firing while dragging + e->accept(); + return true; + } + if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent *ke = ((QKeyEvent*)e); if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) { diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index aa6720e..9495f40 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -132,20 +132,21 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); - m_gestureToRecognizer.remove(g); } } - foreach (QGestureRecognizer *recognizer, list) { - QList<QGesture *> obsoleteGestures; - QMap<ObjectGesture, QList<QGesture *> >::Iterator iter = m_objectGestures.begin(); - while (iter != m_objectGestures.end()) { - ObjectGesture objectGesture = iter.key(); - if (objectGesture.gesture == type) - obsoleteGestures << iter.value(); - ++iter; + QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type) { + foreach (QGesture *g, iter.value()) { + if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g)) { + m_gestureToRecognizer.remove(g); + m_obsoleteGestures[recognizer].insert(g); + } + } } - m_obsoleteGestures.insert(recognizer, obsoleteGestures); + ++iter; } } @@ -155,7 +156,14 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object.data()) { - qDeleteAll(iter.value()); + QSet<QGesture *> gestures = iter.value().toSet(); + for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator + it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { + it.value() -= gestures; + } + foreach (QGesture *g, gestures) + m_deletedRecognizers.remove(g); + qDeleteAll(gestures); iter = m_objectGestures.erase(iter); } else { ++iter; @@ -177,6 +185,9 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni #ifndef QT_NO_GRAPHICSVIEW } else { Q_ASSERT(qobject_cast<QGraphicsObject *>(object)); + QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object); + if (graphicsObject->QGraphicsItem::d_func()->inDestructor) + return 0; #endif } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index a0ff83f..c105c9b 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -127,7 +127,7 @@ private: int m_lastCustomGestureId; - QHash<QGestureRecognizer *, QList<QGesture *> > m_obsoleteGestures; + QHash<QGestureRecognizer *, QSet<QGesture *> > m_obsoleteGestures; QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); diff --git a/src/gui/kernel/qsound_mac.mm b/src/gui/kernel/qsound_mac.mm index 71fd663..2aff44d 100644 --- a/src/gui/kernel/qsound_mac.mm +++ b/src/gui/kernel/qsound_mac.mm @@ -88,14 +88,14 @@ QT_END_NAMESPACE QT_USE_NAMESPACE -@interface QMacSoundDelegate : NSObject<NSSoundDelegate> { +@interface QT_MANGLE_NAMESPACE(QMacSoundDelegate) : NSObject<NSSoundDelegate> { QSound *qSound; // may be null. QAuServerMac* server; } -(id)initWithQSound:(QSound*)sound:(QAuServerMac*)server; @end -@implementation QMacSoundDelegate +@implementation QT_MANGLE_NAMESPACE(QMacSoundDelegate) -(id)initWithQSound:(QSound*)s:(QAuServerMac*)serv { self = [super init]; if(self) { @@ -172,7 +172,7 @@ NSSound *QAuServerMac::createNSSound(const QString &fileName, QSound *qSound) { NSString *nsFileName = const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(fileName))); NSSound * const nsSound = [[NSSound alloc] initWithContentsOfFile: nsFileName byReference:YES]; - QMacSoundDelegate * const delegate = [[QMacSoundDelegate alloc] initWithQSound:qSound:this]; + QT_MANGLE_NAMESPACE(QMacSoundDelegate) * const delegate = [[QT_MANGLE_NAMESPACE(QMacSoundDelegate) alloc] initWithQSound:qSound:this]; [nsSound setDelegate:delegate]; [nsFileName release]; return nsSound; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 60f38f2..4a9fa94 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1388,6 +1388,9 @@ QWidget::~QWidget() qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); #endif + foreach (Qt::GestureType type, d->gestureContext.keys()) + ungrabGesture(type); + // force acceptDrops false before winId is destroyed. d->registerDropSite(false); @@ -2535,7 +2538,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool Q_Q(QWidget); QStyle *oldStyle = q->style(); #ifndef QT_NO_STYLE_STYLESHEET - QStyle *origStyle = 0; + QWeakPointer<QStyle> origStyle; #endif #ifdef Q_WS_MAC @@ -2549,7 +2552,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool createExtra(); #ifndef QT_NO_STYLE_STYLESHEET - origStyle = extra->style; + origStyle = extra->style.data(); #endif extra->style = newStyle; } @@ -2578,23 +2581,23 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool } } - QEvent e(QEvent::StyleChange); - QApplication::sendEvent(q, &e); -#ifdef QT3_SUPPORT - q->styleChange(*oldStyle); -#endif - #ifndef QT_NO_STYLE_STYLESHEET if (!qobject_cast<QStyleSheetStyle*>(newStyle)) { - if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle)) { + if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) { cssStyle->clearWidgetFont(q); } } #endif + QEvent e(QEvent::StyleChange); + QApplication::sendEvent(q, &e); +#ifdef QT3_SUPPORT + q->styleChange(*oldStyle); +#endif + #ifndef QT_NO_STYLE_STYLESHEET // dereference the old stylesheet style - if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle)) + if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data())) proxy->deref(); #endif } @@ -5583,52 +5586,23 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * pixmapOffset = painterTransform.map(pixmapOffset); } - QRect effectRect; - if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { + if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); - - } else if (mode == QGraphicsEffect::PadToTransparentBorder) { + else if (mode == QGraphicsEffect::PadToTransparentBorder) effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); - - } else { + else effectRect = sourceRect.toAlignedRect(); - } - if (offset) *offset = effectRect.topLeft(); - if (deviceCoordinates) { - // Clip to device rect. - int left, top, right, bottom; - effectRect.getCoords(&left, &top, &right, &bottom); - if (left < 0) { - if (offset) - offset->rx() += -left; - effectRect.setX(0); - } - if (top < 0) { - if (offset) - offset->ry() += -top; - effectRect.setY(0); - } - // NB! We use +-1 for historical reasons (see QRect documentation). - QPaintDevice *device = context->painter->device(); - const int deviceWidth = device->width(); - const int deviceHeight = device->height(); - if (right + 1 > deviceWidth) - effectRect.setRight(deviceWidth - 1); - if (bottom + 1 > deviceHeight) - effectRect.setBottom(deviceHeight -1); - } - pixmapOffset -= effectRect.topLeft(); QPixmap pixmap(effectRect.size()); pixmap.fill(Qt::transparent); - m_widget->render(&pixmap, pixmapOffset); + m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); return pixmap; } #endif //QT_NO_GRAPHICSEFFECT diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index e29b755..f12c956 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3824,9 +3824,35 @@ void QWidgetPrivate::raise_sys() #if QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; if (isRealWindow()) { - // Calling orderFront shows the window on Cocoa too. + // With the introduction of spaces it is not as simple as just raising the window. + // First we need to check if we are in the right space. If we are, then we just continue + // as usual. The problem comes when we are not in the active space. There are two main cases: + // 1. Our parent was moved to a new space. In this case we want the window to be raised + // in the same space as its parent. + // 2. We don't have a parent. For this case we will just raise the window and let Cocoa + // switch to the corresponding space. + // NOTICE: There are a lot of corner cases here. We are keeping this simple for now, if + // required we will introduce special handling for some of them. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { - [qt_mac_window_for(q) orderFront:qt_mac_window_for(q)]; + OSWindowRef window = qt_mac_window_for(q); + // isOnActiveSpace is available only from 10.6 onwards, so we need to check if it is + // available before calling it. + if([window respondsToSelector:@selector(isOnActiveSpace)]) { + if(![window performSelector:@selector(isOnActiveSpace)]) { + QWidget *parentWidget = q->parentWidget(); + if(parentWidget) { + OSWindowRef parentWindow = qt_mac_window_for(parentWidget); + if(parentWindow && [parentWindow isOnActiveSpace]) { + // The window was created in a different space. Therefore if we want + // to show it in the current space we need to recreate it in the new + // space. + recreateMacWindow(); + window = qt_mac_window_for(q); + } + } + } + } + [window orderFront:window]; } if (qt_mac_raise_process) { //we get to be the active process now ProcessSerialNumber psn; diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 7d647b7..5482da3 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -123,9 +123,11 @@ static PtrWTClose ptrWTClose = 0; static PtrWTInfo ptrWTInfo = 0; static PtrWTQueueSizeGet ptrWTQueueSizeGet = 0; static PtrWTQueueSizeSet ptrWTQueueSizeSet = 0; +#ifndef QT_NO_TABLETEVENT static void init_wintab_functions(); static void qt_tablet_init(); static void qt_tablet_cleanup(); +#endif // QT_NO_TABLETEVENT extern HCTX qt_tablet_context; extern bool qt_tablet_tilt_support; @@ -136,6 +138,8 @@ QWidget* qt_get_tablet_widget() } extern bool qt_is_gui_used; + +#ifndef QT_NO_TABLETEVENT static void init_wintab_functions() { #if defined(Q_OS_WINCE) @@ -227,6 +231,7 @@ static void qt_tablet_cleanup() delete qt_tablet_widget; qt_tablet_widget = 0; } +#endif // QT_NO_TABLETEVENT const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp @@ -512,8 +517,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO DestroyWindow(destroyw); } +#ifndef QT_NO_TABLETEVENT if (q != qt_tablet_widget && QWidgetPrivate::mapper) qt_tablet_init(); +#endif // QT_NO_TABLETEVENT if (q->testAttribute(Qt::WA_DropSiteRegistered)) registerDropSite(true); diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp index 509847b..fc1e52c 100644 --- a/src/gui/kernel/qwidget_wince.cpp +++ b/src/gui/kernel/qwidget_wince.cpp @@ -63,6 +63,7 @@ typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT); typedef int (API *PtrWTQueueSizeGet)(HCTX); typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int); +#ifndef QT_NO_TABLETEVENT static void qt_tablet_init_wce(); static void qt_tablet_cleanup_wce(); @@ -135,6 +136,7 @@ static void qt_tablet_cleanup_wce() { delete qt_tablet_widget; qt_tablet_widget = 0; } +#endif // QT_NO_TABLETEVENT // The internal qWinRequestConfig, defined in qapplication_win.cpp, stores move, @@ -358,8 +360,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO DestroyWindow(destroyw); } +#ifndef QT_NO_TABLETEVENT if (q != qt_tablet_widget && QWidgetPrivate::mapper) qt_tablet_init_wce(); +#endif // QT_NO_TABLETEVENT if (q->testAttribute(Qt::WA_DropSiteRegistered)) registerDropSite(true); diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 37ac6bf..43f510c 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -3000,7 +3000,7 @@ Picture QX11Data::getSolidFill(int screen, const QColor &c) return X11->solid_fills[i].picture; } // none found, replace one - int i = rand() % 16; + int i = qrand() % 16; if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) { XRenderFreePicture (X11->display, X11->solid_fills[i].picture); |