Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwidget_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWIDGET_P_H
5#define QWIDGET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
13// file may change from version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18
19
20#include <QtWidgets/private/qtwidgetsglobal_p.h>
21#include "QtWidgets/qwidget.h"
22#include "private/qobject_p.h"
23#include "QtCore/qrect.h"
24#include "QtCore/qlocale.h"
25#include "QtCore/qset.h"
26#include "QtGui/qregion.h"
27#include "QtGui/qinputmethod.h"
28#include "QtGui/qsurfaceformat.h"
29#include "QtGui/qscreen.h"
30#include "QtWidgets/qsizepolicy.h"
31#include "QtWidgets/qstyle.h"
32#include "QtWidgets/qapplication.h"
33#if QT_CONFIG(graphicseffect)
34#include <private/qgraphicseffect_p.h>
35#endif
36#if QT_CONFIG(graphicsview)
37#include "QtWidgets/qgraphicsproxywidget.h"
38#include "QtWidgets/qgraphicsscene.h"
39#include "QtWidgets/qgraphicsview.h"
40#endif
41#include <private/qgesture_p.h>
42#include <qpa/qplatformbackingstore.h>
43#include <QtGui/private/qbackingstorerhisupport_p.h>
44
45#include <vector>
46#include <memory>
47
49
51
52// Extra QWidget data
53// - to minimize memory usage for members that are seldom used.
54// - top-level widgets have extra extra data to reduce cost further
55class QWidgetWindow;
56class QPaintEngine;
57class QPixmap;
60class QWidgetItemV2;
61
62class QStyle;
63
64class QUnifiedToolbarSurface;
65
66// implemented in qshortcut.cpp
69
71{
72public:
73 explicit QUpdateLaterEvent(const QRegion& paintRegion)
74 : QEvent(UpdateLater), m_region(paintRegion)
75 {
76 }
77
79 {
80 }
81
82 inline const QRegion &region() const { return m_region; }
83
84protected:
86};
87
88struct QTLWExtra {
89 // *************************** Cross-platform variables *****************************
90
91 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
92 std::unique_ptr<QIcon> icon; // widget icon
93 std::unique_ptr<QWidgetRepaintManager> repaintManager;
97
98 // Implicit pointers (shared_null).
99 QString caption; // widget caption
100 QString iconText; // widget icon text
101 QString role; // widget role
102 QString filePath; // widget file path
103
104 // Other variables.
105 short incw, inch; // size increments
106 short basew, baseh; // base sizes
107 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
109 QRect normalGeometry; // used by showMin/maximized/FullScreen
110 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
111 QScreen *initialScreen; // Screen when passing a QDesktop[Screen]Widget as parent.
112
113 std::vector<std::unique_ptr<QPlatformTextureList>> widgetTextures;
114
115 // *************************** Cross-platform bit fields ****************************
120};
121
122struct QWExtra {
123 // *************************** Cross-platform variables *****************************
124
125 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
126 void *glContext; // if the widget is hijacked by QGLWindowSurface
127 std::unique_ptr<QTLWExtra> topextra; // only useful for TLWs
128#if QT_CONFIG(graphicsview)
129 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
130#endif
131#ifndef QT_NO_CURSOR
132 std::unique_ptr<QCursor> curs;
133#endif
136
137 // Implicit pointers (shared_empty/shared_null).
138 QRegion mask; // widget mask
140
141 // Other variables.
143 qint32 minh; // minimum size
145 qint32 maxh; // maximum size
149
150 // *************************** Cross-platform bit fields ****************************
158};
159
168static inline bool bypassGraphicsProxyWidget(const QWidget *p)
169{
170 while (p) {
171 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
172 return true;
173 p = p->parentWidget();
174 }
175 return false;
176}
177
178class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
179{
180 Q_DECLARE_PUBLIC(QWidget)
182
183public:
184 // *************************** Cross-platform ***************************************
186 DrawAsRoot = 0x01,
187 DrawPaintOnScreen = 0x02,
188 DrawRecursive = 0x04,
189 DrawInvisible = 0x08,
190 DontSubtractOpaqueChildren = 0x10,
191 DontDrawOpaqueChildren = 0x20,
192 DontDrawNativeChildren = 0x40,
193 DontSetCompositionMode = 0x80,
194 UseEffectRegionBounds = 0x100
195 };
196 Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
197 Q_FLAG(DrawWidgetFlags)
198
200 DirectionNorth = 0x01,
201 DirectionEast = 0x10,
202 DirectionSouth = 0x02,
203 DirectionWest = 0x20
204 };
205 Q_ENUM(Direction)
206
207 // Functions.
208 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
210
211 static QWidgetPrivate *get(QWidget *w) { return w->d_func(); }
212 static const QWidgetPrivate *get(const QWidget *w) { return w->d_func(); }
213
214 static void checkRestoredGeometry(const QRect &availableGeometry, QRect *restoredGeometry,
215 int frameHeight);
216
217 QWExtra *extraData() const;
218 QTLWExtra *topData() const;
219 QTLWExtra *maybeTopData() const;
220 QPainter *sharedPainter() const;
221 void setSharedPainter(QPainter *painter);
222 QWidgetRepaintManager *maybeRepaintManager() const;
223
224 enum class WindowHandleMode {
225 Direct,
226 Closest,
227 TopLevel
228 };
229 QWindow *windowHandle(WindowHandleMode mode = WindowHandleMode::Direct) const;
230 QWindow *_q_closestWindowHandle() const; // Private slot in QWidget
231
232 QScreen *associatedScreen() const;
233
234 template <typename T>
235 void repaint(T t);
236
237 template <typename T>
238 void update(T t);
239
240 void init(QWidget *desktopWidget, Qt::WindowFlags f);
241 void create();
242 void createRecursively();
243 void createWinId();
244
245 bool setScreenForPoint(const QPoint &pos);
246 bool setScreen(QScreen *screen);
247
248 void createTLExtra();
249 void createExtra();
250 void deleteExtra();
251 void createSysExtra();
252 void deleteSysExtra();
253 void createTLSysExtra();
254 void deleteTLSysExtra();
255 void updateSystemBackground();
256 void propagatePaletteChange();
257
258 void setPalette_helper(const QPalette &);
259 void resolvePalette();
260 QPalette naturalWidgetPalette(QPalette::ResolveMask inheritedMask) const;
261
262 void setMask_sys(const QRegion &);
263
264 void raise_sys();
265 void lower_sys();
266 void stackUnder_sys(QWidget *);
267
268 QWidget *deepestFocusProxy() const;
269 void setFocus_sys();
270 void updateFocusChild();
271
272 void updateFont(const QFont &);
273 inline void setFont_helper(const QFont &font) {
274 if (directFontResolveMask == font.resolveMask() && data.fnt == font)
275 return;
276 updateFont(font);
277 }
278 QFont localFont() const;
279 void resolveFont();
280 QFont naturalWidgetFont(uint inheritedMask) const;
281
282 void setLayoutDirection_helper(Qt::LayoutDirection);
283 void resolveLayoutDirection();
284
285 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
286 void resolveLocale();
287
288 void setStyle_helper(QStyle *newStyle, bool propagate);
289 void inheritStyle();
290
291 void setUpdatesEnabled_helper(bool );
292
293 bool updateBrushOrigin(QPainter *, const QBrush &brush) const;
294 void paintBackground(QPainter *, const QRegion &, DrawWidgetFlags flags = DrawAsRoot) const;
295 bool isAboutToShow() const;
296 QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
297 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
298 QWidget::RenderFlags renderFlags);
299 void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
300 QWidget::RenderFlags renderFlags);
301 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, DrawWidgetFlags flags,
302 QPainter *sharedPainter = nullptr, QWidgetRepaintManager *repaintManager = nullptr);
303 void sendPaintEvent(const QRegion &toBePainted);
304
305
306 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
307 const QRegion &rgn, const QPoint &offset, DrawWidgetFlags flags,
308 QPainter *sharedPainter, QWidgetRepaintManager *repaintManager);
309
310#if QT_CONFIG(graphicsview)
311 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
312#endif
313 bool shouldPaintOnScreen() const;
314 void paintOnScreen(const QRegion &rgn);
315
316 QRect clipRect() const;
317 QRegion clipRegion() const;
318 void setSystemClip(QPaintEngine *paintEngine, qreal devicePixelRatio, const QRegion &region);
319 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
320 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = nullptr,
321 bool alsoNonOpaque = false) const;
322 void clipToEffectiveMask(QRegion &region) const;
323 void updateIsOpaque();
324 void setOpaque(bool opaque);
325 void updateIsTranslucent();
326#if QT_CONFIG(graphicseffect)
327 void invalidateGraphicsEffectsRecursively();
328#endif // QT_CONFIG(graphicseffect)
329
330 const QRegion &getOpaqueChildren() const;
331 void setDirtyOpaqueRegion();
332
333 bool close();
337 CloseWithSpontaneousEvent
338 };
339 Q_ENUM(CloseMode)
340 bool handleClose(CloseMode mode);
341
342 void setWindowIcon_helper();
343 void setWindowIcon_sys();
344 void setWindowOpacity_sys(qreal opacity);
345 void adjustQuitOnCloseAttribute();
346
347 void scrollChildren(int dx, int dy);
348 void moveRect(const QRect &, int dx, int dy);
349 void scrollRect(const QRect &, int dx, int dy);
350 void invalidateBackingStore_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
351
352 template <class T>
353 void invalidateBackingStore(const T &);
354
355 QRegion overlappedRegion(const QRect &rect, bool breakAfterFirst = false) const;
356 bool isOverlapped(const QRect &rect) const { return !overlappedRegion(rect, true).isEmpty(); }
357 void syncBackingStore();
358 void syncBackingStore(const QRegion &region);
359
360 bool shouldDiscardSyncRequest() const;
361
362 // tells the input method about the widgets transform
363 void updateWidgetTransform(QEvent *event);
364
365 void reparentFocusWidgets(QWidget *oldtlw);
366
367 void setWinId(WId);
368 void showChildren(bool spontaneous);
369 void hideChildren(bool spontaneous);
370 void setParent_sys(QWidget *parent, Qt::WindowFlags);
371 void scroll_sys(int dx, int dy);
372 void scroll_sys(int dx, int dy, const QRect &r);
373 void deactivateWidgetCleanup();
374 void setGeometry_sys(int, int, int, int, bool);
375 void fixPosIncludesFrame();
376 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
377 void activateChildLayoutsRecursively();
378 void show_recursive();
379 void show_helper();
380 void show_sys();
381 void hide_sys();
382 void hide_helper();
383 void _q_showIfNotHidden();
384 void setVisible(bool);
385
386 void setEnabled_helper(bool);
387 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = nullptr);
388
389 void updateFrameStrut();
390 QRect frameStrut() const;
391
392#ifdef QT_KEYPAD_NAVIGATION
393 static bool navigateToDirection(Direction direction);
394 static QWidget *widgetInNavigationDirection(Direction direction);
395 static bool canKeypadNavigate(Qt::Orientation orientation);
396 static bool inTabWidget(QWidget *widget);
397#endif
398
399 void setWindowIconText_sys(const QString &cap);
400 void setWindowIconText_helper(const QString &cap);
401 void setWindowTitle_sys(const QString &cap);
402 void setWindowFilePath_sys(const QString &filePath);
403
404#ifndef QT_NO_CURSOR
405 void setCursor_sys(const QCursor &cursor);
406 void unsetCursor_sys();
407#endif
408
409 void setWindowTitle_helper(const QString &cap);
410 void setWindowFilePath_helper(const QString &filePath);
411 void setWindowModified_helper();
412 virtual void setWindowFlags(Qt::WindowFlags windowFlags);
413
414 bool setMinimumSize_helper(int &minw, int &minh);
415 bool setMaximumSize_helper(int &maxw, int &maxh);
416 void setConstraints_sys();
417 bool pointInsideRectAndMask(const QPoint &) const;
418 QWidget *childAt_helper(const QPoint &, bool) const;
419 QWidget *childAtRecursiveHelper(const QPoint &p, bool) const;
420 void updateGeometry_helper(bool forceUpdate);
421
422 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
423 void setLayoutItemMargins(int left, int top, int right, int bottom);
424 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = nullptr);
425
426 void updateContentsRect();
427 QMargins safeAreaMargins() const;
428
429 // aboutToDestroy() is called just before the contents of
430 // QWidget::destroy() is executed. It's used to signal QWidget
431 // sub-classes that their internals are about to be released.
432 virtual void aboutToDestroy() {}
433
435 QWidget *w = q_func();
436 while (w->focusProxy())
437 w = w->focusProxy();
438 return w;
439 }
440
441 void setModal_sys();
442
443 // These helper functions return the (available) geometry for the screen
444 // the widget is on, and takes care if this one is embedded in a QGraphicsView.
446 {
447#if QT_CONFIG(graphicsview)
448 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
449 //It's embedded if it has an ancestor
450 if (ancestorProxy) {
451 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != nullptr) {
452 if (!ancestorProxy->scene()->views().empty()) {
453 return ancestorProxy->scene()->views().at(0);
454 }
455 }
456 }
457#else
459#endif
460 return nullptr;
461 }
462
464 {
465 return screenGeometry(widget, QPoint(), false);
466 }
467
469 {
470 return availableScreenGeometry(widget, QPoint(), false);
471 }
472
473 static QScreen *screen(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true)
474 {
475 while (QWidget *view = parentGraphicsView(widget))
476 widget = view;
477
478 QScreen *screen = nullptr;
479 if (hasPosition)
480 screen = widget->screen()->virtualSiblingAt(globalPosition);
481 if (!screen)
482 screen = widget->screen();
483
484 return screen;
485 }
486
487 static QRect screenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true)
488 {
489 return screen(widget, globalPosition, hasPosition)->geometry();
490 }
491
492 static QRect availableScreenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true)
493 {
494 return screen(widget, globalPosition, hasPosition)->availableGeometry();
495 }
496
497 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
498 {
499 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
500 redirectDev = replacement;
501 redirectOffset = offset;
502 }
503
505 {
506 if (offset)
507 *offset = redirectDev ? redirectOffset : QPoint();
508 return redirectDev;
509 }
510
511 inline void restoreRedirected()
512 { redirectDev = nullptr; }
513
515 {
516 if (!extra)
517 createExtra();
518
519 if (extra->nativeChildrenForced)
520 return;
521 extra->nativeChildrenForced = 1;
522
523 for (int i = 0; i < children.size(); ++i) {
524 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
525 child->setAttribute(Qt::WA_NativeWindow);
526 }
527 }
528
529 inline bool nativeChildrenForced() const
530 {
531 return extra ? extra->nativeChildrenForced : false;
532 }
533
534 inline QRect effectiveRectFor(const QRegion &region) const
535 {
536 return effectiveRectFor(region.boundingRect());
537 }
538
539 inline QRect effectiveRectFor(const QRect &rect) const
540 {
541#if QT_CONFIG(graphicseffect)
542 if (graphicsEffect && graphicsEffect->isEnabled())
543 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
544#endif // QT_CONFIG(graphicseffect)
545 return rect;
546 }
547
548 QSize adjustedSize() const;
549
550 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
551 {
552 if (button == Qt::LeftButton)
553 handleSoftwareInputPanel(clickCausedFocus);
554 }
555
556 inline void handleSoftwareInputPanel(bool clickCausedFocus = false)
557 {
558 Q_Q(QWidget);
559 if (qApp->autoSipEnabled()) {
561 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
562 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
564 }
565 }
566 }
567
568 void setWSGeometry();
569
570 inline QPoint mapToWS(const QPoint &p) const
571 { return p - data.wrect.topLeft(); }
572
573 inline QPoint mapFromWS(const QPoint &p) const
574 { return p + data.wrect.topLeft(); }
575
576 inline QRect mapToWS(const QRect &r) const
577 { return r.translated(-data.wrect.topLeft()); }
578
579 inline QRect mapFromWS(const QRect &r) const
580 { return r.translated(data.wrect.topLeft()); }
581
582 virtual QObject *focusObject();
583
584 virtual QPlatformBackingStoreRhiConfig rhiConfig() const { return {}; }
585
586 // Note that textureRight may be null, as it's only used in stereoscopic rendering
587 struct TextureData {
588 QRhiTexture *textureLeft = nullptr;
589 QRhiTexture *textureRight = nullptr;
590 };
591
592 virtual TextureData texture() const { return {}; }
593 virtual QPlatformTextureList::Flags textureListFlags() {
594 Q_Q(QWidget);
595 return q->testAttribute(Qt::WA_AlwaysStackOnTop)
597 : QPlatformTextureList::Flags();
598 }
599 virtual QImage grabFramebuffer() { return QImage(); }
600 virtual void beginBackingStorePainting() { }
601 virtual void endBackingStorePainting() { }
602 virtual void beginCompose() { }
603 virtual void endCompose() { }
604 void setRenderToTexture() { renderToTexture = true; setTextureChildSeen(); }
606 {
607 Q_Q(QWidget);
608 if (textureChildSeen)
609 return;
610 textureChildSeen = 1;
611
612 if (!q->isWindow()) {
613 QWidget *parent = q->parentWidget();
614 if (parent)
615 get(parent)->setTextureChildSeen();
616 }
617 }
618 static void sendComposeStatus(QWidget *w, bool end);
619 // Called on setViewport().
621 // When using a QOpenGLWidget as viewport with QAbstractScrollArea, resize events are
622 // filtered away from the widget. This is fine for QGLWidget but bad for QOpenGLWidget
623 // since the fbo must be resized. We need an alternative way to notify.
624 virtual void resizeViewportFramebuffer() { }
625 // Called after each paint event.
626 virtual void resolveSamples() { }
627
628 // These two are used in QGraphicsView for supporting stereoscopic rendering with a
629 // QOpenGLWidget viewport.
630 virtual bool isStereoEnabled() { return false; } // Called in QGraphicsView::setupViewport
631 virtual bool toggleStereoTargetBuffer() { return false; } // Called in QGraphicsView::paintEvent
632
633 static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent);
634
635 std::string flagsForDumping() const override;
636
637 // Variables.
638 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
639 std::unique_ptr<QWExtra> extra;
648 mutable const QMetaObject *polished;
650 // All widgets are added into the allWidgets set. Once
651 // they receive a window id they are also added to the mapper.
652 // This should just ensure that all widgets are deleted by QApplication
655#if !defined(QT_NO_IM)
656 Qt::InputMethodHints imHints;
657#endif
658#ifdef QT_KEYPAD_NAVIGATION
659 static QPointer<QWidget> editingWidget;
660#endif
661
662 // Implicit pointers (shared_null/shared_empty).
665#if QT_CONFIG(tooltip)
666 QString toolTip;
667 int toolTipDuration;
668#endif
669#if QT_CONFIG(statustip)
670 QString statusTip;
671#endif
672#if QT_CONFIG(whatsthis)
673 QString whatsThis;
674#endif
675#if QT_CONFIG(accessibility)
676 QString accessibleName;
677 QString accessibleDescription;
678#endif
679
680 // Other variables.
683 decltype(std::declval<QPalette>().resolveMask()) directPaletteResolveMask;
693 static int instanceCounter; // Current number of widget instances
694 static int maxInstances; // Maximum number of widget instances
700#ifndef QT_NO_ACTION
702#endif
703#ifndef QT_NO_GESTURES
705#endif
706
707 // Bit fields.
708 uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
721#ifndef QT_NO_IM
723#endif
728
729 // *************************** Platform specific ************************************
730#if defined(Q_OS_WIN)
731 uint noPaintOnScreen : 1; // see qwidget.cpp ::paintEngine()
732#elif defined(Q_OS_MAC)
733 void macUpdateSizeAttribute();
734#endif
735 void setNetWmWindowTypes(bool skipIfMissing = false);
736
737 bool stealKeyboardGrab(bool grab);
738 bool stealMouseGrab(bool grab);
739};
740
741Q_DECLARE_OPERATORS_FOR_FLAGS(QWidgetPrivate::DrawWidgetFlags)
742
744{
745 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, QWidgetPrivate::DrawWidgetFlags f,
747 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), repaintManager(rpm), painter(nullptr) {}
748
752 QWidgetPrivate::DrawWidgetFlags flags;
756};
757
758#if QT_CONFIG(graphicseffect)
759class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
760{
761public:
762 QWidgetEffectSourcePrivate(QWidget *widget)
763 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(nullptr), updateDueToGraphicsEffect(false)
764 {}
765
766 void detach() override
767 { m_widget->d_func()->graphicsEffect = nullptr; }
768
769 const QGraphicsItem *graphicsItem() const override
770 { return nullptr; }
771
772 const QWidget *widget() const override
773 { return m_widget; }
774
775 void update() override
776 {
777 updateDueToGraphicsEffect = true;
778 m_widget->update();
779 updateDueToGraphicsEffect = false;
780 }
781
782 bool isPixmap() const override
783 { return false; }
784
785 void effectBoundingRectChanged() override
786 {
787 // ### This function should take a rect parameter; then we can avoid
788 // updating too much on the parent widget.
789 if (QWidget *parent = m_widget->parentWidget())
790 parent->update();
791 else
792 update();
793 }
794
795 const QStyleOption *styleOption() const override
796 { return nullptr; }
797
798 QRect deviceRect() const override
799 { return m_widget->window()->rect(); }
800
801 QRectF boundingRect(Qt::CoordinateSystem system) const override;
802 void draw(QPainter *p) override;
804 QGraphicsEffect::PixmapPadMode mode) const override;
805
806 QWidget *m_widget;
808 QTransform lastEffectTransform;
809 bool updateDueToGraphicsEffect;
810};
811#endif // QT_CONFIG(graphicseffect)
812
814{
815 return extra.get();
816}
817
819{
820 const_cast<QWidgetPrivate *>(this)->createTLExtra();
821 return extra->topextra.get();
822}
823
825{
826 return extra ? extra->topextra.get() : nullptr;
827}
828
830{
831 Q_Q(const QWidget);
832 QTLWExtra *x = q->window()->d_func()->maybeTopData();
833 return x ? x->sharedPainter : nullptr;
834}
835
837{
838 Q_Q(QWidget);
839 QTLWExtra *x = q->window()->d_func()->topData();
840 x->sharedPainter = painter;
841}
842
844{
845 Q_Q(const QWidget);
846 return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
847 || extra->mask.contains(p));
848}
849
851{
852 Q_Q(const QWidget);
853 QTLWExtra *x = q->window()->d_func()->maybeTopData();
854 return x ? x->repaintManager.get() : nullptr;
855}
856
858
859#endif // QWIDGET_P_H
The QBackingStore class provides a drawing area for QWindow.
\inmodule QtGui
Definition qbrush.h:30
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ UpdateLater
Definition qcoreevent.h:114
\reentrant
Definition qfont.h:20
uint resolveMask() const
Definition qfont.h:251
virtual const QGraphicsItem * graphicsItem() const =0
virtual bool isPixmap() const =0
virtual QRectF boundingRect(Qt::CoordinateSystem system) const =0
virtual const QStyleOption * styleOption() const =0
virtual void draw(QPainter *p)=0
virtual QRect deviceRect() const =0
virtual void effectBoundingRectChanged()=0
virtual const QWidget * widget() const =0
The QGraphicsEffect class is the base class for all graphics effects.
PixmapPadMode
This enum describes how the pixmap returned from sourcePixmap should be padded.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
QGraphicsScene * scene() const
Returns the current scene for the item, or \nullptr if the item is not stored in a scene.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
QList< QGraphicsView * > views() const
Returns a list of all the views that display this scene.
static QInputMethod * inputMethod()
returns the input method.
\inmodule QtGui
Definition qimage.h:37
void show()
Requests virtual keyboard to open.
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
bool empty() const noexcept
Definition qlist.h:682
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
Definition qmap.h:186
\inmodule QtCore
Definition qmargins.h:23
ExtraData * extraData
Definition qobject_p.h:196
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
virtual std::string flagsForDumping() const
Definition qobject.cpp:4228
\inmodule QtCore
Definition qobject.h:90
\inmodule QtGui
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
quint64 ResolveMask
Definition qpalette.h:112
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:260
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
\inmodule QtGui
Definition qrhi.h:883
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QRect availableGeometry
the screen's available geometry in pixels
Definition qscreen.h:46
QRect geometry
the screen's geometry in pixels
Definition qscreen.h:45
QScreen * virtualSiblingAt(QPoint point)
Returns the screen at point within the set of \l QScreen::virtualSiblings(), or nullptr if outside of...
Definition qscreen.cpp:629
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QStyleOption class stores the parameters used by QStyle functions.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ SH_RequestSoftwareInputPanel
Definition qstyle.h:678
RequestSoftwareInputPanel
This enum describes under what circumstances a software input panel will be requested by input capabl...
Definition qstyle.h:576
@ RSIP_OnMouseClick
Definition qstyle.h:578
SubElement
This enum represents a sub-area of a widget.
Definition qstyle.h:242
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
const QRegion & region() const
Definition qwidget_p.h:82
QUpdateLaterEvent(const QRegion &paintRegion)
Definition qwidget_p.h:73
uint mustHaveWindowHandle
Definition qwidget_p.h:718
static const QWidgetPrivate * get(const QWidget *w)
Definition qwidget_p.h:212
uint dirtyOpaqueChildren
Definition qwidget_p.h:711
const QMetaObject * polished
Definition qwidget_p.h:648
QTLWExtra * maybeTopData() const
Definition qwidget_p.h:824
QRegion * needsFlush
Definition qwidget_p.h:644
static int instanceCounter
Definition qwidget_p.h:693
uint inheritedFontResolveMask
Definition qwidget_p.h:682
QWidget * focus_next
Definition qwidget_p.h:640
QWidgetData data
Definition qwidget_p.h:696
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
Definition qwidget_p.h:704
bool isOverlapped(const QRect &rect) const
Definition qwidget_p.h:356
QRect mapFromWS(const QRect &r) const
Definition qwidget_p.h:579
QList< QAction * > actions
Definition qwidget_p.h:701
void createTLExtra()
Definition qwidget.cpp:1582
uint usesDoubleBufferedGLContext
Definition qwidget_p.h:717
virtual bool isStereoEnabled()
Definition qwidget_p.h:630
uint childrenHiddenByWState
Definition qwidget_p.h:726
signed char leftLayoutItemMargin
Definition qwidget_p.h:689
virtual void beginBackingStorePainting()
Definition qwidget_p.h:600
uint childrenShownByExpose
Definition qwidget_p.h:727
QPalette::ResolveMask inheritedPaletteResolveMask
Definition qwidget_p.h:684
virtual QImage grabFramebuffer()
Definition qwidget_p.h:599
uint renderToTextureReallyDirty
Definition qwidget_p.h:724
virtual void endBackingStorePainting()
Definition qwidget_p.h:601
virtual QPlatformBackingStoreRhiConfig rhiConfig() const
Definition qwidget_p.h:584
QRect effectiveRectFor(const QRect &rect) const
Definition qwidget_p.h:539
QPaintDevice * redirectDev
Definition qwidget_p.h:645
static QWidgetMapper * mapper
Definition qwidget_p.h:653
void restoreRedirected()
Definition qwidget_p.h:511
void setSharedPainter(QPainter *painter)
Definition qwidget_p.h:836
uint retainSizeWhenHiddenChanged
Definition qwidget_p.h:713
QPalette::ColorRole bg_role
Definition qwidget_p.h:710
static QWidgetPrivate * get(QWidget *w)
Definition qwidget_p.h:211
uint inheritsInputMethodHints
Definition qwidget_p.h:722
signed char topLayoutItemMargin
Definition qwidget_p.h:690
QPoint mapFromWS(const QPoint &p) const
Definition qwidget_p.h:573
QPoint mapToWS(const QPoint &p) const
Definition qwidget_p.h:570
QWidgetRepaintManager * maybeRepaintManager() const
Definition qwidget_p.h:850
short bottommargin
Definition qwidget_p.h:688
void handleSoftwareInputPanel(bool clickCausedFocus=false)
Definition qwidget_p.h:556
virtual void aboutToDestroy()
Definition qwidget_p.h:432
QPaintEngine * extraPaintEngine
Definition qwidget_p.h:647
static QRect screenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition=true)
Definition qwidget_p.h:487
std::unique_ptr< QWExtra > extra
Definition qwidget_p.h:639
bool nativeChildrenForced() const
Definition qwidget_p.h:529
QRect mapToWS(const QRect &r) const
Definition qwidget_p.h:576
virtual void resizeViewportFramebuffer()
Definition qwidget_p.h:624
void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
Definition qwidget_p.h:550
signed char bottomLayoutItemMargin
Definition qwidget_p.h:692
QRegion dirty
Definition qwidget_p.h:664
QLocale locale
Definition qwidget_p.h:698
QGraphicsEffect * graphicsEffect
Definition qwidget_p.h:649
signed char rightLayoutItemMargin
Definition qwidget_p.h:691
uint textureChildSeen
Definition qwidget_p.h:720
void setRedirected(QPaintDevice *replacement, const QPoint &offset)
Definition qwidget_p.h:497
static QRect availableScreenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition=true)
Definition qwidget_p.h:492
static QWidget * parentGraphicsView(const QWidget *widget)
Definition qwidget_p.h:445
QWidget * focus_child
Definition qwidget_p.h:642
QPalette::ColorRole fg_role
Definition qwidget_p.h:709
virtual void beginCompose()
Definition qwidget_p.h:602
QRegion opaqueChildren
Definition qwidget_p.h:663
bool pointInsideRectAndMask(const QPoint &) const
Definition qwidget_p.h:843
Qt::HANDLE hd
Definition qwidget_p.h:695
QWidgetItemV2 * widgetItem
Definition qwidget_p.h:646
short rightmargin
Definition qwidget_p.h:687
virtual void resolveSamples()
Definition qwidget_p.h:626
void enforceNativeChildren()
Definition qwidget_p.h:514
QWExtra * extraData() const
Definition qwidget_p.h:813
void setRenderToTexture()
Definition qwidget_p.h:604
static QRect screenGeometry(const QWidget *widget)
Definition qwidget_p.h:463
uint renderToTexture
Definition qwidget_p.h:719
QRect effectiveRectFor(const QRegion &region) const
Definition qwidget_p.h:534
QWidget * focus_prev
Definition qwidget_p.h:641
virtual void initializeViewportFramebuffer()
Definition qwidget_p.h:620
QSizePolicy size_policy
Definition qwidget_p.h:697
QWidget * effectiveFocusWidget()
Definition qwidget_p.h:434
static QScreen * screen(const QWidget *widget, const QPoint &globalPosition, bool hasPosition=true)
Definition qwidget_p.h:473
QTLWExtra * topData() const
Definition qwidget_p.h:818
QPoint redirectOffset
Definition qwidget_p.h:699
QPaintDevice * redirected(QPoint *offset) const
Definition qwidget_p.h:504
QPainter * sharedPainter() const
Definition qwidget_p.h:829
virtual bool toggleStereoTargetBuffer()
Definition qwidget_p.h:631
uint directFontResolveMask
Definition qwidget_p.h:681
virtual QPlatformTextureList::Flags textureListFlags()
Definition qwidget_p.h:593
Qt::InputMethodHints imHints
Definition qwidget_p.h:656
void setFont_helper(const QFont &font)
Definition qwidget_p.h:273
static int maxInstances
Definition qwidget_p.h:694
virtual TextureData texture() const
Definition qwidget_p.h:592
static QRect availableScreenGeometry(const QWidget *widget)
Definition qwidget_p.h:468
void setTextureChildSeen()
Definition qwidget_p.h:605
virtual void endCompose()
Definition qwidget_p.h:603
QLayout * layout
Definition qwidget_p.h:643
static QWidgetSet * allWidgets
Definition qwidget_p.h:654
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QScreen * screen() const
Returns the screen the widget is on.
Definition qwidget.cpp:2503
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
QPushButton * button
[2]
QCursor cursor
rect
[4]
direction
QStyleOptionButton opt
Combined button and popup list for selecting options.
MouseButton
Definition qnamespace.h:55
@ LeftButton
Definition qnamespace.h:57
@ WA_AlwaysStackOnTop
Definition qnamespace.h:410
@ WA_NativeWindow
Definition qnamespace.h:377
@ WA_WState_InPaintEvent
Definition qnamespace.h:328
@ WA_MouseNoMask
Definition qnamespace.h:337
LayoutDirection
Orientation
Definition qnamespace.h:97
void * HANDLE
CoordinateSystem
@ BypassGraphicsProxyWidget
Definition qnamespace.h:242
ShortcutContext
Definition brush.cpp:5
static void * context
#define qApp
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define Q_DECLARE_LOGGING_CATEGORY(name)
static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
@ QObjectPrivateVersion
Definition qobject_p.h:61
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLboolean r
[2]
GLuint GLuint end
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLfloat GLfloat f
GLint left
GLint GLint bottom
GLenum target
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLenum cap
void forceUpdate(QQuickItem *item)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScreen * screen
[1]
Definition main.cpp:29
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_ENUM(x)
#define Q_FLAG(x)
#define Q_GADGET
#define Q_UNUSED(x)
unsigned short quint16
Definition qtypes.h:43
int qint32
Definition qtypes.h:44
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QWidget * qobject_cast< QWidget * >(QObject *o)
Definition qwidget.h:786
bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
void qSendWindowChangeToTextureChildrenRecursively(QWidget *widget, QEvent::Type eventType)
static bool bypassGraphicsProxyWidget(const QWidget *p)
Definition qwidget_p.h:168
QT_BEGIN_NAMESPACE typedef QHash< WId, QWidget * > QWidgetMapper
Definition qwindowdefs.h:68
QObject::connect nullptr
QLayoutItem * child
[0]
widget render & pixmap
QPainter painter(this)
[7]
myWidget render(this)
QQuickView * view
[0]
view create()
\inmodule QtCore
QRect frameStrut
Definition qwidget_p.h:108
QString role
Definition qwidget_p.h:101
QString iconText
Definition qwidget_p.h:100
QString caption
Definition qwidget_p.h:99
std::unique_ptr< QWidgetRepaintManager > repaintManager
Definition qwidget_p.h:93
uint posIncludesFrame
Definition qwidget_p.h:117
QRect normalGeometry
Definition qwidget_p.h:109
Qt::WindowFlags savedFlags
Definition qwidget_p.h:110
QPainter * sharedPainter
Definition qwidget_p.h:95
std::unique_ptr< QIcon > icon
Definition qwidget_p.h:92
uint opacity
Definition qwidget_p.h:116
std::vector< std::unique_ptr< QPlatformTextureList > > widgetTextures
Definition qwidget_p.h:113
uint sizeAdjusted
Definition qwidget_p.h:118
short baseh
Definition qwidget_p.h:106
QScreen * initialScreen
Definition qwidget_p.h:111
QBackingStore * backingStore
Definition qwidget_p.h:94
QString filePath
Definition qwidget_p.h:102
short inch
Definition qwidget_p.h:105
short basew
Definition qwidget_p.h:106
QWidgetWindow * window
Definition qwidget_p.h:96
uint embedded
Definition qwidget_p.h:119
short incw
Definition qwidget_p.h:105
uint hasMask
Definition qwidget_p.h:156
uint hasWindowContainer
Definition qwidget_p.h:157
QString styleSheet
Definition qwidget_p.h:139
QRegion mask
Definition qwidget_p.h:138
qint32 minw
Definition qwidget_p.h:142
QSize staticContentsSize
Definition qwidget_p.h:148
QPointer< QWidget > focus_proxy
Definition qwidget_p.h:135
uint inRenderWithPainter
Definition qwidget_p.h:155
qint32 maxh
Definition qwidget_p.h:145
quint16 customDpiY
Definition qwidget_p.h:147
uint nativeChildrenForced
Definition qwidget_p.h:154
quint16 customDpiX
Definition qwidget_p.h:146
std::unique_ptr< QTLWExtra > topextra
Definition qwidget_p.h:127
void * glContext
Definition qwidget_p.h:126
std::unique_ptr< QCursor > curs
Definition qwidget_p.h:132
uint explicitMinSize
Definition qwidget_p.h:151
uint autoFillBackground
Definition qwidget_p.h:153
QPointer< QStyle > style
Definition qwidget_p.h:134
uint explicitMaxSize
Definition qwidget_p.h:152
qint32 maxw
Definition qwidget_p.h:144
qint32 minh
Definition qwidget_p.h:143
QWidgetRepaintManager * repaintManager
Definition qwidget_p.h:754
QPainter * painter
Definition qwidget_p.h:755
QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, QWidgetPrivate::DrawWidgetFlags f, QPainter *p, QWidgetRepaintManager *rpm)
Definition qwidget_p.h:745
QPaintDevice * pdev
Definition qwidget_p.h:749
QWidgetPrivate::DrawWidgetFlags flags
Definition qwidget_p.h:752
QPainter * sharedPainter
Definition qwidget_p.h:753
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent