Coverage Report

Created: 2026-10-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qwindow_p.h
Line
Count
Source
1
// Copyright (C) 2016 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
// Qt-Security score:significant reason:default
4
5
#ifndef QWINDOW_P_H
6
#define QWINDOW_P_H
7
8
//
9
//  W A R N I N G
10
//  -------------
11
//
12
// This file is not part of the Qt API.  It exists purely as an
13
// implementation detail.  This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#include <QtGui/private/qtguiglobal_p.h>
20
#include <QtGui/qscreen.h>
21
#include <QtGui/qwindow.h>
22
#include <qpa/qplatformwindow.h>
23
24
#include <QtCore/private/qobject_p.h>
25
#include <QtCore/qelapsedtimer.h>
26
#include <QtCore/qxpfunctional.h>
27
#include <QtGui/qicon.h>
28
#include <QtGui/qpalette.h>
29
30
#include <QtCore/qpointer.h>
31
32
QT_BEGIN_NAMESPACE
33
34
class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
35
{
36
0
    Q_DECLARE_PUBLIC(QWindow)
Unexecuted instantiation: QWindowPrivate::q_func()
Unexecuted instantiation: QWindowPrivate::q_func() const
37
0
    Q_GADGET
38
0
39
0
public:
40
0
    enum PositionPolicy
41
0
    {
42
0
        WindowFrameInclusive,
43
0
        WindowFrameExclusive
44
0
    };
45
0
    Q_ENUM(PositionPolicy)
Unexecuted instantiation: qt_getEnumMetaObject(QWindowPrivate::PositionPolicy)
Unexecuted instantiation: qt_getEnumName(QWindowPrivate::PositionPolicy)
46
0
47
0
    QWindowPrivate(decltype(QObjectPrivateVersion) version = QObjectPrivateVersion);
48
0
    ~QWindowPrivate() override;
49
0
50
0
    void init(QWindow *parent, QScreen *targetScreen = nullptr);
51
0
52
0
#ifndef QT_NO_CURSOR
53
0
    void setCursor(const QCursor *c = nullptr);
54
0
    bool applyCursor();
55
0
#endif
56
0
57
0
    QPoint globalPosition() const;
58
0
59
0
    QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const;
60
0
61
0
    virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
62
0
    virtual QPalette windowPalette() const { return QPalette(); }
63
64
    virtual void setVisible(bool visible);
65
    void updateVisibility();
66
    void _q_clearAlert();
67
68
    enum SiblingPosition { PositionTop, PositionBottom };
69
    void updateSiblingPosition(SiblingPosition);
70
71
    bool windowRecreationRequired(QScreen *newScreen) const;
72
    void create(bool recursive);
73
    void destroy();
74
    void setTopLevelScreen(QScreen *newScreen, bool recreate);
75
    void connectToScreen(QScreen *topLevelScreen);
76
    void disconnectFromScreen();
77
    void emitScreenChangedRecursion(QScreen *newScreen);
78
    QScreen *screenForGeometry(const QRect &rect) const;
79
    void setTransientParent(QWindow *parent);
80
81
#if QT_CONFIG(accessibility)
82
    void setAccessibleParent(QObject *parent);
83
#endif
84
85
    virtual void clearFocusObject();
86
87
    enum class FocusTarget {
88
        First,
89
        Last,
90
        Current,
91
        Next,
92
        Prev
93
    };
94
0
    virtual void setFocusToTarget(FocusTarget, Qt::FocusReason) {}
95
96
    virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
97
98
    void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size,
99
                         qxp::function_ref<void()> funcWidthChanged,
100
                         qxp::function_ref<void()> funcHeightChanged);
101
102
    virtual bool participatesInLastWindowClosed() const;
103
    virtual bool treatAsVisible() const;
104
105
    virtual void maybeSynthesizeContextMenuEvent(QMouseEvent *event);
106
107
    const QWindow *forwardToPopup(QEvent *event, const QWindow *activePopupOnPress);
108
109
0
    bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
110
    void setAutomaticPositionAndResizeEnabled(bool a)
111
0
    { positionAutomatic = resizeAutomatic = a; }
112
113
    bool updateDevicePixelRatio();
114
115
0
    static QWindowPrivate *get(QWindow *window) { return window->d_func(); }
116
117
    static Qt::WindowState effectiveState(Qt::WindowStates);
118
119
    QWindow::SurfaceType surfaceType = QWindow::RasterSurface;
120
    Qt::WindowFlags windowFlags = Qt::Window;
121
    QWindow *parentWindow = nullptr;
122
    QPlatformWindow *platformWindow = nullptr;
123
    bool visible= false;
124
    bool visibilityOnDestroy = false;
125
    bool exposed = false;
126
    bool inClose = false;
127
    QSurfaceFormat requestedFormat;
128
    QString windowTitle;
129
    QString windowFilePath;
130
    QIcon windowIcon;
131
    QRect geometry;
132
    qreal devicePixelRatio = 1.0;
133
    Qt::WindowStates windowState = Qt::WindowNoState;
134
    QWindow::Visibility visibility = QWindow::Hidden;
135
    bool resizeEventPending = true;
136
    bool receivedExpose = false;
137
    PositionPolicy positionPolicy = WindowFrameExclusive;
138
    bool positionAutomatic = true;
139
    // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry().
140
    // It also indicates that width/height=0 is acceptable (for example, for
141
    // the QRollEffect widget) and is thus not cleared in setGeometry().
142
    // An alternative approach might be using -1,-1 as a default size.
143
    bool resizeAutomatic = true;
144
    Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation;
145
    qreal opacity= 1;
146
    QRegion mask;
147
148
    QSize minimumSize = {0, 0};
149
    QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX};
150
    QSize baseSize;
151
    QSize sizeIncrement;
152
153
    Qt::WindowModality modality = Qt::NonModal;
154
    bool blockedByModalWindow = false;
155
156
    bool updateRequestPending = false;
157
    bool transientParentPropertySet = false;
158
159
    QPointer<QWindow> transientParent;
160
    QPointer<QScreen> topLevelScreen;
161
162
#if QT_CONFIG(accessibility)
163
    QPointer<QObject> accessibleParent;
164
#endif
165
166
#ifndef QT_NO_CURSOR
167
    QCursor cursor = {Qt::ArrowCursor};
168
    bool hasCursor = false;
169
#endif
170
171
    QElapsedTimer lastComposeTime;
172
173
#if QT_CONFIG(vulkan)
174
    QVulkanInstance *vulkanInstance = nullptr;
175
#endif
176
};
177
178
179
QT_END_NAMESPACE
180
181
#endif // QWINDOW_P_H