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 "QtWidgets/qsizepolicy.h"
63 #include "QtWidgets/qstyle.h"
64 #include "QtWidgets/qapplication.h"
65 #include <private/qgraphicseffect_p.h>
66 #include "QtWidgets/qgraphicsproxywidget.h"
67 #include "QtWidgets/qgraphicsscene.h"
68 #include "QtWidgets/qgraphicsview.h"
69 #include <private/qgesture_p.h>
72 #include "QtCore/qt_windows.h"
73 #include <private/qdnd_p.h>
77 #include "QtGui/qx11info_x11.h"
81 #include <private/qt_mac_p.h>
85 #include "QtWidgets/qinputcontext.h"
86 #include "QtGui/qscreen_qws.h"
89 #if defined(Q_OS_SYMBIAN)
90 class RDrawableWindow;
97 // - to minimize memory usage for members that are seldom used.
98 // - top-level widgets have extra extra data to reduce cost further
102 #if defined(Q_WS_MAC)
103 class QCoreGraphicsPaintEnginePrivate;
105 #if defined(Q_WS_QPA)
110 class QWidgetBackingStore;
111 class QGraphicsProxyWidget;
116 class QUnifiedToolbarSurface;
118 class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
122 QWidgetBackingStoreTracker();
123 ~QWidgetBackingStoreTracker();
125 void create(QWidget *tlw);
128 void registerWidget(QWidget *w);
129 void unregisterWidget(QWidget *w);
130 void unregisterWidgetSubtree(QWidget *w);
132 inline QWidgetBackingStore* data()
137 inline QWidgetBackingStore* operator->()
142 inline QWidgetBackingStore& operator*()
147 inline operator bool() const
153 Q_DISABLE_COPY(QWidgetBackingStoreTracker)
156 QWidgetBackingStore* m_ptr;
157 QSet<QWidget *> m_widgets;
161 // *************************** Cross-platform variables *****************************
163 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
164 QIcon *icon; // widget icon
166 QWidgetBackingStoreTracker backingStore;
167 QWindowSurface *windowSurface;
168 QPainter *sharedPainter;
170 // Implicit pointers (shared_null).
171 QString caption; // widget caption
172 QString iconText; // widget icon text
173 QString role; // widget role
174 QString filePath; // widget file path
177 short incw, inch; // size increments
178 short basew, baseh; // base sizes
179 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
181 QRect normalGeometry; // used by showMin/maximized/FullScreen
182 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
184 // *************************** Cross-platform bit fields ****************************
186 uint posFromMove : 1;
187 uint sizeAdjusted : 1;
188 uint inTopLevelResize : 1;
192 // *************************** Platform specific values (bit fields first) **********
193 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
194 uint spont_unmapped: 1; // window was spontaneously unmapped
195 uint dnd : 1; // DND properties installed
196 uint validWMState : 1; // is WM_STATE valid?
197 uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
198 WId parentWinId; // parent window Id (valid after reparenting)
199 WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
200 QPoint fullScreenOffset;
202 WId syncUpdateCounter;
203 ulong syncRequestTimestamp;
204 qint32 newCounterValueHi;
205 quint32 newCounterValueLo;
207 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
208 uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
209 HICON winIconBig; // internal big Windows icon
210 HICON winIconSmall; // internal small Windows icon
211 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
213 uint isSetGeometry : 1;
217 WindowGroupRef group;
218 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
219 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
220 #ifdef QT_MAC_USE_COCOA
221 // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
223 // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
224 // starting position as 0,0 instead of the normal starting position.
226 #endif // QT_MAC_USE_COCOA
228 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
229 #ifndef QT_NO_QWS_MANAGER
230 QWSManager *qwsManager;
232 #elif defined(Q_OS_SYMBIAN)
233 uint inExpose : 1; // Prevents drawing recursion
234 uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
235 #elif defined(Q_WS_QPA)
236 QWidgetWindow *window;
237 quint32 screenIndex; // index in qplatformscreenlist
242 // *************************** Cross-platform variables *****************************
244 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
245 void *glContext; // if the widget is hijacked by QGLWindowSurface
246 QTLWExtra *topextra; // only useful for TLWs
247 #ifndef QT_NO_GRAPHICSVIEW
248 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
253 QPointer<QStyle> style;
254 QPointer<QWidget> focus_proxy;
256 // Implicit pointers (shared_empty/shared_null).
257 QRegion mask; // widget mask
262 qint32 minh; // minimum size
264 qint32 maxh; // maximum size
267 QSize staticContentsSize;
269 // *************************** Cross-platform bit fields ****************************
270 uint explicitMinSize : 2;
271 uint explicitMaxSize : 2;
272 uint autoFillBackground : 1;
273 uint nativeChildrenForced : 1;
274 uint inRenderWithPainter : 1;
277 // *************************** Platform specific values (bit fields first) **********
278 #if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
279 #ifndef QT_NO_DRAGANDDROP
280 QOleDropTarget *dropTarget; // drop target
281 QList<QPointer<QWidget> > oleDropWidgets;
283 #elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
284 uint compress_events : 1;
285 WId xDndProxy; // XDND forwarding to embedded windows
286 #elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
287 #ifdef QT_MAC_USE_COCOA
290 CGImageRef imageMask;
292 #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
293 uint activated : 1; // RWindowBase::Activated has been called
296 * If this bit is set, each native widget receives the signals from the
297 * Symbian control immediately before and immediately after draw ops are
298 * sent to the window server for this control:
299 * void beginNativePaintEvent(const QRect &paintRect);
300 * void endNativePaintEvent(const QRect &paintRect);
302 uint receiveNativePaintEvents : 1;
305 * Defines the behaviour of QSymbianControl::Draw.
307 enum NativePaintMode {
309 * Normal drawing mode: blits the required region of the backing store
315 * Disable drawing for this widget.
320 * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
321 * with an EColor16MU display mode, zero is written only into the R, G and B
322 * channels of the pixel.
327 * Blit backing store, propagating alpha channel into the framebuffer.
334 NativePaintMode nativePaintMode;
342 Returns true if \a p or any of its parents enable the
343 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
344 QWidget::setParent() to determine whether it's necessary to embed the
345 widget into a QGraphicsProxyWidget or not.
347 static inline bool bypassGraphicsProxyWidget(const QWidget *p)
350 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
352 p = p->parentWidget();
357 class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
359 Q_DECLARE_PUBLIC(QWidget)
362 // *************************** Cross-platform ***************************************
363 enum DrawWidgetFlags {
365 DrawPaintOnScreen = 0x02,
366 DrawRecursive = 0x04,
367 DrawInvisible = 0x08,
368 DontSubtractOpaqueChildren = 0x10,
369 DontSetCompositionMode = 0x20,
370 DontDrawOpaqueChildren = 0x40,
371 DontDrawNativeChildren = 0x80
377 CloseWithSpontaneousEvent
381 DirectionNorth = 0x01,
382 DirectionEast = 0x10,
383 DirectionSouth = 0x02,
388 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
391 QWExtra *extraData() const;
392 QTLWExtra *topData() const;
393 QTLWExtra *maybeTopData() const;
394 QPainter *sharedPainter() const;
395 void setSharedPainter(QPainter *painter);
396 QWidgetBackingStore *maybeBackingStore() const;
397 void init(QWidget *desktopWidget, Qt::WindowFlags f);
398 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
399 void createRecursively();
400 void createWinId(WId id = 0);
402 void createTLExtra();
405 void createSysExtra();
406 void deleteSysExtra();
407 void createTLSysExtra();
408 void deleteTLSysExtra();
409 void updateSystemBackground();
410 void propagatePaletteChange();
412 void setPalette_helper(const QPalette &);
413 void resolvePalette();
414 QPalette naturalWidgetPalette(uint inheritedMask) const;
416 void setMask_sys(const QRegion &);
418 void setSoftKeys_sys(const QList<QAction*> &softkeys);
419 void activateSymbianWindow(WId wid = 0);
420 void _q_delayedDestroy(WId winId);
425 void stackUnder_sys(QWidget *);
429 void updateFont(const QFont &);
430 inline void setFont_helper(const QFont &font) {
431 if (data.fnt == font && data.fnt.resolve() == font.resolve())
436 QFont naturalWidgetFont(uint inheritedMask) const;
438 void setLayoutDirection_helper(Qt::LayoutDirection);
439 void resolveLayoutDirection();
441 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
442 void resolveLocale();
444 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
447 void setUpdatesEnabled_helper(bool );
449 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
450 bool isAboutToShow() const;
451 QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags);
452 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
453 QWidget::RenderFlags renderFlags);
454 void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
455 QWidget::RenderFlags renderFlags, bool readyToRender);
456 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
457 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
460 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
461 const QRegion &rgn, const QPoint &offset, int flags
462 #ifdef Q_BACKINGSTORE_SUBSURFACES
463 , const QWindowSurface *currentSurface
465 , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
468 QPainter *beginSharedPainter();
469 bool endSharedPainter();
470 #ifndef QT_NO_GRAPHICSVIEW
471 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
473 QWindowSurface *createDefaultWindowSurface();
474 QWindowSurface *createDefaultWindowSurface_sys();
475 void repaint_sys(const QRegion &rgn);
477 QRect clipRect() const;
478 QRegion clipRegion() const;
479 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
480 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
481 bool alsoNonOpaque = false) const;
482 void clipToEffectiveMask(QRegion ®ion) const;
483 void updateIsOpaque();
484 void setOpaque(bool opaque);
485 void updateIsTranslucent();
486 bool paintOnScreen() const;
487 #ifndef QT_NO_GRAPHICSEFFECT
488 void invalidateGraphicsEffectsRecursively();
489 #endif //QT_NO_GRAPHICSEFFECT
491 const QRegion &getOpaqueChildren() const;
492 void setDirtyOpaqueRegion();
494 bool close_helper(CloseMode mode);
496 void setWindowIcon_helper();
497 void setWindowIcon_sys(bool forceReset = false);
498 void setWindowOpacity_sys(qreal opacity);
499 void adjustQuitOnCloseAttribute();
501 void scrollChildren(int dx, int dy);
502 void moveRect(const QRect &, int dx, int dy);
503 void scrollRect(const QRect &, int dx, int dy);
504 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
505 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
506 void invalidateBuffer(const QRegion &);
507 void invalidateBuffer(const QRect &);
508 bool isOverlapped(const QRect&) const;
509 void syncBackingStore();
510 void syncBackingStore(const QRegion ®ion);
512 void reparentFocusWidgets(QWidget *oldtlw);
514 static int pointToRect(const QPoint &p, const QRect &r);
517 void showChildren(bool spontaneous);
518 void hideChildren(bool spontaneous);
519 void setParent_sys(QWidget *parent, Qt::WindowFlags);
520 void scroll_sys(int dx, int dy);
521 void scroll_sys(int dx, int dy, const QRect &r);
522 void deactivateWidgetCleanup();
523 void setGeometry_sys(int, int, int, int, bool);
524 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
525 void activateChildLayoutsRecursively();
526 void show_recursive();
531 void _q_showIfNotHidden();
533 void setEnabled_helper(bool);
534 void registerDropSite(bool);
535 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
537 void updateFrameStrut();
538 QRect frameStrut() const;
540 #ifdef QT_KEYPAD_NAVIGATION
541 static bool navigateToDirection(Direction direction);
542 static QWidget *widgetInNavigationDirection(Direction direction);
543 static bool canKeypadNavigate(Qt::Orientation orientation);
544 static bool inTabWidget(QWidget *widget);
547 void setWindowIconText_sys(const QString &cap);
548 void setWindowIconText_helper(const QString &cap);
549 void setWindowTitle_sys(const QString &cap);
552 void setCursor_sys(const QCursor &cursor);
553 void unsetCursor_sys();
556 void setWindowTitle_helper(const QString &cap);
557 void setWindowFilePath_helper(const QString &filePath);
559 bool setMinimumSize_helper(int &minw, int &minh);
560 bool setMaximumSize_helper(int &maxw, int &maxh);
561 virtual bool hasHeightForWidth() const;
562 void setConstraints_sys();
563 bool pointInsideRectAndMask(const QPoint &) const;
564 QWidget *childAt_helper(const QPoint &, bool) const;
565 QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
566 void updateGeometry_helper(bool forceUpdate);
568 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
569 void setLayoutItemMargins(int left, int top, int right, int bottom);
570 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
572 // aboutToDestroy() is called just before the contents of
573 // QWidget::destroy() is executed. It's used to signal QWidget
574 // sub-classes that their internals are about to be released.
575 virtual void aboutToDestroy() {}
577 QInputContext *assignedInputContext() const;
578 QInputContext *inputContext() const;
579 inline QWidget *effectiveFocusWidget() {
580 QWidget *w = q_func();
581 while (w->focusProxy())
588 // This is an helper function that return the available geometry for
589 // a widget and takes care is this one is in QGraphicsView.
590 // If the widget is not embed in a scene then the geometry available is
591 // null, we let QDesktopWidget decide for us.
592 static QRect screenGeometry(const QWidget *widget)
595 #ifndef QT_NO_GRAPHICSVIEW
596 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
597 //It's embedded if it has an ancestor
599 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
600 // One view, let be smart and return the viewport rect then the popup is aligned
601 if (ancestorProxy->scene()->views().size() == 1) {
602 QGraphicsView *view = ancestorProxy->scene()->views().at(0);
603 screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
605 screen = ancestorProxy->scene()->sceneRect().toRect();
613 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
615 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
616 redirectDev = replacement;
617 redirectOffset = offset;
620 inline QPaintDevice *redirected(QPoint *offset) const
623 *offset = redirectDev ? redirectOffset : QPoint();
627 inline void restoreRedirected()
630 inline void enforceNativeChildren()
635 if (extra->nativeChildrenForced)
637 extra->nativeChildrenForced = 1;
639 for (int i = 0; i < children.size(); ++i) {
640 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
641 child->setAttribute(Qt::WA_NativeWindow);
645 inline bool nativeChildrenForced() const
647 return extra ? extra->nativeChildrenForced : false;
650 inline QRect effectiveRectFor(const QRect &rect) const
652 #ifndef QT_NO_GRAPHICSEFFECT
653 if (graphicsEffect && graphicsEffect->isEnabled())
654 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
655 #endif //QT_NO_GRAPHICSEFFECT
659 QSize adjustedSize() const;
661 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
664 if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
665 QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
666 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
667 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
668 QEvent event(QEvent::RequestSoftwareInputPanel);
669 QApplication::sendEvent(q, &event);
674 #ifndef Q_WS_QWS // Almost cross-platform :-)
675 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
677 inline QPoint mapToWS(const QPoint &p) const
678 { return p - data.wrect.topLeft(); }
680 inline QPoint mapFromWS(const QPoint &p) const
681 { return p + data.wrect.topLeft(); }
683 inline QRect mapToWS(const QRect &r) const
684 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
686 inline QRect mapFromWS(const QRect &r) const
687 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
691 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
695 QWidget *focus_child;
698 QPaintDevice *redirectDev;
699 QWidgetItemV2 *widgetItem;
700 QPaintEngine *extraPaintEngine;
701 mutable const QMetaObject *polished;
702 QGraphicsEffect *graphicsEffect;
703 // All widgets are added into the allWidgets set. Once
704 // they receive a window id they are also added to the mapper.
705 // This should just ensure that all widgets are deleted by QApplication
706 static QWidgetMapper *mapper;
707 static QWidgetSet *allWidgets;
708 #if !defined(QT_NO_IM)
709 QPointer<QInputContext> ic;
710 Qt::InputMethodHints imHints;
712 #ifdef QT_KEYPAD_NAVIGATION
713 static QPointer<QWidget> editingWidget;
716 // Implicit pointers (shared_null/shared_empty).
717 QRegion opaqueChildren;
719 #ifndef QT_NO_TOOLTIP
722 #ifndef QT_NO_STATUSTIP
725 #ifndef QT_NO_WHATSTHIS
728 #ifndef QT_NO_ACCESSIBILITY
729 QString accessibleName;
730 QString accessibleDescription;
734 uint inheritedFontResolveMask;
735 uint inheritedPaletteResolveMask;
740 signed char leftLayoutItemMargin;
741 signed char topLayoutItemMargin;
742 signed char rightLayoutItemMargin;
743 signed char bottomLayoutItemMargin;
744 static int instanceCounter; // Current number of widget instances
745 static int maxInstances; // Maximum number of widget instances
748 QSizePolicy size_policy;
750 QPoint redirectOffset;
752 QList<QAction*> actions;
754 #ifndef QT_NO_GESTURES
755 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
759 uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
760 QPalette::ColorRole fg_role : 8;
761 QPalette::ColorRole bg_role : 8;
762 uint dirtyOpaqueChildren : 1;
764 uint inDirtyList : 1;
768 uint usesDoubleBufferedGLContext : 1;
770 uint inheritsInputMethodHints : 1;
772 uint inSetParent : 1;
774 // *************************** Platform specific ************************************
775 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
778 static QWidget *mouseGrabber;
779 static QWidget *keyboardGrabber;
781 void setWindowRole();
782 void sendStartupMessage(const char *message) const;
783 void setNetWmWindowTypes();
784 void x11UpdateIsOpaque();
785 bool isBackgroundInherited() const;
786 void updateX11AcceptFocus();
787 QPoint mapToGlobal(const QPoint &pos) const;
788 QPoint mapFromGlobal(const QPoint &pos) const;
789 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
790 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
791 #ifndef QT_NO_GESTURES
792 uint nativeGesturePanEnabled : 1;
794 bool shouldShowMaximizeButton();
795 void winUpdateIsOpaque();
796 void reparentChildren();
797 #ifndef QT_NO_DRAGANDDROP
798 QOleDropTarget *registerOleDnd(QWidget *widget);
799 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
801 void grabMouseWhileInWindow();
802 void registerTouchWindow();
803 void winSetupGestures();
804 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
806 uint needWindowChange : 1;
808 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
809 // This list is used to update the gl context whenever a parent and a granparent
810 // moves, and also to check for intersections with gl widgets within the window
811 // when a widget moves.
814 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
815 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
817 QWidget * lastUpdateWidget;
820 // dirtyOnWidget contains the areas in the widget that needs to be repained,
821 // in the same way as dirtyOnScreen does for the window. Areas are added in
822 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
823 // this information repaint invalid areas when widgets are scrolled.
824 QRegion dirtyOnWidget;
825 EventHandlerRef window_event;
826 QList<GlWidgetInfo> glWidgets;
828 //these are here just for code compat (HIViews)
831 void macUpdateSizeAttribute();
832 void macUpdateHideOnSuspend();
833 void macUpdateOpaqueSizeGrip();
834 void macUpdateIgnoreMouseEvents();
835 void macUpdateMetalAttribute();
836 void macUpdateIsOpaque();
837 void macSetNeedsDisplay(QRegion region);
838 void setEnabled_helper_sys(bool enable);
839 bool isRealWindow() const;
840 void adjustWithinMaxAndMinSize(int &w, int &h);
841 void applyMaxAndMinSizeOnWindow();
842 void update_sys(const QRect &rect);
843 void update_sys(const QRegion &rgn);
844 void setGeometry_sys_helper(int, int, int, int, bool);
845 void setWindowModified_sys(bool b);
846 void updateMaximizeButton_sys();
847 void setWindowFilePath_sys(const QString &filePath);
848 void createWindow_sys();
849 void recreateMacWindow();
850 #ifndef QT_MAC_USE_COCOA
851 void initWindowPtr();
852 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
854 void setSubWindowStacking(bool set);
855 void setWindowLevel();
856 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
857 void syncCocoaMask();
858 void finishCocoaMaskSetup();
859 void syncUnifiedMode();
860 // Did we add the drawRectOriginal method?
861 bool drawRectOriginalAdded;
862 // Is the original drawRect method available?
863 bool originalDrawMethod;
864 // Do we need to change the methods?
867 // Unified toolbar variables
868 bool isInUnifiedToolbar;
869 QUnifiedToolbarSurface *unifiedSurface;
870 QPoint toolbar_offset;
871 QWidget *toolbar_ancestor;
873 bool touchEventsEnabled;
874 #endif // QT_MAC_USE_COCOA
875 void determineWindowClass();
876 void transferChildren();
877 bool qt_mac_dnd_event(uint, DragRef);
878 void toggleDrawers(bool);
879 //mac event functions
880 static bool qt_create_root_win();
881 static void qt_clean_root_win();
882 static bool qt_mac_update_sizer(QWidget *, int up = 0);
883 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
884 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
885 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
886 void registerTouchWindow(bool enable = true);
887 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
888 void setMaxWindowState_helper();
889 void setFullScreenSize_helper();
890 void moveSurface(QWindowSurface *surface, const QPoint &offset);
891 QRegion localRequestedRegion() const;
892 QRegion localAllocatedRegion() const;
894 friend class QWSManager;
895 friend class QWSManagerPrivate;
896 friend class QDecoration;
898 void updateCursor() const;
900 QScreen* getScreen() const;
901 #elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
902 void setMaxWindowState_helper();
903 void setFullScreenSize_helper();
904 bool stealKeyboardGrab(bool grab);
905 bool stealMouseGrab(bool grab);
906 #elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
907 static QWidget *mouseGrabber;
908 static QWidget *keyboardGrabber;
909 int symbianScreenNumber; // only valid for desktop widget and top-levels
910 bool fixNativeOrientationCalled;
911 void s60UpdateIsOpaque();
912 void reparentChildren();
913 void registerTouchWindow();
918 struct QWidgetPaintContext
920 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
921 QPainter *p, QWidgetBackingStore *b)
922 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
928 QPainter *sharedPainter;
929 QWidgetBackingStore *backingStore;
933 #ifndef QT_NO_GRAPHICSEFFECT
934 class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
937 QWidgetEffectSourcePrivate(QWidget *widget)
938 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
942 { m_widget->d_func()->graphicsEffect = 0; }
944 inline const QGraphicsItem *graphicsItem() const
947 inline const QWidget *widget() const
952 updateDueToGraphicsEffect = true;
954 updateDueToGraphicsEffect = false;
957 inline bool isPixmap() const
960 inline void effectBoundingRectChanged()
962 // ### This function should take a rect parameter; then we can avoid
963 // updating too much on the parent widget.
964 if (QWidget *parent = m_widget->parentWidget())
970 inline const QStyleOption *styleOption() const
973 inline QRect deviceRect() const
974 { return m_widget->window()->rect(); }
976 QRectF boundingRect(Qt::CoordinateSystem system) const;
977 void draw(QPainter *p);
978 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
979 QGraphicsEffect::PixmapPadMode mode) const;
982 QWidgetPaintContext *context;
983 QTransform lastEffectTransform;
984 bool updateDueToGraphicsEffect;
986 #endif //QT_NO_GRAPHICSEFFECT
988 inline QWExtra *QWidgetPrivate::extraData() const
993 inline QTLWExtra *QWidgetPrivate::topData() const
995 const_cast<QWidgetPrivate *>(this)->createTLExtra();
996 return extra->topextra;
999 inline QTLWExtra *QWidgetPrivate::maybeTopData() const
1001 return extra ? extra->topextra : 0;
1004 inline QPainter *QWidgetPrivate::sharedPainter() const
1007 QTLWExtra *x = q->window()->d_func()->maybeTopData();
1008 return x ? x->sharedPainter : 0;
1011 inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
1014 QTLWExtra *x = q->window()->d_func()->topData();
1015 x->sharedPainter = painter;
1018 inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
1021 return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
1022 || extra->mask.contains(p));
1025 inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
1028 QTLWExtra *x = q->window()->d_func()->maybeTopData();
1029 return x ? x->backingStore.data() : 0;
1034 #endif // QWIDGET_P_H