Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qwidget.cpp

    r786 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6868# include "qt_cocoa_helpers_mac_p.h"
    6969# include "qmainwindow.h"
     70# include "qtoolbar.h"
     71# include <private/qmainwindowlayout_p.h>
    7072#endif
    7173#if defined(Q_WS_QWS)
     
    127129#endif // QT_KEYPAD_NAVIGATION
    128130
     131#ifdef Q_WS_S60
     132#include <aknappui.h>
     133#endif
     134
    129135// widget/widget data creation count
    130136//#define QWIDGET_EXTRA_DEBUG
     
    165171extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
    166172extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
     173
     174/*!
     175    \internal
     176    \class QWidgetBackingStoreTracker
     177    \brief Class which allows tracking of which widgets are using a given backing store
     178
     179    QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer,
     180    which maintains a list of the QWidgets which are currently using the backing
     181    store.  This list is modified via the registerWidget and unregisterWidget functions.
     182 */
     183
     184QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
     185    :   m_ptr(0)
     186{
     187
     188}
     189
     190QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker()
     191{
     192    delete m_ptr;
     193}
     194
     195/*!
     196    \internal
     197    Destroy the contained QWidgetBackingStore, if not null, and clear the list of
     198    widgets using the backing store, then create a new QWidgetBackingStore, providing
     199    the QWidget.
     200 */
     201void QWidgetBackingStoreTracker::create(QWidget *widget)
     202{
     203    destroy();
     204    m_ptr = new QWidgetBackingStore(widget);
     205}
     206
     207/*!
     208    \internal
     209    Destroy the contained QWidgetBackingStore, if not null, and clear the list of
     210    widgets using the backing store.
     211 */
     212void QWidgetBackingStoreTracker::destroy()
     213{
     214    delete m_ptr;
     215    m_ptr = 0;
     216    m_widgets.clear();
     217}
     218
     219/*!
     220    \internal
     221    Add the widget to the list of widgets currently using the backing store.
     222    If the widget was already in the list, this function is a no-op.
     223 */
     224void QWidgetBackingStoreTracker::registerWidget(QWidget *w)
     225{
     226    Q_ASSERT(m_ptr);
     227    Q_ASSERT(w->internalWinId());
     228    Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr);
     229    m_widgets.insert(w);
     230}
     231
     232/*!
     233    \internal
     234    Remove the widget from the list of widgets currently using the backing store.
     235    If the widget was in the list, and removing it causes the list to be empty,
     236    the backing store is deleted.
     237    If the widget was not in the list, this function is a no-op.
     238 */
     239void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w)
     240{
     241    if (m_widgets.remove(w) && m_widgets.isEmpty()) {
     242        delete m_ptr;
     243        m_ptr = 0;
     244    }
     245}
     246
     247/*!
     248    \internal
     249    Recursively remove widget and all of its descendents.
     250 */
     251void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget)
     252{
     253    unregisterWidget(widget);
     254    foreach (QObject *child, widget->children())
     255        if (QWidget *childWidget = qobject_cast<QWidget *>(child))
     256            unregisterWidgetSubtree(childWidget);
     257}
    167258
    168259QWidgetPrivate::QWidgetPrivate(int version)
     
    203294      , isGLWidget(0)
    204295      , usesDoubleBufferedGLContext(0)
     296#ifndef QT_NO_IM
     297      , inheritsInputMethodHints(0)
     298#endif
    205299#if defined(Q_WS_X11)
    206300      , picture(0)
     
    209303#elif defined(Q_WS_WIN)
    210304      , noPaintOnScreen(0)
     305  #ifndef QT_NO_GESTURES
    211306      , nativeGesturePanEnabled(0)
     307  #endif
    212308#elif defined(Q_WS_MAC)
    213309      , needWindowChange(0)
     310      , hasAlienChildren(0)
    214311      , window_event(0)
    215312      , qd_hd(0)
     
    226323    isWidget = true;
    227324    memset(high_attributes, 0, sizeof(high_attributes));
     325#if QT_MAC_USE_COCOA
     326    drawRectOriginalAdded = false;
     327    originalDrawMethod = true;
     328    changeMethods = false;
     329#endif // QT_MAC_USE_COCOA
    228330#ifdef QWIDGET_EXTRA_DEBUG
    229331    static int count = 0;
     
    246348}
    247349
     350class QDummyWindowSurface : public QWindowSurface
     351{
     352public:
     353    QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {}
     354    QPaintDevice *paintDevice() { return window(); }
     355    void flush(QWidget *, const QRegion &, const QPoint &) {}
     356};
     357
    248358QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
    249359{
    250360    Q_Q(QWidget);
    251     if (QApplicationPrivate::graphicsSystem())
    252         return QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
    253     return createDefaultWindowSurface_sys();
     361
     362    QWindowSurface *surface;
     363    if (q->property("_q_DummyWindowSurface").toBool()) {
     364        surface = new QDummyWindowSurface(q);
     365    } else {
     366        if (QApplicationPrivate::graphicsSystem())
     367            surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
     368        else
     369            surface = createDefaultWindowSurface_sys();
     370    }
     371
     372    return surface;
    254373}
    255374
     
    286405    if (ic)
    287406        return ic;
    288 #endif
    289407    return qApp->inputContext();
     408#else
     409    return 0;
     410#endif
    290411}
    291412
     
    312433  This function sets the input context \a context
    313434  on this widget.
     435
     436  Qt takes ownership of the given input \a context.
    314437
    315438  \sa inputContext()
     
    321444    if (!testAttribute(Qt::WA_InputMethodEnabled))
    322445        return;
     446    if (context == d->ic)
     447        return;
    323448    if (d->ic)
    324449        delete d->ic;
    325450    d->ic = context;
     451    if (d->ic)
     452        d->ic->setParent(this);
    326453#endif
    327454}
     
    639766        \i  mouseMoveEvent() is called whenever the mouse moves while a mouse
    640767            button is held down. This can be useful during drag and drop
    641             operations. If you call setMouseTracking(true), you get mouse move
    642             events even when no buttons are held down. (See also the \l{Drag
    643             and Drop} guide.)
     768            operations. If you call \l{setMouseTracking()}{setMouseTracking}(true),
     769            you get mouse move events even when no buttons are held down.
     770            (See also the \l{Drag and Drop} guide.)
    644771        \i  keyReleaseEvent() is called whenever a key is released and while it
    645772            is held down (if the key is auto-repeating). In that case, the
     
    671798    one of the more specialized handlers above.
    672799
    673     Events and the mechanism used to deliver them are covered in the
    674     \l{Events and Event Filters} document.
     800    Events and the mechanism used to deliver them are covered in
     801    \l{The Event System}.
    675802
    676803    \section1 Groups of Functions and Properties
     
    10111138    \sa windowFlags
    10121139*/
    1013 
    10141140QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
    10151141    : QObject(*new QWidgetPrivate, 0), QPaintDevice()
     
    11061232    }
    11071233    if (customize)
    1108         ; // don't modify window flags if the user explicitely set them.
     1234        ; // don't modify window flags if the user explicitly set them.
    11091235    else if (type == Qt::Dialog || type == Qt::Sheet)
    11101236#ifndef Q_WS_WINCE
     
    11281254
    11291255    Q_ASSERT(allWidgets);
    1130     allWidgets->insert(q);
     1256    if (allWidgets)
     1257        allWidgets->insert(q);
    11311258
    11321259    QWidget *desktopWidget = 0;
     
    11751302        q->setAttribute(Qt::WA_NativeWindow);
    11761303
     1304#ifdef Q_WS_MAC
     1305    q->setAttribute(Qt::WA_NativeWindow);
     1306#endif
     1307
    11771308    q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
    11781309    adjustQuitOnCloseAttribute();
     
    11811312
    11821313    //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
     1314#ifdef Q_OS_SYMBIAN
     1315    if (isGLWidget) {
     1316        // Don't waste GPU mem for unnecessary large egl surface
     1317        data.crect = QRect(0,0,2,2);
     1318    } else {
     1319        data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640);
     1320    }
     1321#else
    11831322    data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
     1323#endif
    11841324
    11851325    focus_next = focus_prev = q;
     
    12701410
    12711411    if (QWidget *parent = parentWidget()) {
     1412#ifdef Q_WS_MAC
     1413        if (testAttribute(Qt::WA_NativeWindow) == false)
     1414            parent->d_func()->hasAlienChildren = true;
     1415#endif
    12721416        if (type & Qt::Window) {
    12731417            if (!parent->testAttribute(Qt::WA_WState_Created))
     
    13311475    // a real toplevel window needs a backing store
    13321476    if (isWindow() && windowType() != Qt::Desktop) {
    1333         delete d->topData()->backingStore;
    1334         // QWidgetBackingStore will check this variable, hence it must be 0
    1335         d->topData()->backingStore = 0;
     1477        d->topData()->backingStore.destroy();
    13361478        if (hasBackingStoreSupport())
    1337             d->topData()->backingStore = new QWidgetBackingStore(this);
     1479            d->topData()->backingStore.create(this);
    13381480    }
    13391481
     
    13781520    if (paintingActive())
    13791521        qWarning("QWidget: %s (%s) deleted while being painted", className(), name());
     1522#endif
     1523
     1524#ifndef QT_NO_GESTURES
     1525    foreach (Qt::GestureType type, d->gestureContext.keys())
     1526        ungrabGesture(type);
    13801527#endif
    13811528
     
    14401587    }
    14411588
    1442 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM)
     1589#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM)
    14431590    else if (!internalWinId() && isVisible()) {
    14441591        qApp->d_func()->sendSyntheticEnterLeave(this);
     
    14581605        // not have a reference to this widget that will be used later to
    14591606        // notify the window it no longer has a surface.
    1460         delete d->extra->topextra->backingStore;
    1461         d->extra->topextra->backingStore = 0;
     1607        d->extra->topextra->backingStore.destroy();
    14621608    }
    14631609#endif
     
    14751621
    14761622    if (d->declarativeData) {
    1477         d->declarativeData->destroyed(this);
     1623        QAbstractDeclarativeData::destroyed(d->declarativeData, this);
    14781624        d->declarativeData = 0;                 // don't activate again in ~QObject
    14791625    }
     1626
     1627#ifdef QT_MAC_USE_COCOA
     1628    // QCocoaView holds a pointer back to this widget. Clear it now
     1629    // to make sure it's not followed later on. The lifetime of the
     1630    // QCocoaView might exceed the lifetime of this widget in cases
     1631    // where Cocoa itself holds references to it.
     1632    extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *);
     1633    qt_mac_clearCocoaViewQWidgetPointers(this);
     1634#endif
    14801635
    14811636    if (!d->children.isEmpty())
     
    15291684
    15301685    if(oldWinId != id) {
    1531         // Do not emit an event when the old winId is destroyed.  This only
    1532         // happens (a) during widget destruction, and (b) immediately prior
    1533         // to creation of a new winId, for example as a result of re-parenting.
    1534         if(id != 0) {
    1535             QEvent e(QEvent::WinIdChange);
    1536             QCoreApplication::sendEvent(q, &e);
    1537         }
     1686        QEvent e(QEvent::WinIdChange);
     1687        QCoreApplication::sendEvent(q, &e);
    15381688    }
    15391689}
     
    15471697        x->icon = 0;
    15481698        x->iconPixmap = 0;
    1549         x->backingStore = 0;
    15501699        x->windowSurface = 0;
    15511700        x->sharedPainter = 0;
     
    15611710        x->inRepaint = false;
    15621711        x->embedded = 0;
     1712#ifdef Q_WS_MAC
     1713#ifdef QT_MAC_USE_COCOA
     1714        x->wasMaximized = false;
     1715#endif // QT_MAC_USE_COCOA
     1716#endif // Q_WS_MAC
    15631717        createTLSysExtra();
    15641718#ifdef QWIDGET_EXTRA_DEBUG
     
    16261780        if (extra->topextra) {
    16271781            deleteTLSysExtra();
    1628             delete extra->topextra->backingStore;
     1782            extra->topextra->backingStore.destroy();
    16291783            delete extra->topextra->icon;
    16301784            delete extra->topextra->iconPixmap;
     
    23082462{
    23092463    if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
     2464#ifdef ALIEN_DEBUG
     2465        qDebug() << "QWidget::winId: creating native window for" << this;
     2466#endif
    23102467        QWidget *that = const_cast<QWidget*>(this);
    23112468        that->setAttribute(Qt::WA_NativeWindow);
     
    23202477{
    23212478    Q_Q(QWidget);
     2479
     2480#ifdef ALIEN_DEBUG
     2481    qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
     2482#endif
    23222483    const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
    23232484    if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
     
    23622523{
    23632524    Q_D(QWidget);
     2525#ifdef ALIEN_DEBUG
     2526    qDebug()  << "QWidget::createWinId" << this;
     2527#endif
    23642528//    qWarning("QWidget::createWinId is obsolete, please fix your code.");
    23652529    d->createWinId();
     
    25082672    QStyle *oldStyle  = q->style();
    25092673#ifndef QT_NO_STYLE_STYLESHEET
    2510     QStyle *origStyle = 0;
     2674    QWeakPointer<QStyle> origStyle;
    25112675#endif
    25122676
     
    25222686
    25232687#ifndef QT_NO_STYLE_STYLESHEET
    2524         origStyle = extra->style;
     2688        origStyle = extra->style.data();
    25252689#endif
    25262690        extra->style = newStyle;
     
    25512715    }
    25522716
     2717#ifndef QT_NO_STYLE_STYLESHEET
     2718    if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
     2719        if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
     2720            cssStyle->clearWidgetFont(q);
     2721        }
     2722    }
     2723#endif
     2724
    25532725    QEvent e(QEvent::StyleChange);
    25542726    QApplication::sendEvent(q, &e);
     
    25582730
    25592731#ifndef QT_NO_STYLE_STYLESHEET
    2560     if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
    2561         if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle)) {
    2562             cssStyle->clearWidgetFont(q);
    2563         }
    2564     }
    2565 #endif
    2566 
    2567 #ifndef QT_NO_STYLE_STYLESHEET
    25682732    // dereference the old stylesheet style
    2569     if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle))
     2733    if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
    25702734        proxy->deref();
    25712735#endif
     
    28683032void QWidget::showFullScreen()
    28693033{
     3034#ifdef Q_WS_MAC
     3035    // If the unified toolbar is enabled, we have to disable it before going fullscreen.
     3036    QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
     3037    if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) {
     3038        mainWindow->setUnifiedTitleAndToolBarOnMac(false);
     3039        QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     3040        mainLayout->activateUnifiedToolbarAfterFullScreen = true;
     3041    }
     3042#endif // Q_WS_MAC
    28703043    ensurePolished();
    28713044#ifdef QT3_SUPPORT
     
    29003073    setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
    29013074                   | Qt::WindowMaximized);
     3075#ifdef Q_WS_MAC
     3076    // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
     3077    QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
     3078    if (mainWindow)
     3079    {
     3080        QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     3081        if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
     3082            mainWindow->setUnifiedTitleAndToolBarOnMac(true);
     3083            mainLayout->activateUnifiedToolbarAfterFullScreen = false;
     3084        }
     3085    }
     3086#endif // Q_WS_MAC
    29023087    show();
    29033088}
     
    29213106                                     | Qt::WindowMaximized
    29223107                                     | Qt::WindowFullScreen));
     3108#ifdef Q_WS_MAC
     3109    // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
     3110    QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
     3111    if (mainWindow)
     3112    {
     3113        QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     3114        if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
     3115            mainWindow->setUnifiedTitleAndToolBarOnMac(true);
     3116            mainLayout->activateUnifiedToolbarAfterFullScreen = false;
     3117        }
     3118    }
     3119#endif // Q_WS_MAC
    29233120    show();
    29243121}
     
    47334930    direction.
    47344931
     4932    This method no longer affects text layout direction since Qt 4.7.
     4933
    47354934    \sa QApplication::layoutDirection
    47364935*/
     
    47384937{
    47394938    Q_D(QWidget);
     4939
     4940    if (direction == Qt::LayoutDirectionAuto) {
     4941        unsetLayoutDirection();
     4942        return;
     4943    }
    47404944
    47414945    setAttribute(Qt::WA_SetLayoutDirection);
     
    48915095                     const QRegion &sourceRegion, RenderFlags renderFlags)
    48925096{
    4893     Q_D(QWidget);
    4894     if (!target) {
    4895         qWarning("QWidget::render: null pointer to paint device");
    4896         return;
    4897     }
    4898 
    4899     const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
    4900     QRegion paintRegion = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
    4901                                                : sourceRegion;
    4902     if (paintRegion.isEmpty())
    4903         return;
    4904 
    4905 #ifndef Q_WS_MAC
    4906     QPainter *oldSharedPainter = inRenderWithPainter ? d->sharedPainter() : 0;
    4907 
    4908     // Use the target's shared painter if set (typically set when doing
    4909     // "other->render(widget);" in the widget's paintEvent.
    4910     if (target->devType() == QInternal::Widget) {
    4911         QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func();
    4912         if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
    4913             QPainter *targetPainter = targetPrivate->sharedPainter();
    4914             if (targetPainter && targetPainter->isActive())
    4915                 d->setSharedPainter(targetPainter);
    4916         }
    4917     }
    4918 #endif
    4919 
    4920     // Use the target's redirected device if set and adjust offset and paint
    4921     // region accordingly. This is typically the case when people call render
    4922     // from the paintEvent.
    4923     QPoint offset = targetOffset;
    4924     offset -= paintRegion.boundingRect().topLeft();
    4925     QPoint redirectionOffset;
    4926     QPaintDevice *redirected = 0;
    4927 
    4928     if (target->devType() == QInternal::Widget)
    4929         redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
    4930     if (!redirected)
    4931         redirected = QPainter::redirected(target, &redirectionOffset);
    4932 
    4933     if (redirected) {
    4934         target = redirected;
    4935         offset -= redirectionOffset;
    4936     }
    4937 
    4938     if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
    4939         if (QPaintEngine *targetEngine = target->paintEngine()) {
    4940             const QRegion targetSystemClip = targetEngine->systemClip();
    4941             if (!targetSystemClip.isEmpty())
    4942                 paintRegion &= targetSystemClip.translated(-offset);
    4943         }
    4944     }
    4945 
    4946     // Set backingstore flags.
    4947     int flags = QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawInvisible;
    4948     if (renderFlags & DrawWindowBackground)
    4949         flags |= QWidgetPrivate::DrawAsRoot;
    4950 
    4951     if (renderFlags & DrawChildren)
    4952         flags |= QWidgetPrivate::DrawRecursive;
    4953     else
    4954         flags |= QWidgetPrivate::DontSubtractOpaqueChildren;
    4955 
    4956 #ifdef Q_WS_QWS
    4957     flags |= QWidgetPrivate::DontSetCompositionMode;
    4958 #endif
    4959 
    4960     if (target->devType() == QInternal::Printer) {
    4961         QPainter p(target);
    4962         d->render_helper(&p, targetOffset, paintRegion, renderFlags);
    4963         return;
    4964     }
    4965 
    4966 #ifndef Q_WS_MAC
    4967     // Render via backingstore.
    4968     d->drawWidget(target, paintRegion, offset, flags, d->sharedPainter());
    4969 
    4970     // Restore shared painter.
    4971     if (oldSharedPainter)
    4972         d->setSharedPainter(oldSharedPainter);
    4973 #else
    4974     // Render via backingstore (no shared painter).
    4975     d->drawWidget(target, paintRegion, offset, flags, 0);
    4976 #endif
     5097    d_func()->render(target, targetOffset, sourceRegion, renderFlags, false);
    49775098}
    49785099
     
    53345455            if (paintEngine) {
    53355456                setRedirected(pdev, -offset);
    5336 
     5457#ifdef Q_WS_MAC
     5458                // (Alien support) Special case for Mac when redirecting: If the paint device
     5459                // is of the Widget type we need to set WA_WState_InPaintEvent since painting
     5460                // outside the paint event is not supported on QWidgets. The attributeis
     5461                // restored further down.
     5462                if (pdev->devType() == QInternal::Widget)
     5463                    static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent);
     5464
     5465#endif
    53375466                if (sharedPainter)
    53385467                    paintEngine->d_func()->systemClip = toBePainted;
     
    53755504            //restore
    53765505            if (paintEngine) {
     5506#ifdef Q_WS_MAC
     5507                if (pdev->devType() == QInternal::Widget)
     5508                    static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false);
     5509#endif
    53775510                restoreRedirected();
    53785511                if (!sharedPainter)
     
    54185551                                , sharedPainter, backingStore);
    54195552    }
     5553}
     5554
     5555void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
     5556                            const QRegion &sourceRegion, QWidget::RenderFlags renderFlags,
     5557                            bool readyToRender)
     5558{
     5559    if (!target) {
     5560        qWarning("QWidget::render: null pointer to paint device");
     5561        return;
     5562    }
     5563
     5564    const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
     5565    QRegion paintRegion = !inRenderWithPainter && !readyToRender
     5566                          ? prepareToRender(sourceRegion, renderFlags)
     5567                          : sourceRegion;
     5568    if (paintRegion.isEmpty())
     5569        return;
     5570
     5571#ifndef Q_WS_MAC
     5572    QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
     5573
     5574    // Use the target's shared painter if set (typically set when doing
     5575    // "other->render(widget);" in the widget's paintEvent.
     5576    if (target->devType() == QInternal::Widget) {
     5577        QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func();
     5578        if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
     5579            QPainter *targetPainter = targetPrivate->sharedPainter();
     5580            if (targetPainter && targetPainter->isActive())
     5581                setSharedPainter(targetPainter);
     5582        }
     5583    }
     5584#endif
     5585
     5586    // Use the target's redirected device if set and adjust offset and paint
     5587    // region accordingly. This is typically the case when people call render
     5588    // from the paintEvent.
     5589    QPoint offset = targetOffset;
     5590    offset -= paintRegion.boundingRect().topLeft();
     5591    QPoint redirectionOffset;
     5592    QPaintDevice *redirected = 0;
     5593
     5594    if (target->devType() == QInternal::Widget)
     5595        redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
     5596    if (!redirected)
     5597        redirected = QPainter::redirected(target, &redirectionOffset);
     5598
     5599    if (redirected) {
     5600        target = redirected;
     5601        offset -= redirectionOffset;
     5602    }
     5603
     5604    if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
     5605        if (QPaintEngine *targetEngine = target->paintEngine()) {
     5606            const QRegion targetSystemClip = targetEngine->systemClip();
     5607            if (!targetSystemClip.isEmpty())
     5608                paintRegion &= targetSystemClip.translated(-offset);
     5609        }
     5610    }
     5611
     5612    // Set backingstore flags.
     5613    int flags = DrawPaintOnScreen | DrawInvisible;
     5614    if (renderFlags & QWidget::DrawWindowBackground)
     5615        flags |= DrawAsRoot;
     5616
     5617    if (renderFlags & QWidget::DrawChildren)
     5618        flags |= DrawRecursive;
     5619    else
     5620        flags |= DontSubtractOpaqueChildren;
     5621
     5622#ifdef Q_WS_QWS
     5623    flags |= DontSetCompositionMode;
     5624#endif
     5625
     5626    if (target->devType() == QInternal::Printer) {
     5627        QPainter p(target);
     5628        render_helper(&p, targetOffset, paintRegion, renderFlags);
     5629        return;
     5630    }
     5631
     5632#ifndef Q_WS_MAC
     5633    // Render via backingstore.
     5634    drawWidget(target, paintRegion, offset, flags, sharedPainter());
     5635
     5636    // Restore shared painter.
     5637    if (oldSharedPainter)
     5638        setSharedPainter(oldSharedPainter);
     5639#else
     5640    // Render via backingstore (no shared painter).
     5641    drawWidget(target, paintRegion, offset, flags, 0);
     5642#endif
    54205643}
    54215644
     
    55375760    }
    55385761
    5539 
    55405762    QRect effectRect;
    55415763
    5542     if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
     5764    if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
    55435765        effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
    5544 
    5545     } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
     5766    else if (mode == QGraphicsEffect::PadToTransparentBorder)
    55465767        effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
    5547 
    5548     } else {
     5768    else
    55495769        effectRect = sourceRect.toAlignedRect();
    5550 
    5551     }
    55525770
    55535771    if (offset)
    55545772        *offset = effectRect.topLeft();
    55555773
    5556     if (deviceCoordinates) {
    5557         // Clip to device rect.
    5558         int left, top, right, bottom;
    5559         effectRect.getCoords(&left, &top, &right, &bottom);
    5560         if (left < 0) {
    5561             if (offset)
    5562                 offset->rx() += -left;
    5563             effectRect.setX(0);
    5564         }
    5565         if (top < 0) {
    5566             if (offset)
    5567                 offset->ry() += -top;
    5568             effectRect.setY(0);
    5569         }
    5570         // NB! We use +-1 for historical reasons (see QRect documentation).
    5571         QPaintDevice *device = context->painter->device();
    5572         const int deviceWidth = device->width();
    5573         const int deviceHeight = device->height();
    5574         if (right + 1 > deviceWidth)
    5575             effectRect.setRight(deviceWidth - 1);
    5576         if (bottom + 1 > deviceHeight)
    5577             effectRect.setBottom(deviceHeight -1);
    5578     }
    5579 
    55805774    pixmapOffset -= effectRect.topLeft();
    55815775
    55825776    QPixmap pixmap(effectRect.size());
    55835777    pixmap.fill(Qt::transparent);
    5584     m_widget->render(&pixmap, pixmapOffset);
     5778    m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren);
    55855779    return pixmap;
    55865780}
     
    61866380                }
    61876381                if (!isHidden()) {
     6382#ifndef QT_NO_GRAPHICSVIEW
     6383                    // Update proxy state
     6384                    if (QWExtra *topData = window()->d_func()->extra)
     6385                        if (topData->proxyWidget && topData->proxyWidget->hasFocus())
     6386                            topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
     6387#endif
    61886388                    // Send event to self
    61896389                    QFocusEvent event(QEvent::FocusIn, reason);
     
    64656665    QWidget *fn = first->d_func()->focus_next;
    64666666
    6467     if (fn == second)
     6667    if (fn == second || first == second)
    64686668        return;
    64696669
     
    66946894QByteArray QWidget::saveGeometry() const
    66956895{
     6896#ifdef QT_MAC_USE_COCOA
     6897    // We check if the window was maximized during this invocation. If so, we need to record the
     6898    // starting position as 0,0.
     6899    Q_D(const QWidget);
     6900    QRect newFramePosition = frameGeometry();
     6901    QRect newNormalPosition = normalGeometry();
     6902    if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) {
     6903        // Change the starting position
     6904        newFramePosition.moveTo(0, 0);
     6905        newNormalPosition.moveTo(0, 0);
     6906    }
     6907#endif // QT_MAC_USE_COCOA
    66966908    QByteArray array;
    66976909    QDataStream stream(&array, QIODevice::WriteOnly);
     
    67036915           << majorVersion
    67046916           << minorVersion
     6917#ifdef QT_MAC_USE_COCOA
     6918           << newFramePosition
     6919           << newNormalPosition
     6920#else
    67056921           << frameGeometry()
    67066922           << normalGeometry()
     6923#endif // QT_MAC_USE_COCOA
    67076924           << qint32(QApplication::desktop()->screenNumber(this))
    67086925           << quint8(windowState() & Qt::WindowMaximized)
     
    72817498    bool isEmbedded = false;
    72827499#if !defined QT_NO_GRAPHICSVIEW
    7283     isEmbedded = q->isWindow() && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
     7500    isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
    72847501#else
    72857502    Q_UNUSED(isEmbedded);
     
    73187535    // hidden.
    73197536    if (wasVisible) {
    7320 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM)
     7537#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM)
    73217538        qApp->d_func()->sendSyntheticEnterLeave(q);
    73227539#endif
     
    73497566    it. It will not be automatically shown when the parent is shown.
    73507567
    7351     To check visiblity, use !isVisible() instead (notice the exclamation mark).
     7568    To check visibility, use !isVisible() instead (notice the exclamation mark).
    73527569
    73537570    isHidden() implies !isVisible(), but a widget can be not visible
     
    74507667            d->show_helper();
    74517668
    7452 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM)
     7669#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM)
    74537670            qApp->d_func()->sendSyntheticEnterLeave(this);
    74547671#endif
     
    75827799            }
    75837800        }
    7584 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM)
     7801#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM)
    75857802        qApp->d_func()->sendSyntheticEnterLeave(widget);
    75867803#endif
     
    76267843        QApplication::quit();
    76277844#endif
    7628     // Attempt to close the application only if this widget has the
    7629     // WA_QuitOnClose flag set set and has a non-visible parent
    7630     quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible() || parentWidget->testAttribute(Qt::WA_DontShowOnScreen));
     7845    // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
     7846    quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
    76317847
    76327848    if (quitOnClose) {
    7633         // If there is no non-withdrawn primary window left (except
    7634         // the ones without QuitOnClose or with WA_DontShowOnScreen),
    7635         // we emit the lastWindowClosed signal
     7849        /* if there is no non-withdrawn primary window left (except
     7850           the ones without QuitOnClose), we emit the lastWindowClosed
     7851           signal */
    76367852        QWidgetList list = QApplication::topLevelWidgets();
    76377853        bool lastWindowClosed = true;
    76387854        for (int i = 0; i < list.size(); ++i) {
    76397855            QWidget *w = list.at(i);
    7640             if ((w->isVisible() && !w->testAttribute(Qt::WA_DontShowOnScreen))
    7641                     && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) {
    7642                 lastWindowClosed = false;
    7643                 break;
    7644             }
     7856            if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
     7857                continue;
     7858            lastWindowClosed = false;
     7859            break;
    76457860        }
    76467861        if (lastWindowClosed)
     
    84848699        break;
    84858700    }
     8701#ifndef QT_NO_GESTURES
    84868702    case QEvent::Gesture:
    84878703        event->ignore();
    84888704        break;
     8705#endif
    84898706#ifndef QT_NO_PROPERTIES
    84908707    case QEvent::DynamicPropertyChange: {
     
    85138730  This event handler can be reimplemented to handle state changes.
    85148731
    8515   The state being changed in this event can be retrieved through event \a
    8516   event.
     8732  The state being changed in this event can be retrieved through the \a event
     8733  supplied.
    85178734
    85188735  Change events include: QEvent::ToolBarChange,
     
    86258842        while ((w = QApplication::activePopupWidget()) && w != this){
    86268843            w->close();
    8627             if (QApplication::activePopupWidget() == w) // widget does not want to dissappear
     8844            if (QApplication::activePopupWidget() == w) // widget does not want to disappear
    86288845                w->hide(); // hide at least
    86298846        }
     
    90789295{
    90799296#ifndef QT_NO_IM
    9080     Q_D(const QWidget);
    9081     return d->imHints;
     9297    const QWidgetPrivate *priv = d_func();
     9298    while (priv->inheritsInputMethodHints) {
     9299        priv = priv->q_func()->parentWidget()->d_func();
     9300        Q_ASSERT(priv);
     9301    }
     9302    return priv->imHints;
    90829303#else //QT_NO_IM
    90839304    return 0;
     
    90909311    Q_D(QWidget);
    90919312    d->imHints = hints;
    9092     // Optimisation to update input context only it has already been created.
     9313    // Optimization to update input context only it has already been created.
    90939314    if (d->ic || qApp->d_func()->inputContext) {
    90949315        QInputContext *ic = inputContext();
     
    96349855QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
    96359856{
     9857    if (children.isEmpty())
     9858        return 0;
     9859
     9860#ifdef Q_WS_MAC
    96369861    Q_Q(const QWidget);
    9637 #ifdef Q_WS_MAC
     9862    // Unified tool bars on the Mac require special handling since they live outside
     9863    // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8
    96389864    bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
    96399865                        && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
    9640 #endif
    9641 
    9642     if (
     9866    if (includeFrame)
     9867        return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame);
     9868#endif
     9869
     9870    if (!pointInsideRectAndMask(p))
     9871        return 0;
     9872    return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
     9873}
     9874
     9875QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const
     9876{
     9877#ifndef Q_WS_MAC
     9878    Q_UNUSED(includeFrame);
     9879#endif
     9880    for (int i = children.size() - 1; i >= 0; --i) {
     9881        QWidget *child = qobject_cast<QWidget *>(children.at(i));
     9882        if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
     9883            || (ignoreChildrenInDestructor && child->data->in_destructor)) {
     9884            continue;
     9885        }
     9886
     9887        // Map the point 'p' from parent coordinates to child coordinates.
     9888        QPoint childPoint = p;
    96439889#ifdef Q_WS_MAC
    9644             !includeFrame &&
    9645 #endif
    9646             !q->rect().contains(p))
    9647         return 0;
    9648 
    9649     for (int i = children.size(); i > 0 ;) {
    9650         --i;
    9651         QWidget *w = qobject_cast<QWidget *>(children.at(i));
    9652         if (w && !w->isWindow() && !w->isHidden()
    9653                 && (w->geometry().contains(p)
    9654 #ifdef Q_WS_MAC
    9655                     || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p)))
    9656 #endif
    9657                )) {
    9658             if (ignoreChildrenInDestructor && w->data->in_destructor)
    9659                 continue;
    9660             if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
    9661                 continue;
    9662             QPoint childPoint = w->mapFromParent(p);
    9663 #ifdef Q_WS_MAC
    9664             if (includeFrame && !w->geometry().contains(p))
    9665                 childPoint = qt_mac_nativeMapFromParent(w, p);
    9666 #endif
    9667             if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor))
    9668                 return t;
    9669             // if WMouseNoMask is set the widget mask is ignored, if
    9670             // the widget has no mask then the WMouseNoMask flag has no
    9671             // effect
    9672             if (w->testAttribute(Qt::WA_MouseNoMask) || w->mask().contains(childPoint)
    9673                 || w->mask().isEmpty())
    9674                 return w;
    9675         }
     9890        // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar.
     9891        // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal
     9892        // QWidget::mapFromParent won't do the trick.
     9893        if (includeFrame && qobject_cast<QToolBar *>(child))
     9894            childPoint = qt_mac_nativeMapFromParent(child, p);
     9895        else
     9896#endif
     9897        childPoint -= child->data->crect.topLeft();
     9898
     9899        // Check if the point hits the child.
     9900        if (!child->d_func()->pointInsideRectAndMask(childPoint))
     9901            continue;
     9902
     9903        // Do the same for the child's descendants.
     9904        if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
     9905            return w;
     9906
     9907        // We have found our target; namely the child at position 'p'.
     9908        return child;
    96769909    }
    96779910    return 0;
     
    983010063    bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
    983110064
    9832 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
     10065#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
    983310066    if (newParent && parent && !desktopWidget) {
    983410067        if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
     
    985210085        focusWidget()->clearFocus();
    985310086
     10087    QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData();
     10088    QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0;
     10089
    985410090    d->setParent_sys(parent, f);
     10091
     10092    QTLWExtra *topExtra = window()->d_func()->maybeTopData();
     10093    QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0;
     10094    if (oldBsTracker && oldBsTracker != bsTracker)
     10095        oldBsTracker->unregisterWidgetSubtree(this);
     10096
    985510097    if (desktopWidget)
    985610098        parent = 0;
     
    1031510557#endif // QT3_SUPPORT
    1031610558
    10317 /*!
    10318     Sets the attribute \a attribute on this widget if \a on is true;
    10319     otherwise clears the attribute.
    10320 
    10321     \sa testAttribute()
    10322 */
    10323 void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
    10324 {
    10325     if (testAttribute(attribute) == on)
    10326         return;
    10327 
    10328     Q_D(QWidget);
    10329     Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
    10330                "QWidget::setAttribute(WidgetAttribute, bool)",
    10331                "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
    10332 
    10333 #if defined(Q_WS_WIN) || defined(Q_WS_PM)
    10334     // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
    10335     if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
    10336         // see qwidget_[win|pm].cpp, ::paintEngine for details
    10337         paintEngine();
    10338         if (d->noPaintOnScreen)
    10339             return;
    10340     }
    10341 #endif
    10342 
     10559 /*!
     10560  \internal
     10561
     10562  This just sets the corresponding attribute bit to 1 or 0
     10563 */
     10564static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data,
     10565                                  QWidgetPrivate *d)
     10566{
    1034310567    if (attribute < int(8*sizeof(uint))) {
    1034410568        if (on)
     
    1035410578            d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
    1035510579    }
     10580}
     10581
     10582/*!
     10583    Sets the attribute \a attribute on this widget if \a on is true;
     10584    otherwise clears the attribute.
     10585
     10586    \sa testAttribute()
     10587*/
     10588void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
     10589{
     10590    if (testAttribute(attribute) == on)
     10591        return;
     10592
     10593    Q_D(QWidget);
     10594    Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
     10595               "QWidget::setAttribute(WidgetAttribute, bool)",
     10596               "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
     10597
     10598#if defined(Q_WS_WIN) || defined(Q_WS_PM)
     10599    // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
     10600    if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
     10601        // see qwidget_[win|pm].cpp, ::paintEngine for details
     10602        paintEngine();
     10603        if (d->noPaintOnScreen)
     10604            return;
     10605    }
     10606#endif
     10607
     10608    setAttribute_internal(attribute, on, data, d);
    1035610609
    1035710610    switch (attribute) {
     
    1041210665        {
    1041310666            // We can only have one of these set at a time
    10414             static const int MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
    10415                                             Qt::WA_MacMiniSize, 0 };
    10416             for (int i = 0; MacSizes[i] != 0; ++i) {
    10417                 if (MacSizes[i] == attribute)
    10418                     continue;
    10419                 int macsize_x = MacSizes[i] - 8*sizeof(uint);
    10420                 int macsize_int_off = macsize_x / (8*sizeof(uint));
    10421                 d->high_attributes[macsize_int_off] &= ~(1<<(macsize_x-(macsize_int_off*8*sizeof(uint))));
     10667            const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
     10668                                                     Qt::WA_MacMiniSize };
     10669            for (int i = 0; i < 3; ++i) {
     10670                if (MacSizes[i] != attribute)
     10671                    setAttribute_internal(MacSizes[i], false, data, d);
    1042210672            }
    1042310673            d->macUpdateSizeAttribute();
     
    1048610736    case Qt::WA_PaintOnScreen:
    1048710737        d->updateIsOpaque();
    10488 #if defined(Q_WS_WIN) || defined(Q_WS_X11)
     10738#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
    1048910739        // Recreate the widget if it's already created as an alien widget and
    1049010740        // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
     
    1054210792        d->updateIsOpaque();
    1054310793        break;
     10794    case Qt::WA_X11DoNotAcceptFocus:
     10795        if (testAttribute(Qt::WA_WState_Created))
     10796            d->updateX11AcceptFocus();
     10797        break;
    1054410798#endif
    1054510799    case Qt::WA_DontShowOnScreen: {
     
    1059710851        break;
    1059810852    case Qt::WA_AcceptTouchEvents:
    10599 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_S60)
     10853#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
    1060010854        if (on)
    1060110855            d->registerTouchWindow();
    1060210856#endif
    1060310857        break;
     10858    case Qt::WA_LockPortraitOrientation:
     10859    case Qt::WA_LockLandscapeOrientation:
     10860    case Qt::WA_AutoOrientation: {
     10861        const Qt::WidgetAttribute orientations[3] = {
     10862            Qt::WA_LockPortraitOrientation,
     10863            Qt::WA_LockLandscapeOrientation,
     10864            Qt::WA_AutoOrientation
     10865        };
     10866
     10867        if (on) {
     10868            // We can only have one of these set at a time
     10869            for (int i = 0; i < 3; ++i) {
     10870                if (orientations[i] != attribute)
     10871                    setAttribute_internal(orientations[i], false, data, d);
     10872            }
     10873        }
     10874
     10875#ifdef Q_WS_S60
     10876        CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
     10877        const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
     10878            CAknAppUiBase::EAppUiOrientationPortrait,
     10879            CAknAppUiBase::EAppUiOrientationLandscape,
     10880            CAknAppUiBase::EAppUiOrientationAutomatic
     10881        };
     10882        CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
     10883        for (int i = 0; i < 3; ++i) {
     10884            if (testAttribute(orientations[i])) {
     10885                s60orientation = s60orientations[i];
     10886                break;
     10887            }
     10888        }
     10889        QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
     10890        S60->orientationSet = true;
     10891#endif
     10892        break;
     10893    }
    1060410894    default:
    1060510895        break;
     
    1095911249#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
    1096011250    Q_D(QWidget);
    10961     // and optimisation to update input context only it has already been created.
     11251    // and optimization to update input context only it has already been created.
    1096211252    if (d->ic || qApp->d_func()->inputContext) {
    1096311253        QInputContext *ic = inputContext();
     
    1178512075    Tells us if it there is currently a reachable widget by keypad navigation in
    1178612076    a certain \a orientation.
    11787     If no navigation is possible, occuring key events in that \a orientation may
    11788     be used to interact with the value in the focussed widget, even though it
     12077    If no navigation is possible, occurring key events in that \a orientation may
     12078    be used to interact with the value in the focused widget, even though it
    1178912079    currently has not the editFocus.
    1179012080
     
    1180612096    navigation. If there is no QTabWidget, the horizontal key events can be used
    1180712097to
    11808     interact with the value in the focussed widget, even though it currently has
     12098    interact with the value in the focused widget, even though it currently has
    1180912099    not the editFocus.
    1181012100
     
    1200612296*/
    1200712297
     12298#ifndef QT_NO_GESTURES
    1200812299/*!
    1200912300    Subscribes the widget to a given \a gesture with specific \a flags.
     
    1202912320    Q_D(QWidget);
    1203012321    if (d->gestureContext.remove(gesture)) {
    12031         QGestureManager *manager = QGestureManager::instance();
    12032         manager->cleanupCachedGestures(this, gesture);
    12033     }
    12034 }
    12035 
     12322        if (QGestureManager *manager = QGestureManager::instance())
     12323            manager->cleanupCachedGestures(this, gesture);
     12324    }
     12325}
     12326#endif // QT_NO_GESTURES
    1203612327
    1203712328/*!
     
    1235712648#endif
    1235812649
     12650#if QT_MAC_USE_COCOA
     12651void QWidgetPrivate::syncUnifiedMode() {
     12652    // The whole purpose of this method is to keep the unifiedToolbar in sync.
     12653    // That means making sure we either exchange the drawing methods or we let
     12654    // the toolbar know that it does not require to draw the baseline.
     12655    Q_Q(QWidget);
     12656    // This function makes sense only if this is a top level
     12657    if(!q->isWindow())
     12658        return;
     12659    OSWindowRef window = qt_mac_window_for(q);
     12660    if(changeMethods) {
     12661        // Ok, we are in documentMode.
     12662        if(originalDrawMethod)
     12663            qt_mac_replaceDrawRect(window, this);
     12664    } else {
     12665        if(!originalDrawMethod)
     12666            qt_mac_replaceDrawRectOriginal(window, this);
     12667    }
     12668}
     12669
     12670#endif // QT_MAC_USE_COCOA
     12671
    1235912672QT_END_NAMESPACE
    1236012673
Note: See TracChangeset for help on using the changeset viewer.