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;
86 void maybeLastWindowClosed();
87 bool lastWindowClosed()
const;
88 static bool quitOnLastWindowClosed;
90 static void captureGlobalModifierState(QEvent *e);
91 static Qt::KeyboardModifiers modifier_buttons;
92 static Qt::MouseButtons mouse_buttons;
94 static QPlatformIntegration *platform_integration;
96 static QPlatformIntegration *platformIntegration()
97 {
return platform_integration; }
99 static QPlatformTheme *platform_theme;
101 static QPlatformTheme *platformTheme()
102 {
return platform_theme; }
104 static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
106 if (QCoreApplication::instance())
107 return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed();
112 static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
113 static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
114 static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
115 static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
117 static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
119 static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
121 static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
122 static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
124 static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e);
126 static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
127 static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
128 static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e);
130 static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e);
132 static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
134 static void processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
136 static void updateFilteredScreenOrientation(QScreen *screen);
137 static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
138 static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
139 static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
140 static void processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e);
141 static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
143 static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
144 static void processPaintEvent(QWindowSystemInterfacePrivate::PaintEvent *e);
146 static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
148 static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e);
149 static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e);
150 static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
152#ifndef QT_NO_GESTURES
153 static void processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e);
156 static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e);
157#ifndef QT_NO_CONTEXTMENU
158 static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
161#if QT_CONFIG(draganddrop)
162 static QPlatformDragQtResponse processDrag(QWindow *w,
const QMimeData *dropData,
163 const QPoint &p, Qt::DropActions supportedActions,
164 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
165 static QPlatformDropQtResponse processDrop(QWindow *w,
const QMimeData *dropData,
166 const QPoint &p, Qt::DropActions supportedActions,
167 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
170 static bool processNativeEvent(QWindow *window,
const QByteArray &eventType,
void *message, qintptr *result);
172 static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
174 static bool maybeForwardEventToVirtualKeyboard(QEvent *e);
175 static bool isUsingVirtualKeyboard();
177 static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
179 if (!(alignment & Qt::AlignHorizontal_Mask))
180 alignment |= Qt::AlignLeft;
181 if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
182 if (direction == Qt::RightToLeft)
183 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
184 alignment |= Qt::AlignAbsolute;
189 QPixmap getPixmapCursor(Qt::CursorShape cshape);
191 void _q_updateFocusObject(QObject *object);
193 static QGuiApplicationPrivate *instance() { QT_IGNORE_DEPRECATIONS(
return self;) }
195 static QIcon *app_icon;
196 static QString *platform_name;
197 static QString *displayName;
198 static QString *desktopFileName;
200 QWindowList modalWindowList;
201 static void showModalWindow(QWindow *window);
202 static void hideModalWindow(QWindow *window);
203 static void updateBlockedStatus(QWindow *window);
205 virtual Qt::WindowModality defaultModality()
const;
206 virtual bool windowNeverBlocked(QWindow *window)
const;
207 bool isWindowBlocked(QWindow *window, QWindow **blockingWindow =
nullptr)
const;
208 static qsizetype popupCount() {
return QGuiApplicationPrivate::popup_list.size(); }
209 static QWindow *activePopupWindow();
210 static void activatePopup(QWindow *popup);
211 static bool closePopup(QWindow *popup);
212 static bool closeAllPopups();
214 static Qt::MouseButton mousePressButton;
215 static struct QLastCursorPosition {
218 constexpr inline QLastCursorPosition()
noexcept : thePoint(1 << 23, 1 << 23) {}
219 constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p)
noexcept : thePoint(p) {}
220 constexpr inline Q_IMPLICIT operator QPointF()
const noexcept {
return thePoint; }
221 constexpr inline qreal x()
const noexcept{
return thePoint.x(); }
222 constexpr inline qreal y()
const noexcept{
return thePoint.y(); }
223 Q_GUI_EXPORT QPoint toPoint()
const noexcept;
225 constexpr void reset()
noexcept { *
this = QLastCursorPosition{}; }
231 friend constexpr bool operator==(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
233 return QtPrivate::fuzzyCompare(
float(p1.x()),
float(p2.x()))
234 && QtPrivate::fuzzyCompare(
float(p1.y()),
float(p2.y()));
236 friend constexpr bool operator!=(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
240 friend constexpr bool operator==(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
244 friend constexpr bool operator!=(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
251 } lastCursorPosition;
252 static QWindow *currentMouseWindow;
253 static QWindow *currentMousePressWindow;
254 static Qt::ApplicationState applicationState;
255 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy;
256 static QPointer<QWindow> currentDragWindow;
259 struct TabletPointData {
260 TabletPointData(qint64 devId = 0) : deviceId(devId), state(Qt::NoButton), target(
nullptr) {}
262 Qt::MouseButtons state;
265 static QList<TabletPointData> tabletDevicePoints;
266 static TabletPointData &tabletDevicePoint(qint64 deviceId);
268#ifndef QT_NO_CLIPBOARD
269 static QClipboard *qt_clipboard;
272 static QPalette *app_pal;
274 static QWindowList window_list;
275 static QWindowList popup_list;
276 static const QWindow *active_popup_on_press;
277 static QWindow *focus_window;
280 QList<QCursor> cursor_list;
282 static QList<QScreen *> screen_list;
284 static QFont *app_font;
286 static QString styleOverride;
287 static QStyleHints *styleHints;
288 static bool obey_desktop_settings;
289 static bool popup_closed_on_press;
290 QInputMethod *inputMethod;
292 QString firstWindowTitle;
293 QIcon forcedWindowIcon;
295 static QList<QObject *> generic_plugin_list;
296#if QT_CONFIG(shortcut)
297 QShortcutMap shortcutMap;
300#ifndef QT_NO_SESSIONMANAGER
301 QSessionManager *session_manager;
302 bool is_session_restored;
303 bool is_saving_session;
308 QEvent::Type lastTouchType;
309 struct SynthesizedMouseData {
310 SynthesizedMouseData(
const QPointF &p,
const QPointF &sp, QWindow *w)
311 : pos(p), screenPos(sp), window(w) { }
314 QPointer<QWindow> window;
316 QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
318 static QInputDeviceManager *inputDeviceManager();
320 const QColorTrcLut *colorProfileForA8Text();
321 const QColorTrcLut *colorProfileForA32Text();
324 virtual QPixmap applyQIconStyleHelper(QIcon::Mode,
const QPixmap &basePixmap)
const {
return basePixmap; }
326 virtual void notifyWindowIconChanged();
328 static void applyWindowGeometrySpecificationTo(QWindow *window);
330 static void setApplicationState(Qt::ApplicationState state,
bool forcePropagate =
false);
332 static void resetCachedDevicePixelRatio();
335 virtual QActionPrivate *createActionPrivate()
const;
337#ifndef QT_NO_SHORTCUT
338 virtual QShortcutPrivate *createShortcutPrivate()
const;
341 static void updatePalette();
343 static QEvent::Type contextMenuEventType();
345 static QThreadPool *qtGuiThreadPool();
348 bool ownGlobalShareContext =
false;
351 void _q_updatePrimaryScreenDpis();
352 static QBasicAtomicInt m_primaryScreenDpis;
355 virtual void handleThemeChanged();
357 static bool setPalette(
const QPalette &palette);
358 virtual QPalette basePalette()
const;
359 virtual void handlePaletteChanged(
const char *className =
nullptr);
361#if QT_CONFIG(draganddrop)
362 virtual void notifyDragStarted(
const QDrag *);
366 static void clearPalette();
368 friend class QDragManager;
369 friend class QWindowPrivate;
371 static QGuiApplicationPrivate *self;
372 static int m_fakeMouseSourcePointId;
374 std::shared_ptr<QColorTrcLut> m_a8ColorProfile;
376 std::shared_ptr<QColorTrcLut> m_a32ColorProfile;
378 static QInputDeviceManager *m_inputDeviceManager;
382 static qreal m_maxDevicePixelRatio;