1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
49 // This file is not part of the Qt API. It exists for the convenience
50 // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
51 // file may change from version to version without notice, or even be removed.
56 #include "QtWidgets/qwidget.h"
57 #include "private/qobject_p.h"
58 #include "QtCore/qrect.h"
59 #include "QtCore/qlocale.h"
60 #include "QtCore/qset.h"
61 #include "QtGui/qregion.h"
62 #include "QtGui/qinputpanel.h"
63 #include "QtWidgets/qsizepolicy.h"
64 #include "QtWidgets/qstyle.h"
65 #include "QtWidgets/qapplication.h"
66 #include <private/qgraphicseffect_p.h>
67 #include "QtWidgets/qgraphicsproxywidget.h"
68 #include "QtWidgets/qgraphicsscene.h"
69 #include "QtWidgets/qgraphicsview.h"
70 #include <private/qgesture_p.h>
73 #include "QtCore/qt_windows.h"
74 #include <private/qdnd_p.h>
78 #include "QtGui/qx11info_x11.h"
82 #include <private/qt_mac_p.h>
86 #include "QtWidgets/qinputcontext.h"
87 #include "QtGui/qscreen_qws.h"
90 #if defined(Q_OS_SYMBIAN)
91 class RDrawableWindow;
98 // - to minimize memory usage for members that are seldom used.
99 // - top-level widgets have extra extra data to reduce cost further
100 #if defined(Q_WS_QWS)
103 #if defined(Q_WS_MAC)
104 class QCoreGraphicsPaintEnginePrivate;
106 #if defined(Q_WS_QPA)
111 class QWidgetBackingStore;
112 class QGraphicsProxyWidget;
117 class QUnifiedToolbarSurface;
119 class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
123 QWidgetBackingStoreTracker();
124 ~QWidgetBackingStoreTracker();
126 void create(QWidget *tlw);
129 void registerWidget(QWidget *w);
130 void unregisterWidget(QWidget *w);
131 void unregisterWidgetSubtree(QWidget *w);
133 inline QWidgetBackingStore* data()
138 inline QWidgetBackingStore* operator->()
143 inline QWidgetBackingStore& operator*()
148 inline operator bool() const
154 Q_DISABLE_COPY(QWidgetBackingStoreTracker)
157 QWidgetBackingStore* m_ptr;
158 QSet<QWidget *> m_widgets;
162 // *************************** Cross-platform variables *****************************
164 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
165 QIcon *icon; // widget icon
167 QWidgetBackingStoreTracker backingStoreTracker;
168 QBackingStore *backingStore;
169 QPainter *sharedPainter;
171 // Implicit pointers (shared_null).
172 QString caption; // widget caption
173 QString iconText; // widget icon text
174 QString role; // widget role
175 QString filePath; // widget file path
178 short incw, inch; // size increments
179 short basew, baseh; // base sizes
180 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
182 QRect normalGeometry; // used by showMin/maximized/FullScreen
183 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
185 // *************************** Cross-platform bit fields ****************************
187 uint posFromMove : 1;
188 uint sizeAdjusted : 1;
189 uint inTopLevelResize : 1;
193 // *************************** Platform specific values (bit fields first) **********
194 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
195 uint spont_unmapped: 1; // window was spontaneously unmapped
196 uint dnd : 1; // DND properties installed
197 uint validWMState : 1; // is WM_STATE valid?
198 uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
199 WId parentWinId; // parent window Id (valid after reparenting)
200 WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
201 QPoint fullScreenOffset;
203 WId syncUpdateCounter;
204 ulong syncRequestTimestamp;
205 qint32 newCounterValueHi;
206 quint32 newCounterValueLo;
208 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
209 uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
210 HICON winIconBig; // internal big Windows icon
211 HICON winIconSmall; // internal small Windows icon
212 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
214 uint isSetGeometry : 1;
218 WindowGroupRef group;
219 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
220 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
221 #ifdef QT_MAC_USE_COCOA
222 // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
224 // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
225 // starting position as 0,0 instead of the normal starting position.
227 #endif // QT_MAC_USE_COCOA
229 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
230 #ifndef QT_NO_QWS_MANAGER
231 QWSManager *qwsManager;
233 #elif defined(Q_OS_SYMBIAN)
234 uint inExpose : 1; // Prevents drawing recursion
235 uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
236 #elif defined(Q_WS_QPA)
237 QWidgetWindow *window;
238 quint32 screenIndex; // index in qplatformscreenlist
243 // *************************** Cross-platform variables *****************************
245 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
246 void *glContext; // if the widget is hijacked by QGLWindowSurface
247 QTLWExtra *topextra; // only useful for TLWs
248 #ifndef QT_NO_GRAPHICSVIEW
249 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
254 QPointer<QStyle> style;
255 QPointer<QWidget> focus_proxy;
257 // Implicit pointers (shared_empty/shared_null).
258 QRegion mask; // widget mask
263 qint32 minh; // minimum size
265 qint32 maxh; // maximum size
268 QSize staticContentsSize;
270 // *************************** Cross-platform bit fields ****************************
271 uint explicitMinSize : 2;
272 uint explicitMaxSize : 2;
273 uint autoFillBackground : 1;
274 uint nativeChildrenForced : 1;
275 uint inRenderWithPainter : 1;
278 // *************************** Platform specific values (bit fields first) **********
279 #if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
280 #ifndef QT_NO_DRAGANDDROP
281 QOleDropTarget *dropTarget; // drop target
282 QList<QPointer<QWidget> > oleDropWidgets;
284 #elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
285 uint compress_events : 1;
286 WId xDndProxy; // XDND forwarding to embedded windows
287 #elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
288 #ifdef QT_MAC_USE_COCOA
291 CGImageRef imageMask;
293 #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
294 uint activated : 1; // RWindowBase::Activated has been called
297 * If this bit is set, each native widget receives the signals from the
298 * Symbian control immediately before and immediately after draw ops are
299 * sent to the window server for this control:
300 * void beginNativePaintEvent(const QRect &paintRect);
301 * void endNativePaintEvent(const QRect &paintRect);
303 uint receiveNativePaintEvents : 1;
306 * Defines the behaviour of QSymbianControl::Draw.
308 enum NativePaintMode {
310 * Normal drawing mode: blits the required region of the backing store
316 * Disable drawing for this widget.
321 * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
322 * with an EColor16MU display mode, zero is written only into the R, G and B
323 * channels of the pixel.
328 * Blit backing store, propagating alpha channel into the framebuffer.
335 NativePaintMode nativePaintMode;
343 Returns true if \a p or any of its parents enable the
344 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
345 QWidget::setParent() to determine whether it's necessary to embed the
346 widget into a QGraphicsProxyWidget or not.
348 static inline bool bypassGraphicsProxyWidget(const QWidget *p)
351 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
353 p = p->parentWidget();
358 class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
360 Q_DECLARE_PUBLIC(QWidget)
363 // *************************** Cross-platform ***************************************
364 enum DrawWidgetFlags {
366 DrawPaintOnScreen = 0x02,
367 DrawRecursive = 0x04,
368 DrawInvisible = 0x08,
369 DontSubtractOpaqueChildren = 0x10,
370 DontSetCompositionMode = 0x20,
371 DontDrawOpaqueChildren = 0x40,
372 DontDrawNativeChildren = 0x80
378 CloseWithSpontaneousEvent
382 DirectionNorth = 0x01,
383 DirectionEast = 0x10,
384 DirectionSouth = 0x02,
389 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
392 QWExtra *extraData() const;
393 QTLWExtra *topData() const;
394 QTLWExtra *maybeTopData() const;
395 QPainter *sharedPainter() const;
396 void setSharedPainter(QPainter *painter);
397 QWidgetBackingStore *maybeBackingStore() const;
398 void init(QWidget *desktopWidget, Qt::WindowFlags f);
399 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
400 void createRecursively();
401 void createWinId(WId id = 0);
403 void createTLExtra();
406 void createSysExtra();
407 void deleteSysExtra();
408 void createTLSysExtra();
409 void deleteTLSysExtra();
410 void updateSystemBackground();
411 void propagatePaletteChange();
413 void setPalette_helper(const QPalette &);
414 void resolvePalette();
415 QPalette naturalWidgetPalette(uint inheritedMask) const;
417 void setMask_sys(const QRegion &);
419 void setSoftKeys_sys(const QList<QAction*> &softkeys);
420 void activateSymbianWindow(WId wid = 0);
421 void _q_delayedDestroy(WId winId);
426 void stackUnder_sys(QWidget *);
430 void updateFont(const QFont &);
431 inline void setFont_helper(const QFont &font) {
432 if (data.fnt == font && data.fnt.resolve() == font.resolve())
437 QFont naturalWidgetFont(uint inheritedMask) const;
439 void setLayoutDirection_helper(Qt::LayoutDirection);
440 void resolveLayoutDirection();
442 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
443 void resolveLocale();
445 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
448 void setUpdatesEnabled_helper(bool );
450 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
451 bool isAboutToShow() const;
452 QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags);
453 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
454 QWidget::RenderFlags renderFlags);
455 void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
456 QWidget::RenderFlags renderFlags, bool readyToRender);
457 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
458 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
461 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
462 const QRegion &rgn, const QPoint &offset, int flags,
463 QPainter *sharedPainter, QWidgetBackingStore *backingStore);
466 QPainter *beginSharedPainter();
467 bool endSharedPainter();
468 #ifndef QT_NO_GRAPHICSVIEW
469 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
471 void repaint_sys(const QRegion &rgn);
473 QRect clipRect() const;
474 QRegion clipRegion() const;
475 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
476 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
477 bool alsoNonOpaque = false) const;
478 void clipToEffectiveMask(QRegion ®ion) const;
479 void updateIsOpaque();
480 void setOpaque(bool opaque);
481 void updateIsTranslucent();
482 bool paintOnScreen() const;
483 #ifndef QT_NO_GRAPHICSEFFECT
484 void invalidateGraphicsEffectsRecursively();
485 #endif //QT_NO_GRAPHICSEFFECT
487 const QRegion &getOpaqueChildren() const;
488 void setDirtyOpaqueRegion();
490 bool close_helper(CloseMode mode);
492 void setWindowIcon_helper();
493 void setWindowIcon_sys(bool forceReset = false);
494 void setWindowOpacity_sys(qreal opacity);
495 void adjustQuitOnCloseAttribute();
497 void scrollChildren(int dx, int dy);
498 void moveRect(const QRect &, int dx, int dy);
499 void scrollRect(const QRect &, int dx, int dy);
500 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
501 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
502 void invalidateBuffer(const QRegion &);
503 void invalidateBuffer(const QRect &);
504 bool isOverlapped(const QRect&) const;
505 void syncBackingStore();
506 void syncBackingStore(const QRegion ®ion);
508 // tells the input panel about the widgets transform
509 void updateWidgetTransform();
511 void reparentFocusWidgets(QWidget *oldtlw);
513 static int pointToRect(const QPoint &p, const QRect &r);
516 void showChildren(bool spontaneous);
517 void hideChildren(bool spontaneous);
518 void setParent_sys(QWidget *parent, Qt::WindowFlags);
519 void scroll_sys(int dx, int dy);
520 void scroll_sys(int dx, int dy, const QRect &r);
521 void deactivateWidgetCleanup();
522 void setGeometry_sys(int, int, int, int, bool);
523 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
524 void activateChildLayoutsRecursively();
525 void show_recursive();
530 void _q_showIfNotHidden();
532 void setEnabled_helper(bool);
533 void registerDropSite(bool);
534 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
536 void updateFrameStrut();
537 QRect frameStrut() const;
539 #ifdef QT_KEYPAD_NAVIGATION
540 static bool navigateToDirection(Direction direction);
541 static QWidget *widgetInNavigationDirection(Direction direction);
542 static bool canKeypadNavigate(Qt::Orientation orientation);
543 static bool inTabWidget(QWidget *widget);
546 void setWindowIconText_sys(const QString &cap);
547 void setWindowIconText_helper(const QString &cap);
548 void setWindowTitle_sys(const QString &cap);
551 void setCursor_sys(const QCursor &cursor);
552 void unsetCursor_sys();
555 void setWindowTitle_helper(const QString &cap);
556 void setWindowFilePath_helper(const QString &filePath);
558 bool setMinimumSize_helper(int &minw, int &minh);
559 bool setMaximumSize_helper(int &maxw, int &maxh);
560 virtual bool hasHeightForWidth() const;
561 void setConstraints_sys();
562 bool pointInsideRectAndMask(const QPoint &) const;
563 QWidget *childAt_helper(const QPoint &, bool) const;
564 QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
565 void updateGeometry_helper(bool forceUpdate);
567 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
568 void setLayoutItemMargins(int left, int top, int right, int bottom);
569 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
571 // aboutToDestroy() is called just before the contents of
572 // QWidget::destroy() is executed. It's used to signal QWidget
573 // sub-classes that their internals are about to be released.
574 virtual void aboutToDestroy() {}
576 QInputContext *assignedInputContext() const;
577 QInputContext *inputContext() const;
578 inline QWidget *effectiveFocusWidget() {
579 QWidget *w = q_func();
580 while (w->focusProxy())
587 // This is an helper function that return the available geometry for
588 // a widget and takes care is this one is in QGraphicsView.
589 // If the widget is not embed in a scene then the geometry available is
590 // null, we let QDesktopWidget decide for us.
591 static QRect screenGeometry(const QWidget *widget)
594 #ifndef QT_NO_GRAPHICSVIEW
595 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
596 //It's embedded if it has an ancestor
598 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
599 // One view, let be smart and return the viewport rect then the popup is aligned
600 if (ancestorProxy->scene()->views().size() == 1) {
601 QGraphicsView *view = ancestorProxy->scene()->views().at(0);
602 screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
604 screen = ancestorProxy->scene()->sceneRect().toRect();
612 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
614 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
615 redirectDev = replacement;
616 redirectOffset = offset;
619 inline QPaintDevice *redirected(QPoint *offset) const
622 *offset = redirectDev ? redirectOffset : QPoint();
626 inline void restoreRedirected()
629 inline void enforceNativeChildren()
634 if (extra->nativeChildrenForced)
636 extra->nativeChildrenForced = 1;
638 for (int i = 0; i < children.size(); ++i) {
639 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
640 child->setAttribute(Qt::WA_NativeWindow);
644 inline bool nativeChildrenForced() const
646 return extra ? extra->nativeChildrenForced : false;
649 inline QRect effectiveRectFor(const QRect &rect) const
651 #ifndef QT_NO_GRAPHICSEFFECT
652 if (graphicsEffect && graphicsEffect->isEnabled())
653 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
654 #endif //QT_NO_GRAPHICSEFFECT
658 QSize adjustedSize() const;
660 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
663 if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
664 QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
665 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
666 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
667 qApp->inputPanel()->show();
672 #ifndef Q_WS_QWS // Almost cross-platform :-)
673 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
675 inline QPoint mapToWS(const QPoint &p) const
676 { return p - data.wrect.topLeft(); }
678 inline QPoint mapFromWS(const QPoint &p) const
679 { return p + data.wrect.topLeft(); }
681 inline QRect mapToWS(const QRect &r) const
682 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
684 inline QRect mapFromWS(const QRect &r) const
685 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
689 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
693 QWidget *focus_child;
696 QPaintDevice *redirectDev;
697 QWidgetItemV2 *widgetItem;
698 QPaintEngine *extraPaintEngine;
699 mutable const QMetaObject *polished;
700 QGraphicsEffect *graphicsEffect;
701 // All widgets are added into the allWidgets set. Once
702 // they receive a window id they are also added to the mapper.
703 // This should just ensure that all widgets are deleted by QApplication
704 static QWidgetMapper *mapper;
705 static QWidgetSet *allWidgets;
706 #if !defined(QT_NO_IM)
707 QPointer<QInputContext> ic;
708 Qt::InputMethodHints imHints;
710 #ifdef QT_KEYPAD_NAVIGATION
711 static QPointer<QWidget> editingWidget;
714 // Implicit pointers (shared_null/shared_empty).
715 QRegion opaqueChildren;
717 #ifndef QT_NO_TOOLTIP
720 #ifndef QT_NO_STATUSTIP
723 #ifndef QT_NO_WHATSTHIS
726 #ifndef QT_NO_ACCESSIBILITY
727 QString accessibleName;
728 QString accessibleDescription;
732 uint inheritedFontResolveMask;
733 uint inheritedPaletteResolveMask;
738 signed char leftLayoutItemMargin;
739 signed char topLayoutItemMargin;
740 signed char rightLayoutItemMargin;
741 signed char bottomLayoutItemMargin;
742 static int instanceCounter; // Current number of widget instances
743 static int maxInstances; // Maximum number of widget instances
746 QSizePolicy size_policy;
748 QPoint redirectOffset;
750 QList<QAction*> actions;
752 #ifndef QT_NO_GESTURES
753 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
757 uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
758 QPalette::ColorRole fg_role : 8;
759 QPalette::ColorRole bg_role : 8;
760 uint dirtyOpaqueChildren : 1;
762 uint inDirtyList : 1;
766 uint usesDoubleBufferedGLContext : 1;
768 uint inheritsInputMethodHints : 1;
770 uint inSetParent : 1;
772 // *************************** Platform specific ************************************
773 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
776 static QWidget *mouseGrabber;
777 static QWidget *keyboardGrabber;
779 void setWindowRole();
780 void sendStartupMessage(const char *message) const;
781 void setNetWmWindowTypes();
782 void x11UpdateIsOpaque();
783 bool isBackgroundInherited() const;
784 void updateX11AcceptFocus();
785 QPoint mapToGlobal(const QPoint &pos) const;
786 QPoint mapFromGlobal(const QPoint &pos) const;
787 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
788 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
789 #ifndef QT_NO_GESTURES
790 uint nativeGesturePanEnabled : 1;
792 bool shouldShowMaximizeButton();
793 void winUpdateIsOpaque();
794 void reparentChildren();
795 #ifndef QT_NO_DRAGANDDROP
796 QOleDropTarget *registerOleDnd(QWidget *widget);
797 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
799 void grabMouseWhileInWindow();
800 void registerTouchWindow();
801 void winSetupGestures();
802 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
804 uint needWindowChange : 1;
806 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
807 // This list is used to update the gl context whenever a parent and a granparent
808 // moves, and also to check for intersections with gl widgets within the window
809 // when a widget moves.
812 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
813 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
815 QWidget * lastUpdateWidget;
818 // dirtyOnWidget contains the areas in the widget that needs to be repained,
819 // in the same way as dirtyOnScreen does for the window. Areas are added in
820 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
821 // this information repaint invalid areas when widgets are scrolled.
822 QRegion dirtyOnWidget;
823 EventHandlerRef window_event;
824 QList<GlWidgetInfo> glWidgets;
826 //these are here just for code compat (HIViews)
829 void macUpdateSizeAttribute();
830 void macUpdateHideOnSuspend();
831 void macUpdateOpaqueSizeGrip();
832 void macUpdateIgnoreMouseEvents();
833 void macUpdateMetalAttribute();
834 void macUpdateIsOpaque();
835 void macSetNeedsDisplay(QRegion region);
836 void setEnabled_helper_sys(bool enable);
837 bool isRealWindow() const;
838 void adjustWithinMaxAndMinSize(int &w, int &h);
839 void applyMaxAndMinSizeOnWindow();
840 void update_sys(const QRect &rect);
841 void update_sys(const QRegion &rgn);
842 void setGeometry_sys_helper(int, int, int, int, bool);
843 void setWindowModified_sys(bool b);
844 void updateMaximizeButton_sys();
845 void setWindowFilePath_sys(const QString &filePath);
846 void createWindow_sys();
847 void recreateMacWindow();
848 #ifndef QT_MAC_USE_COCOA
849 void initWindowPtr();
850 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
852 void setSubWindowStacking(bool set);
853 void setWindowLevel();
854 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
855 void syncCocoaMask();
856 void finishCocoaMaskSetup();
857 void syncUnifiedMode();
858 // Did we add the drawRectOriginal method?
859 bool drawRectOriginalAdded;
860 // Is the original drawRect method available?
861 bool originalDrawMethod;
862 // Do we need to change the methods?
865 // Unified toolbar variables
866 bool isInUnifiedToolbar;
867 QUnifiedToolbarSurface *unifiedSurface;
868 QPoint toolbar_offset;
869 QWidget *toolbar_ancestor;
871 bool touchEventsEnabled;
872 #endif // QT_MAC_USE_COCOA
873 void determineWindowClass();
874 void transferChildren();
875 bool qt_mac_dnd_event(uint, DragRef);
876 void toggleDrawers(bool);
877 //mac event functions
878 static bool qt_create_root_win();
879 static void qt_clean_root_win();
880 static bool qt_mac_update_sizer(QWidget *, int up = 0);
881 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
882 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
883 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
884 void registerTouchWindow(bool enable = true);
885 #elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
886 void setMaxWindowState_helper();
887 void setFullScreenSize_helper();
888 bool stealKeyboardGrab(bool grab);
889 bool stealMouseGrab(bool grab);
890 #elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
891 static QWidget *mouseGrabber;
892 static QWidget *keyboardGrabber;
893 int symbianScreenNumber; // only valid for desktop widget and top-levels
894 bool fixNativeOrientationCalled;
895 void s60UpdateIsOpaque();
896 void reparentChildren();
897 void registerTouchWindow();
902 struct QWidgetPaintContext
904 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
905 QPainter *p, QWidgetBackingStore *b)
906 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
912 QPainter *sharedPainter;
913 QWidgetBackingStore *backingStore;
917 #ifndef QT_NO_GRAPHICSEFFECT
918 class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
921 QWidgetEffectSourcePrivate(QWidget *widget)
922 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
926 { m_widget->d_func()->graphicsEffect = 0; }
928 inline const QGraphicsItem *graphicsItem() const
931 inline const QWidget *widget() const
936 updateDueToGraphicsEffect = true;
938 updateDueToGraphicsEffect = false;
941 inline bool isPixmap() const
944 inline void effectBoundingRectChanged()
946 // ### This function should take a rect parameter; then we can avoid
947 // updating too much on the parent widget.
948 if (QWidget *parent = m_widget->parentWidget())
954 inline const QStyleOption *styleOption() const
957 inline QRect deviceRect() const
958 { return m_widget->window()->rect(); }
960 QRectF boundingRect(Qt::CoordinateSystem system) const;
961 void draw(QPainter *p);
962 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
963 QGraphicsEffect::PixmapPadMode mode) const;
966 QWidgetPaintContext *context;
967 QTransform lastEffectTransform;
968 bool updateDueToGraphicsEffect;
970 #endif //QT_NO_GRAPHICSEFFECT
972 inline QWExtra *QWidgetPrivate::extraData() const
977 inline QTLWExtra *QWidgetPrivate::topData() const
979 const_cast<QWidgetPrivate *>(this)->createTLExtra();
980 return extra->topextra;
983 inline QTLWExtra *QWidgetPrivate::maybeTopData() const
985 return extra ? extra->topextra : 0;
988 inline QPainter *QWidgetPrivate::sharedPainter() const
991 QTLWExtra *x = q->window()->d_func()->maybeTopData();
992 return x ? x->sharedPainter : 0;
995 inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
998 QTLWExtra *x = q->window()->d_func()->topData();
999 x->sharedPainter = painter;
1002 inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
1005 return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
1006 || extra->mask.contains(p));
1009 inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
1012 QTLWExtra *x = q->window()->d_func()->maybeTopData();
1013 return x ? x->backingStoreTracker.data() : 0;
1018 #endif // QWIDGET_P_H