66 Q_DECLARE_PUBLIC(QGuiApplication)
68 QGuiApplicationPrivate(
int &argc,
char **argv);
69 ~QGuiApplicationPrivate();
73 void createPlatformIntegration();
74 void createEventDispatcher() override;
75 void eventDispatcherReady() override;
77 virtual void notifyLayoutDirectionChange();
78 virtual void notifyActiveWindowChange(QWindow *previous);
80#if QT_CONFIG(commandlineparser)
81 void addQtOptions(QList<QCommandLineOption> *options) override;
83 bool canQuitAutomatically() override;
85 bool handleQuitEvent() override;
87 void maybeLastWindowClosed();
88 bool lastWindowClosed()
const;
89 static bool quitOnLastWindowClosed;
91 static void captureGlobalModifierState(QEvent *e);
92 static Qt::KeyboardModifiers modifier_buttons;
93 static Qt::MouseButtons mouse_buttons;
95 static QPlatformIntegration *platform_integration;
97 static QPlatformIntegration *platformIntegration()
98 {
return platform_integration; }
100 static QPlatformTheme *platform_theme;
102 static QPlatformTheme *platformTheme()
103 {
return platform_theme; }
105 static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
107 if (QCoreApplication::instance())
108 return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed();
113 static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
114 static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
115 static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
116 static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
118 static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
120 static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
122 static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
123 static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
125 static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e);
127 static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
128 static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
129 static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e);
131 static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e);
133 static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
135 static void processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
137 static void updateFilteredScreenOrientation(QScreen *screen);
138 static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
139 static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
140 static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
141 static void processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e);
142 static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
144 static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
145 static void processPaintEvent(QWindowSystemInterfacePrivate::PaintEvent *e);
147 static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
149 static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e);
150 static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e);
151 static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
153#ifndef QT_NO_GESTURES
154 static void processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e);
157 static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e);
158#ifndef QT_NO_CONTEXTMENU
159 static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
162#if QT_CONFIG(draganddrop)
163 static QPlatformDragQtResponse processDrag(QWindow *w,
const QMimeData *dropData,
164 const QPoint &p, Qt::DropActions supportedActions,
165 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
166 static QPlatformDropQtResponse processDrop(QWindow *w,
const QMimeData *dropData,
167 const QPoint &p, Qt::DropActions supportedActions,
168 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
171 static bool processNativeEvent(QWindow *window,
const QByteArray &eventType,
void *message, qintptr *result);
173 static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
175 static bool maybeForwardEventToVirtualKeyboard(QEvent *e);
176 static bool isUsingVirtualKeyboard();
178 static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
180 if (!(alignment & Qt::AlignHorizontal_Mask))
181 alignment |= Qt::AlignLeft;
182 if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
183 if (direction == Qt::RightToLeft)
184 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
185 alignment |= Qt::AlignAbsolute;
190 QPixmap getPixmapCursor(Qt::CursorShape cshape);
192 void _q_updateFocusObject(QObject *object);
194 static QGuiApplicationPrivate *instance() { QT_IGNORE_DEPRECATIONS(
return self;) }
196 static QIcon *app_icon;
197 static QString *platform_name;
198 static QString *displayName;
199 static QString *desktopFileName;
201 QWindowList modalWindowList;
202 static void showModalWindow(QWindow *window);
203 static void hideModalWindow(QWindow *window);
204 static void updateBlockedStatus(QWindow *window);
206 virtual Qt::WindowModality defaultModality()
const;
207 virtual bool windowNeverBlocked(QWindow *window)
const;
208 bool isWindowBlocked(QWindow *window, QWindow **blockingWindow =
nullptr)
const;
209 static qsizetype popupCount() {
return QGuiApplicationPrivate::popup_list.size(); }
210 static QWindow *activePopupWindow();
211 static void activatePopup(QWindow *popup);
212 static bool closePopup(QWindow *popup);
213 static bool closeAllPopups();
215 static Qt::MouseButton mousePressButton;
216 static struct QLastCursorPosition {
219 constexpr inline QLastCursorPosition()
noexcept : thePoint(1 << 23, 1 << 23) {}
220 constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p)
noexcept : thePoint(p) {}
221 constexpr inline Q_IMPLICIT operator QPointF()
const noexcept {
return thePoint; }
222 constexpr inline qreal x()
const noexcept{
return thePoint.x(); }
223 constexpr inline qreal y()
const noexcept{
return thePoint.y(); }
224 Q_GUI_EXPORT QPoint toPoint()
const noexcept;
226 constexpr void reset()
noexcept { *
this = QLastCursorPosition{}; }
232 friend constexpr bool operator==(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
234 return QtPrivate::fuzzyCompare(
float(p1.x()),
float(p2.x()))
235 && QtPrivate::fuzzyCompare(
float(p1.y()),
float(p2.y()));
237 friend constexpr bool operator!=(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
241 friend constexpr bool operator==(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
245 friend constexpr bool operator!=(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
252 } lastCursorPosition;
253 static QWindow *currentMouseWindow;
254 static QWindow *currentMousePressWindow;
255 static Qt::ApplicationState applicationState;
256 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy;
257 static QPointer<QWindow> currentDragWindow;
260 struct TabletPointData {
261 TabletPointData(qint64 devId = 0) : deviceId(devId), state(Qt::NoButton), target(
nullptr) {}
263 Qt::MouseButtons state;
266 static QList<TabletPointData> tabletDevicePoints;
267 static TabletPointData &tabletDevicePoint(qint64 deviceId);
269#ifndef QT_NO_CLIPBOARD
270 static QClipboard *qt_clipboard;
273 static QPalette *app_pal;
275 static QWindowList window_list;
276 static QWindowList popup_list;
277 static const QWindow *active_popup_on_press;
278 static QWindow *focus_window;
281 QList<QCursor> cursor_list;
283 static QList<QScreen *> screen_list;
285 static QFont *app_font;
287 static QString styleOverride;
288 static QStyleHints *styleHints;
289 static bool obey_desktop_settings;
290 static bool popup_closed_on_press;
291 QInputMethod *inputMethod;
293 QString firstWindowTitle;
294 QIcon forcedWindowIcon;
295 qint64 badgeNumber = 0;
297 static QList<QObject *> generic_plugin_list;
298#if QT_CONFIG(shortcut)
299 QShortcutMap shortcutMap;
302#ifndef QT_NO_SESSIONMANAGER
303 QSessionManager *session_manager;
304 bool is_session_restored;
305 bool is_saving_session;
310 QEvent::Type lastTouchType;
311 struct SynthesizedMouseData {
312 SynthesizedMouseData(
const QPointF &p,
const QPointF &sp, QWindow *w)
313 : pos(p), screenPos(sp), window(w) { }
316 QPointer<QWindow> window;
318 QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
320 static QInputDeviceManager *inputDeviceManager();
322 const QColorTrcLut *colorProfileForA8Text();
323 const QColorTrcLut *colorProfileForA32Text();
326 virtual QPixmap applyQIconStyleHelper(QIcon::Mode,
const QPixmap &basePixmap)
const {
return basePixmap; }
328 virtual void notifyWindowIconChanged();
330 static void applyWindowGeometrySpecificationTo(QWindow *window);
332 static void setApplicationState(Qt::ApplicationState state,
bool forcePropagate =
false);
334 static void resetCachedDevicePixelRatio();
337 virtual QActionPrivate *createActionPrivate()
const;
339#ifndef QT_NO_SHORTCUT
340 virtual QShortcutPrivate *createShortcutPrivate()
const;
343 static void updatePalette();
345 static QEvent::Type contextMenuEventType();
347 static QThreadPool *qtGuiThreadPool();
350 bool ownGlobalShareContext =
false;
353 void _q_updatePrimaryScreenDpis();
354 static QBasicAtomicInt m_primaryScreenDpis;
357 virtual void handleThemeChanged();
359 static bool setPalette(
const QPalette &palette);
360 virtual QPalette basePalette()
const;
361 virtual void handlePaletteChanged(
const char *className =
nullptr);
363#if QT_CONFIG(draganddrop)
364 virtual void notifyDragStarted(
const QDrag *);
368 static void clearPalette();
370 friend class QDragManager;
371 friend class QWindowPrivate;
373 static QGuiApplicationPrivate *self;
374 static int m_fakeMouseSourcePointId;
376 std::shared_ptr<QColorTrcLut> m_a8ColorProfile;
378 std::shared_ptr<QColorTrcLut> m_a32ColorProfile;
380 static QInputDeviceManager *m_inputDeviceManager;
384 static qreal m_maxDevicePixelRatio;