Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qwidget_p.h

    r309 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5858#include "QtCore/qrect.h"
    5959#include "QtCore/qlocale.h"
     60#include "QtCore/qset.h"
    6061#include "QtGui/qregion.h"
    6162#include "QtGui/qsizepolicy.h"
    6263#include "QtGui/qstyle.h"
     64#include "QtGui/qapplication.h"
     65#include <private/qgraphicseffect_p.h>
     66#include "QtGui/qgraphicsproxywidget.h"
     67#include "QtGui/qgraphicsscene.h"
     68#include "QtGui/qgraphicsview.h"
     69#include <private/qgesture_p.h>
    6370
    6471#ifdef Q_WS_WIN
     
    8289#include "QtGui/qinputcontext.h"
    8390#include "QtGui/qscreen_qws.h"
     91#endif
     92
     93#if defined(Q_OS_SYMBIAN)
     94class RDrawableWindow;
     95class CCoeControl;
    8496#endif
    8597
     
    104116
    105117struct QTLWExtra {
     118    // *************************** Cross-platform variables *****************************
     119
     120    // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
     121    QIcon *icon; // widget icon
     122    QPixmap *iconPixmap;
     123    QWidgetBackingStore *backingStore;
     124    QWindowSurface *windowSurface;
     125    QPainter *sharedPainter;
     126
     127    // Implicit pointers (shared_null).
    106128    QString caption; // widget caption
    107129    QString iconText; // widget icon text
    108130    QString role; // widget role
    109131    QString filePath; // widget file path
    110     QIcon *icon; // widget icon
    111     QPixmap *iconPixmap;
     132
     133    // Other variables.
    112134    short incw, inch; // size increments
     135    short basew, baseh; // base sizes
    113136     // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
    114137    QRect frameStrut;
     138    QRect normalGeometry; // used by showMin/maximized/FullScreen
     139    Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
     140
     141    // *************************** Cross-platform bit fields ****************************
    115142    uint opacity : 8;
    116143    uint posFromMove : 1;
     
    118145    uint inTopLevelResize : 1;
    119146    uint inRepaint : 1;
    120     QWidgetBackingStore *backingStore;
    121 #if defined(Q_WS_WIN)
    122     ulong savedFlags; // Save window flags while showing fullscreen
    123     uint embedded : 1; // window is embedded in another application
    124 #else
    125     Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
    126 #endif
    127     short basew, baseh; // base sizes
    128 #if defined(Q_WS_X11)
    129     WId parentWinId; // parent window Id (valid after reparenting)
    130     uint embedded : 1; // window is embedded in another Qt application
     147    uint embedded : 1;
     148
     149    // *************************** Platform specific values (bit fields first) **********
     150#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
    131151    uint spont_unmapped: 1; // window was spontaneously unmapped
    132152    uint dnd : 1; // DND properties installed
    133153    uint validWMState : 1; // is WM_STATE valid?
    134154    uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
     155    WId parentWinId; // parent window Id (valid after reparenting)
    135156    WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
    136157    QPoint fullScreenOffset;
    137 #endif
    138 #if defined(Q_WS_MAC)
     158#ifndef QT_NO_XSYNC
     159    WId syncUpdateCounter;
     160    ulong syncRequestTimestamp;
     161    qint32 newCounterValueHi;
     162    quint32 newCounterValueLo;
     163#endif
     164#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
     165    HICON winIconBig; // internal big Windows icon
     166    HICON winIconSmall; // internal small Windows icon
     167#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
     168    uint resizer : 4;
     169    uint isSetGeometry : 1;
     170    uint isMove : 1;
    139171    quint32 wattr;
    140172    quint32 wclass;
     
    142174    IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
    143175    quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
    144     uint resizer : 4;
    145     uint isSetGeometry : 1;
    146     uint isMove : 1;
    147     uint embedded : 1;
    148 #endif
    149 #if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER)
     176#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
     177#ifndef QT_NO_QWS_MANAGER
    150178    QWSManager *qwsManager;
    151179#endif
    152 #if defined(Q_WS_WIN)
    153     HICON winIconBig; // internal big Windows icon
    154     HICON winIconSmall; // internal small Windows icon
    155 #endif
    156 #if defined(Q_WS_PM)
     180#elif defined(Q_WS_PM)
    157181    HWND fId;
    158182    HSWITCH swEntry;
    159183    HPOINTER iconPointer;
    160184#endif
    161     QRect normalGeometry; // used by showMin/maximized/FullScreen
    162     QWindowSurface *windowSurface;
    163     QPainter *sharedPainter;
    164185};
    165186
    166187struct QWExtra {
    167     qint32 minw, minh; // minimum size
    168     qint32 maxw, maxh; // maximum size
    169     QPointer<QWidget> focus_proxy;
     188    // *************************** Cross-platform variables *****************************
     189
     190    // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
     191    void *glContext; // if the widget is hijacked by QGLWindowSurface
     192    QTLWExtra *topextra; // only useful for TLWs
     193#ifndef QT_NO_GRAPHICSVIEW
     194    QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
     195#endif
    170196#ifndef QT_NO_CURSOR
    171197    QCursor *curs;
    172198#endif
    173     QTLWExtra *topextra; // only useful for TLWs
    174     QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
    175     void *glContext; // if the widget is hijacked by QGLWindowSurface
    176 #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
    177     QOleDropTarget *dropTarget; // drop target
    178     QList<QPointer<QWidget> > oleDropWidgets;
    179 #endif
    180 #if defined(Q_WS_X11)
    181     WId xDndProxy; // XDND forwarding to embedded windows
    182 #endif
     199    QPointer<QStyle> style;
     200    QPointer<QWidget> focus_proxy;
     201
     202    // Implicit pointers (shared_empty/shared_null).
    183203    QRegion mask; // widget mask
     204    QString styleSheet;
     205
     206    // Other variables.
     207    qint32 minw;
     208    qint32 minh; // minimum size
     209    qint32 maxw;
     210    qint32 maxh; // maximum size
     211    quint16 customDpiX;
     212    quint16 customDpiY;
    184213    QSize staticContentsSize;
    185214
    186 //bit flags at the end to improve packing
    187 #if defined(Q_WS_WIN)
    188     uint shown_mode : 8; // widget show mode
    189 #ifndef QT_NO_DIRECT3D
    190     uint had_paint_on_screen : 1;
    191     uint had_no_system_bg : 1;
    192     uint had_auto_fill_bg : 1;
    193 #endif
    194 #endif
    195 #if defined(Q_WS_X11)
    196     uint compress_events : 1;
    197 #endif
     215    // *************************** Cross-platform bit fields ****************************
    198216    uint explicitMinSize : 2;
    199217    uint explicitMaxSize : 2;
     
    203221    uint hasMask : 1;
    204222
    205     QPointer<QStyle> style;
    206     QString styleSheet;
    207 
    208     quint16 customDpiX;
    209     quint16 customDpiY;
    210 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
     223    // *************************** Platform specific values (bit fields first) **********
     224#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
     225#ifndef QT_NO_DRAGANDDROP
     226    QOleDropTarget *dropTarget; // drop target
     227    QList<QPointer<QWidget> > oleDropWidgets;
     228#endif
     229#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
     230    uint compress_events : 1;
     231    WId xDndProxy; // XDND forwarding to embedded windows
     232#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
     233#ifdef QT_MAC_USE_COCOA
    211234    // Cocoa Mask stuff
    212235    QImage maskBits;
    213236    CGImageRef imageMask;
    214237#endif
     238#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
     239    uint activated : 1; // RWindowBase::Activated has been called
     240
     241    /**
     242     * Defines the behaviour of QSymbianControl::Draw.
     243     */
     244    enum NativePaintMode {
     245        /**
     246         * Normal drawing mode: blits the required region of the backing store
     247         * via WSERV.
     248         */
     249        Blit,
     250
     251        /**
     252         * Disable drawing for this widget.
     253         */
     254        Disable,
     255
     256        /**
     257         * Paint zeros into the WSERV framebuffer, using BitGDI APIs.  For windows
     258         * with an EColor16MU display mode, zero is written only into the R, G and B
     259         * channels of the pixel.
     260         */
     261        ZeroFill,
     262
     263        Default = Blit
     264    };
     265
     266    NativePaintMode nativePaintMode : 2;
     267
     268    /**
     269     * If this bit is set, each native widget receives the signals from the
     270     * Symbian control immediately before and immediately after draw ops are
     271     * sent to the window server for this control:
     272     *      void beginNativePaintEvent(const QRect &paintRect);
     273     *      void endNativePaintEvent(const QRect &paintRect);
     274     */
     275    uint receiveNativePaintEvents : 1;
     276
     277#endif
    215278};
     279
     280/*!
     281    \internal
     282
     283    Returns true if \a p or any of its parents enable the
     284    Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
     285    QWidget::setParent() to determine whether it's necessary to embed the
     286    widget into a QGraphicsProxyWidget or not.
     287*/
     288static inline bool bypassGraphicsProxyWidget(const QWidget *p)
     289{
     290    while (p) {
     291        if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
     292            return true;
     293        p = p->parentWidget();
     294    }
     295    return false;
     296}
    216297
    217298class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
     
    220301
    221302public:
     303    // *************************** Cross-platform ***************************************
     304    enum DrawWidgetFlags {
     305        DrawAsRoot = 0x01,
     306        DrawPaintOnScreen = 0x02,
     307        DrawRecursive = 0x04,
     308        DrawInvisible = 0x08,
     309        DontSubtractOpaqueChildren = 0x10,
     310        DontSetCompositionMode = 0x20,
     311        DontDrawOpaqueChildren = 0x40
     312    };
     313
     314    enum CloseMode {
     315        CloseNoEvent,
     316        CloseWithEvent,
     317        CloseWithSpontaneousEvent
     318    };
     319
     320    enum Direction {
     321        DirectionNorth = 0x01,
     322        DirectionEast = 0x10,
     323        DirectionSouth = 0x02,
     324        DirectionWest = 0x20
     325    };
     326
     327    // Functions.
    222328    explicit QWidgetPrivate(int version = QObjectPrivateVersion);
    223329    ~QWidgetPrivate();
     
    229335    void setSharedPainter(QPainter *painter);
    230336    QWidgetBackingStore *maybeBackingStore() const;
    231 #ifdef Q_WS_QWS
    232     void setMaxWindowState_helper();
    233     void setFullScreenSize_helper();
    234 #endif
    235337    void init(QWidget *desktopWidget, Qt::WindowFlags f);
    236338    void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
     
    253355
    254356    void setMask_sys(const QRegion &);
    255 #ifdef Q_WS_WIN
    256     bool shouldShowMaximizeButton();
    257     void winUpdateIsOpaque();
    258 #endif
    259 
    260 #ifdef Q_WS_MAC
    261     void macUpdateSizeAttribute();
    262     void macUpdateHideOnSuspend();
    263     void macUpdateOpaqueSizeGrip();
    264     void macUpdateIgnoreMouseEvents();
    265     void macUpdateMetalAttribute();
    266     void macUpdateIsOpaque();
    267     void setEnabled_helper_sys(bool enable);
    268     bool isRealWindow() const;
     357#ifdef Q_OS_SYMBIAN
     358    void setSoftKeys_sys(const QList<QAction*> &softkeys);
     359    void activateSymbianWindow(WId wid = 0);
     360    void _q_delayedDestroy(WId winId);
    269361#endif
    270362
     
    293385    void inheritStyle();
    294386
    295     bool isBackgroundInherited() const;
    296 
    297387    void setUpdatesEnabled_helper(bool );
    298388
    299     void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const;
    300     enum DrawWidgetFlags {
    301         DrawAsRoot = 0x01,
    302         DrawPaintOnScreen = 0x02,
    303         DrawRecursive = 0x04,
    304         DrawInvisible = 0x08,
    305         DontSubtractOpaqueChildren = 0x10,
    306         DontSetCompositionMode = 0x20,
    307         DontDrawOpaqueChildren = 0x40
    308     };
     389    void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
    309390    bool isAboutToShow() const;
    310391    QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
     
    325406    QPainter *beginSharedPainter();
    326407    bool endSharedPainter();
    327     static QGraphicsProxyWidget * nearestGraphicsProxyWidget(QWidget *origin);
     408#ifndef QT_NO_GRAPHICSVIEW
     409    static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
     410#endif
    328411    QWindowSurface *createDefaultWindowSurface();
    329412    QWindowSurface *createDefaultWindowSurface_sys();
    330413    void repaint_sys(const QRegion &rgn);
    331 #ifdef Q_WS_MAC
    332     void update_sys(const QRect &rect);
    333     void update_sys(const QRegion &rgn);
    334 #endif
    335414
    336415    QRect clipRect() const;
     
    343422    void setOpaque(bool opaque);
    344423    void updateIsTranslucent();
    345     bool hasBackground() const;
    346424    bool paintOnScreen() const;
    347 
    348     QRegion getOpaqueRegion() const;
     425#ifndef QT_NO_GRAPHICSEFFECT
     426    void invalidateGraphicsEffectsRecursively();
     427#endif //QT_NO_GRAPHICSEFFECT
     428
    349429    const QRegion &getOpaqueChildren() const;
    350430    void setDirtyOpaqueRegion();
    351431
    352     QRegion opaqueChildren;
    353 
    354     enum CloseMode {
    355         CloseNoEvent,
    356         CloseWithEvent,
    357         CloseWithSpontaneousEvent
    358     };
    359432    bool close_helper(CloseMode mode);
    360433
    361     bool compositeEvent(QEvent *e);
    362434    void setWindowIcon_helper();
    363435    void setWindowIcon_sys(bool forceReset = false);
    364436    void setWindowOpacity_sys(qreal opacity);
    365 
    366437    void adjustQuitOnCloseAttribute();
    367438
    368 #if defined(Q_WS_X11)
    369     void setWindowRole();
    370     void sendStartupMessage(const char *message) const;
    371     void setNetWmWindowTypes();
    372     void x11UpdateIsOpaque();
    373 #endif
    374 
    375 #if defined(Q_WS_WIN) || defined(Q_WS_PM)
    376     void reparentChildren();
    377 #endif
    378 
    379439    void scrollChildren(int dx, int dy);
    380 
    381440    void moveRect(const QRect &, int dx, int dy);
    382441    void scrollRect(const QRect &, int dx, int dy);
     
    392451
    393452    static int pointToRect(const QPoint &p, const QRect &r);
    394     QRect fromOrToLayoutItemRect(const QRect &rect, int sign) const;
    395453
    396454    void setWinId(WId);
     
    402460    void deactivateWidgetCleanup();
    403461    void setGeometry_sys(int, int, int, int, bool);
    404 #ifdef Q_WS_MAC
    405     void setGeometry_sys_helper(int, int, int, int, bool);
    406 #endif
    407462    void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
    408463    void activateChildLayoutsRecursively();
     
    416471    void setEnabled_helper(bool);
    417472    void registerDropSite(bool);
    418 #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
    419     QOleDropTarget *registerOleDnd(QWidget *widget);
    420     void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
    421 #endif
    422473    static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
    423474
    424475    void updateFrameStrut();
    425476    QRect frameStrut() const;
     477
     478#ifdef QT_KEYPAD_NAVIGATION
     479    static bool navigateToDirection(Direction direction);
     480    static QWidget *widgetInNavigationDirection(Direction direction);
     481#endif
    426482
    427483    void setWindowIconText_sys(const QString &cap);
     
    429485    void setWindowTitle_sys(const QString &cap);
    430486
    431 #ifdef Q_OS_WIN
    432     void grabMouseWhileInWindow();
    433 #endif
    434 
    435487#ifndef QT_NO_CURSOR
    436488    void setCursor_sys(const QCursor &cursor);
     
    438490#endif
    439491
    440 #ifdef Q_WS_MAC
     492    void setWindowTitle_helper(const QString &cap);
     493    void setWindowFilePath_helper(const QString &filePath);
     494
     495    bool setMinimumSize_helper(int &minw, int &minh);
     496    bool setMaximumSize_helper(int &maxw, int &maxh);
     497    void setConstraints_sys();
     498    QWidget *childAt_helper(const QPoint &, bool) const;
     499    void updateGeometry_helper(bool forceUpdate);
     500
     501    void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
     502    void setLayoutItemMargins(int left, int top, int right, int bottom);
     503    void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
     504
     505    QInputContext *inputContext() const;
     506    inline QWidget *effectiveFocusWidget() {
     507        QWidget *w = q_func();
     508        while (w->focusProxy())
     509            w = w->focusProxy();
     510        return w;
     511    }
     512
     513    void setModal_sys();
     514
     515    // This is an helper function that return the available geometry for
     516    // a widget and takes care is this one is in QGraphicsView.
     517    // If the widget is not embed in a scene then the geometry available is
     518    // null, we let QDesktopWidget decide for us.
     519    static QRect screenGeometry(const QWidget *widget)
     520    {
     521        QRect screen;
     522#ifndef QT_NO_GRAPHICSVIEW
     523        QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
     524        //It's embedded if it has an ancestor
     525        if (ancestorProxy) {
     526            if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
     527                // One view, let be smart and return the viewport rect then the popup is aligned
     528                if (ancestorProxy->scene()->views().size() == 1) {
     529                    QGraphicsView *view = ancestorProxy->scene()->views().at(0);
     530                    screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
     531                } else {
     532                    screen = ancestorProxy->scene()->sceneRect().toRect();
     533                }
     534            }
     535        }
     536#endif
     537        return screen;
     538    }
     539
     540    inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
     541    {
     542        Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
     543        redirectDev = replacement;
     544        redirectOffset = offset;
     545    }
     546
     547    inline QPaintDevice *redirected(QPoint *offset) const
     548    {
     549        if (offset)
     550            *offset = redirectDev ? redirectOffset : QPoint();
     551        return redirectDev;
     552    }
     553
     554    inline void restoreRedirected()
     555    { redirectDev = 0; }
     556
     557    inline void enforceNativeChildren()
     558    {
     559        if (!extra)
     560            createExtra();
     561
     562        if (extra->nativeChildrenForced)
     563            return;
     564        extra->nativeChildrenForced = 1;
     565
     566        for (int i = 0; i < children.size(); ++i) {
     567            if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
     568                child->setAttribute(Qt::WA_NativeWindow);
     569        }
     570    }
     571
     572    inline bool nativeChildrenForced() const
     573    {
     574        return extra ? extra->nativeChildrenForced : false;
     575    }
     576
     577    inline QRect effectiveRectFor(const QRect &rect) const
     578    {
     579#ifndef QT_NO_GRAPHICSEFFECT
     580        if (graphicsEffect && graphicsEffect->isEnabled())
     581            return graphicsEffect->boundingRectFor(rect).toAlignedRect();
     582#endif //QT_NO_GRAPHICSEFFECT
     583        return rect;
     584    }
     585
     586    QSize adjustedSize() const;
     587
     588    inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
     589    {
     590        Q_Q(QWidget);
     591        if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
     592            QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
     593                    q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
     594            if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
     595                QEvent event(QEvent::RequestSoftwareInputPanel);
     596                QApplication::sendEvent(q, &event);
     597            }
     598        }
     599    }
     600
     601#ifndef Q_WS_QWS // Almost cross-platform :-)
     602    void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
     603
     604    inline QPoint mapToWS(const QPoint &p) const
     605    { return p - data.wrect.topLeft(); }
     606
     607    inline QPoint mapFromWS(const QPoint &p) const
     608    { return p + data.wrect.topLeft(); }
     609
     610    inline QRect mapToWS(const QRect &r) const
     611    { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
     612
     613    inline QRect mapFromWS(const QRect &r) const
     614    { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
     615#endif
     616
     617    // Variables.
     618    // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
     619    QWExtra *extra;
     620    QWidget *focus_next;
     621    QWidget *focus_prev;
     622    QWidget *focus_child;
     623    QLayout *layout;
     624    QRegion *needsFlush;
     625    QPaintDevice *redirectDev;
     626    QWidgetItemV2 *widgetItem;
     627    QPaintEngine *extraPaintEngine;
     628    mutable const QMetaObject *polished;
     629    QGraphicsEffect *graphicsEffect;
     630    // All widgets are added into the allWidgets set. Once
     631    // they receive a window id they are also added to the mapper.
     632    // This should just ensure that all widgets are deleted by QApplication
     633    static QWidgetMapper *mapper;
     634    static QWidgetSet *allWidgets;
     635#if !defined(QT_NO_IM)
     636    QPointer<QInputContext> ic;
     637    Qt::InputMethodHints imHints;
     638#endif
     639#ifdef QT_KEYPAD_NAVIGATION
     640    static QPointer<QWidget> editingWidget;
     641#endif
     642
     643    // Implicit pointers (shared_null/shared_empty).
     644    QRegion opaqueChildren;
     645    QRegion dirty;
     646#ifndef QT_NO_TOOLTIP
     647    QString toolTip;
     648#endif
     649#ifndef QT_NO_STATUSTIP
     650    QString statusTip;
     651#endif
     652#ifndef QT_NO_WHATSTHIS
     653    QString whatsThis;
     654#endif
     655#ifndef QT_NO_ACCESSIBILITY
     656    QString accessibleName;
     657    QString accessibleDescription;
     658#endif
     659
     660    // Other variables.
     661    uint inheritedFontResolveMask;
     662    uint inheritedPaletteResolveMask;
     663    short leftmargin;
     664    short topmargin;
     665    short rightmargin;
     666    short bottommargin;
     667    signed char leftLayoutItemMargin;
     668    signed char topLayoutItemMargin;
     669    signed char rightLayoutItemMargin;
     670    signed char bottomLayoutItemMargin;
     671    static int instanceCounter; // Current number of widget instances
     672    static int maxInstances; // Maximum number of widget instances
     673    Qt::HANDLE hd;
     674    QWidgetData data;
     675    QSizePolicy size_policy;
     676    QLocale locale;
     677    QPoint redirectOffset;
     678#ifndef QT_NO_ACTION
     679    QList<QAction*> actions;
     680#endif
     681    QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
     682
     683    // Bit fields.
     684    uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
     685    QPalette::ColorRole fg_role : 8;
     686    QPalette::ColorRole bg_role : 8;
     687    uint dirtyOpaqueChildren : 1;
     688    uint isOpaque : 1;
     689    uint inDirtyList : 1;
     690    uint isScrolled : 1;
     691    uint isMoved : 1;
     692    uint usesDoubleBufferedGLContext : 1;
     693
     694    // *************************** Platform specific ************************************
     695#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
     696    QX11Info xinfo;
     697    Qt::HANDLE picture;
     698    static QWidget *mouseGrabber;
     699    static QWidget *keyboardGrabber;
     700
     701    void setWindowRole();
     702    void sendStartupMessage(const char *message) const;
     703    void setNetWmWindowTypes();
     704    void x11UpdateIsOpaque();
     705    bool isBackgroundInherited() const;
     706#elif defined(Q_WS_PM) // <----------------------------------------------------------- PM
     707    uint noPaintOnScreen : 1; // see qwidget_pm.cpp ::paintEngine()
     708
     709    HWND frameWinId() const
     710    { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
     711             maybeTopData()->fId : data.winid; }
     712    HWND effectiveFrameWinId() const;
     713    void validateObstacles();
     714#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
     715    uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
     716    uint nativeGesturePanEnabled : 1;
     717
     718    bool shouldShowMaximizeButton();
     719    void winUpdateIsOpaque();
     720    void reparentChildren();
     721#ifndef QT_NO_DRAGANDDROP
     722    QOleDropTarget *registerOleDnd(QWidget *widget);
     723    void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
     724#endif
     725    void grabMouseWhileInWindow();
     726    void registerTouchWindow();
     727    void winSetupGestures();
     728#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
     729    // This is new stuff
     730    uint needWindowChange : 1;
     731    uint isGLWidget : 1;
     732
     733    // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
     734    // This list is used to update the gl context whenever a parent and a granparent
     735    // moves, and also to check for intersections with gl widgets within the window
     736    // when a widget moves.
     737    struct GlWidgetInfo
     738    {
     739        GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
     740        bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
     741        QWidget * widget;
     742        QWidget * lastUpdateWidget;
     743    };
     744
     745    // dirtyOnWidget contains the areas in the widget that needs to be repained,
     746    // in the same way as dirtyOnScreen does for the window. Areas are added in
     747    // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
     748    // this information repaint invalid areas when widgets are scrolled.
     749    QRegion dirtyOnWidget;
     750    EventHandlerRef window_event;
     751    QList<GlWidgetInfo> glWidgets;
     752
     753    //these are here just for code compat (HIViews)
     754    Qt::HANDLE qd_hd;
     755
     756    void macUpdateSizeAttribute();
     757    void macUpdateHideOnSuspend();
     758    void macUpdateOpaqueSizeGrip();
     759    void macUpdateIgnoreMouseEvents();
     760    void macUpdateMetalAttribute();
     761    void macUpdateIsOpaque();
     762    void setEnabled_helper_sys(bool enable);
     763    bool isRealWindow() const;
     764    void adjustWithinMaxAndMinSize(int &w, int &h);
     765    void applyMaxAndMinSizeOnWindow();
     766    void update_sys(const QRect &rect);
     767    void update_sys(const QRegion &rgn);
     768    void setGeometry_sys_helper(int, int, int, int, bool);
    441769    void setWindowModified_sys(bool b);
    442770    void updateMaximizeButton_sys();
     
    454782    void determineWindowClass();
    455783    void transferChildren();
    456 #endif
    457     void setWindowTitle_helper(const QString &cap);
    458     void setWindowFilePath_helper(const QString &filePath);
    459 
    460     bool setMinimumSize_helper(int &minw, int &minh);
    461     bool setMaximumSize_helper(int &maxw, int &maxh);
    462     void setConstraints_sys();
    463     QWidget *childAt_helper(const QPoint &, bool) const;
    464     void updateGeometry_helper(bool forceUpdate);
    465 
    466     void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
    467     void setLayoutItemMargins(int left, int top, int right, int bottom);
    468     void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
    469 
    470     QInputContext *inputContext() const;
    471 
    472 #if defined(Q_WS_PM)
    473     HWND frameWinId() const
    474     { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
    475              maybeTopData()->fId : data.winid; }
    476     HWND effectiveFrameWinId() const;
    477 #endif
    478 
    479 #if defined(Q_WS_QWS)
    480     void moveSurface(QWindowSurface *surface, const QPoint &offset);
    481 
    482     QRegion localRequestedRegion() const;
    483     QRegion localAllocatedRegion() const;
    484 
    485     void blitToScreen(const QRegion &globalrgn);
    486 #ifndef QT_NO_CURSOR
    487     void updateCursor() const;
    488 #endif
    489 
    490     QScreen* getScreen() const;
    491 
    492     friend class QWSManager;
    493     friend class QWSManagerPrivate;
    494     friend class QDecoration;
    495 #endif
    496 
    497     static int instanceCounter; // Current number of widget instances
    498     static int maxInstances; // Maximum number of widget instances
    499 
    500 #ifdef QT_KEYPAD_NAVIGATION
    501     static QPointer<QWidget> editingWidget;
    502 #endif
    503 
    504     QWidgetData data;
    505 
    506     QWExtra *extra;
    507     QWidget *focus_next;
    508     QWidget *focus_prev;
    509     QWidget *focus_child;
    510 #ifndef QT_NO_ACTION
    511     QList<QAction*> actions;
    512 #endif
    513     QLayout *layout;
    514     QWidgetItemV2 *widgetItem;
    515 #if !defined(QT_NO_IM)
    516     QPointer<QInputContext> ic;
    517 #endif
    518     // All widgets are initially added into the uncreatedWidgets set. Once
    519     // they receive a window id they are removed and added to the mapper
    520     static QWidgetMapper *mapper;
    521     static QWidgetSet *uncreatedWidgets;
    522 
    523     short leftmargin, topmargin, rightmargin, bottommargin;
    524 
    525     signed char leftLayoutItemMargin;
    526     signed char topLayoutItemMargin;
    527     signed char rightLayoutItemMargin;
    528     signed char bottomLayoutItemMargin;
    529 
    530     // ### TODO: reorganize private/extra/topextra to save memory
    531     QPointer<QWidget> compositeChildGrab;
    532 #ifndef QT_NO_TOOLTIP
    533     QString toolTip;
    534 #endif
    535 #ifndef QT_NO_STATUSTIP
    536     QString statusTip;
    537 #endif
    538 #ifndef QT_NO_WHATSTHIS
    539     QString whatsThis;
    540 #endif
    541     QString accessibleName, accessibleDescription;
    542 
    543     QPalette::ColorRole fg_role : 8;
    544     QPalette::ColorRole bg_role : 8;
    545     uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
    546     Qt::HANDLE hd;
    547     QRegion dirty;
    548     QRegion *needsFlush;
    549     uint dirtyOpaqueChildren : 1;
    550     uint isOpaque : 1;
    551     uint inDirtyList : 1;
    552     uint isScrolled : 1;
    553     uint isMoved : 1;
    554 
    555 #if defined(Q_WS_WIN) || defined(Q_WS_PM)
    556     uint noPaintOnScreen : 1; // see qwidget_[win|pm].cpp ::paintEngine()
    557 #endif
    558 
    559     uint inheritedFontResolveMask;
    560     uint inheritedPaletteResolveMask;
    561 #if defined(Q_WS_X11)
    562     QX11Info xinfo;
    563     Qt::HANDLE picture;
    564 #endif
    565 #if defined(Q_WS_MAC)
    566     enum PaintChildrenOPs {
    567         PC_None = 0x00,
    568         PC_Now = 0x01,
    569         PC_NoPaint = 0x04,
    570         PC_Later = 0x10
    571     };
    572     EventHandlerRef window_event;
    573784    bool qt_mac_dnd_event(uint, DragRef);
    574785    void toggleDrawers(bool);
     
    576787    static bool qt_create_root_win();
    577788    static void qt_clean_root_win();
    578     static bool qt_recreate_root_win();
    579789    static bool qt_mac_update_sizer(QWidget *, int up = 0);
    580790    static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
    581791    static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
    582792    static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
    583     static bool qt_widget_shape(QWidget *, short, HIMutableShapeRef, bool);
    584 
    585     // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
    586     // This list is used to update the gl context whenever a parent and a granparent
    587     // moves, and also to check for intersections with gl widgets within the window
    588     // when a widget moves.
    589     struct GlWidgetInfo
    590     {
    591         GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
    592         bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
    593         QWidget * widget;
    594         QWidget * lastUpdateWidget;
    595     };
    596     QList<GlWidgetInfo> glWidgets;
    597 
    598     // dirtyOnWidget contains the areas in the widget that needs to be repained,
    599     // in the same way as dirtyOnScreen does for the window. Areas are added in
    600     // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
    601     // this information repaint invalid areas when widgets are scrolled.
    602     QRegion dirtyOnWidget;
    603 
    604     //these are here just for code compat (HIViews)
    605     Qt::HANDLE qd_hd;
    606 
    607     // This is new stuff
    608     uint needWindowChange : 1;
    609     uint isGLWidget : 1;
    610 #endif
    611 
    612 #if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined (Q_WS_PM) || defined(Q_WS_MAC)
    613 #ifdef Q_WS_MAC
    614     void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
    615 #else
    616     void setWSGeometry(bool dontShow=false);
    617 #endif
    618 
    619     inline QPoint mapToWS(const QPoint &p) const
    620     { return p - data.wrect.topLeft(); }
    621 
    622     inline QPoint mapFromWS(const QPoint &p) const
    623     { return p + data.wrect.topLeft(); }
    624 
    625     inline QRect mapToWS(const QRect &r) const
    626     { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
    627 
    628     inline QRect mapFromWS(const QRect &r) const
    629     { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
    630 #endif
    631 
    632     QPaintEngine *extraPaintEngine;
    633 
    634     mutable const QMetaObject *polished;
    635 
    636     void setModal_sys();
    637 
    638 #ifdef Q_WS_PM
    639     void validateObstacles();
    640 #endif
    641 
    642     QSizePolicy size_policy;
    643     QLocale locale;
    644 
    645 #ifdef Q_WS_X11
     793    void registerTouchWindow();
     794#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
     795    void setMaxWindowState_helper();
     796    void setFullScreenSize_helper();
     797    void moveSurface(QWindowSurface *surface, const QPoint &offset);
     798    QRegion localRequestedRegion() const;
     799    QRegion localAllocatedRegion() const;
     800
     801    friend class QWSManager;
     802    friend class QWSManagerPrivate;
     803    friend class QDecoration;
     804#ifndef QT_NO_CURSOR
     805    void updateCursor() const;
     806#endif
     807    QScreen* getScreen() const;
     808#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
    646809    static QWidget *mouseGrabber;
    647810    static QWidget *keyboardGrabber;
    648 #endif
    649     QPaintDevice *redirectDev;
    650     QPoint redirectOffset;
    651 
    652     inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
     811    void s60UpdateIsOpaque();
     812    void reparentChildren();
     813    void registerTouchWindow();
     814#endif
     815
     816};
     817
     818struct QWidgetPaintContext
     819{
     820    inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
     821                               QPainter *p, QWidgetBackingStore *b)
     822        : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
     823
     824    QPaintDevice *pdev;
     825    QRegion rgn;
     826    QPoint offset;
     827    int flags;
     828    QPainter *sharedPainter;
     829    QWidgetBackingStore *backingStore;
     830    QPainter *painter;
     831};
     832
     833#ifndef QT_NO_GRAPHICSEFFECT
     834class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
     835{
     836public:
     837    QWidgetEffectSourcePrivate(QWidget *widget)
     838        : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
     839    {}
     840
     841    inline void detach()
     842    { m_widget->d_func()->graphicsEffect = 0; }
     843
     844    inline const QGraphicsItem *graphicsItem() const
     845    { return 0; }
     846
     847    inline const QWidget *widget() const
     848    { return m_widget; }
     849
     850    inline void update()
    653851    {
    654         Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
    655         redirectDev = replacement;
    656         redirectOffset = offset;
    657     }
    658 
    659     inline QPaintDevice *redirected(QPoint *offset) const
     852        updateDueToGraphicsEffect = true;
     853        m_widget->update();
     854        updateDueToGraphicsEffect = false;
     855    }
     856
     857    inline bool isPixmap() const
     858    { return false; }
     859
     860    inline void effectBoundingRectChanged()
    660861    {
    661         if (offset)
    662             *offset = redirectDev ? redirectOffset : QPoint();
    663         return redirectDev;
    664     }
    665 
    666     inline void restoreRedirected()
    667     { redirectDev = 0; }
    668 
    669     inline void enforceNativeChildren()
    670     {
    671         if (!extra)
    672             createExtra();
    673 
    674         if (extra->nativeChildrenForced)
    675             return;
    676         extra->nativeChildrenForced = 1;
    677 
    678         for (int i = 0; i < children.size(); ++i) {
    679             if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
    680                 child->setAttribute(Qt::WA_NativeWindow);
    681         }
    682     }
    683 
    684     inline bool nativeChildrenForced() const
    685     {
    686         return extra ? extra->nativeChildrenForced : false;
    687     }
    688 
    689     QSize adjustedSize() const;
     862        // ### This function should take a rect parameter; then we can avoid
     863        // updating too much on the parent widget.
     864        if (QWidget *parent = m_widget->parentWidget())
     865            parent->update();
     866        else
     867            update();
     868    }
     869
     870    inline const QStyleOption *styleOption() const
     871    { return 0; }
     872
     873    inline QRect deviceRect() const
     874    { return m_widget->window()->rect(); }
     875
     876    QRectF boundingRect(Qt::CoordinateSystem system) const;
     877    void draw(QPainter *p);
     878    QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
     879                   QGraphicsEffect::PixmapPadMode mode) const;
     880
     881    QWidget *m_widget;
     882    QWidgetPaintContext *context;
     883    QTransform lastEffectTransform;
     884    bool updateDueToGraphicsEffect;
    690885};
     886#endif //QT_NO_GRAPHICSEFFECT
    691887
    692888inline QWExtra *QWidgetPrivate::extraData() const
Note: See TracChangeset for help on using the changeset viewer.