64 Q_DECLARE_PUBLIC(QGuiApplication)
66 QGuiApplicationPrivate(
int &argc,
char **argv);
67 ~QGuiApplicationPrivate();
71 void createPlatformIntegration();
72 void createEventDispatcher() override;
73 void eventDispatcherReady() override;
75 virtual void notifyLayoutDirectionChange();
76 virtual void notifyActiveWindowChange(QWindow *previous);
78#if QT_CONFIG(commandlineparser)
79 void addQtOptions(QList<QCommandLineOption> *options) override;
81 bool canQuitAutomatically() override;
84 void maybeLastWindowClosed();
85 bool lastWindowClosed()
const;
86 static bool quitOnLastWindowClosed;
88 static void captureGlobalModifierState(QEvent *e);
89 static Qt::KeyboardModifiers modifier_buttons;
90 static Qt::MouseButtons mouse_buttons;
92 static QPlatformIntegration *platform_integration;
94 static QPlatformIntegration *platformIntegration()
95 {
return platform_integration; }
97 static QPlatformTheme *platform_theme;
99 static QPlatformTheme *platformTheme()
100 {
return platform_theme; }
102 static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
104 if (QCoreApplication::instance())
105 return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed();
110 static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
111 static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
112 static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
113 static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
115 static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
117 static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
119 static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
120 static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
122 static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e);
124 static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
125 static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
126 static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e);
128 static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e);
130 static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
132 static void processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
134 static void updateFilteredScreenOrientation(QScreen *screen);
135 static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
136 static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
137 static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
138 static void processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e);
139 static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
141 static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
142 static void processPaintEvent(QWindowSystemInterfacePrivate::PaintEvent *e);
144 static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
146 static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e);
147 static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e);
148 static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
150#ifndef QT_NO_GESTURES
151 static void processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e);
154 static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e);
155#ifndef QT_NO_CONTEXTMENU
156 static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
159#if QT_CONFIG(draganddrop)
160 static QPlatformDragQtResponse processDrag(QWindow *w,
const QMimeData *dropData,
161 const QPoint &p, Qt::DropActions supportedActions,
162 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
163 static QPlatformDropQtResponse processDrop(QWindow *w,
const QMimeData *dropData,
164 const QPoint &p, Qt::DropActions supportedActions,
165 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
168 static bool processNativeEvent(QWindow *window,
const QByteArray &eventType,
void *message, qintptr *result);
170 static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
172 static bool maybeForwardEventToVirtualKeyboard(QEvent *e);
173 static bool isUsingVirtualKeyboard();
175 static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
177 if (!(alignment & Qt::AlignHorizontal_Mask))
178 alignment |= Qt::AlignLeft;
179 if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
180 if (direction == Qt::RightToLeft)
181 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
182 alignment |= Qt::AlignAbsolute;
187 QPixmap getPixmapCursor(Qt::CursorShape cshape);
189 void _q_updateFocusObject(QObject *object);
191 static QGuiApplicationPrivate *instance() {
return self; }
193 static QIcon *app_icon;
194 static QString *platform_name;
195 static QString *displayName;
196 static QString *desktopFileName;
198 QWindowList modalWindowList;
199 static void showModalWindow(QWindow *window);
200 static void hideModalWindow(QWindow *window);
201 static void updateBlockedStatus(QWindow *window);
203 virtual Qt::WindowModality defaultModality()
const;
204 virtual bool windowNeverBlocked(QWindow *window)
const;
205 bool isWindowBlocked(QWindow *window, QWindow **blockingWindow =
nullptr)
const;
206 static qsizetype popupCount() {
return QGuiApplicationPrivate::popup_list.size(); }
207 static QWindow *activePopupWindow();
208 static void activatePopup(QWindow *popup);
209 static bool closePopup(QWindow *popup);
210 static bool closeAllPopups();
212 static Qt::MouseButton mousePressButton;
213 static struct QLastCursorPosition {
216 constexpr inline QLastCursorPosition()
noexcept : thePoint(1 << 23, 1 << 23) {}
217 constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p)
noexcept : thePoint(p) {}
218 constexpr inline Q_IMPLICIT operator QPointF()
const noexcept {
return thePoint; }
219 constexpr inline qreal x()
const noexcept{
return thePoint.x(); }
220 constexpr inline qreal y()
const noexcept{
return thePoint.y(); }
221 Q_GUI_EXPORT QPoint toPoint()
const noexcept;
223 constexpr void reset()
noexcept { *
this = QLastCursorPosition{}; }
229 friend constexpr bool operator==(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
231 return qFuzzyCompare(
float(p1.x()),
float(p2.x()))
232 && qFuzzyCompare(
float(p1.y()),
float(p2.y()));
234 friend constexpr bool operator!=(
const QLastCursorPosition &p1,
const QPointF &p2)
noexcept
238 friend constexpr bool operator==(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
242 friend constexpr bool operator!=(
const QPointF &p1,
const QLastCursorPosition &p2)
noexcept
249 } lastCursorPosition;
250 static QWindow *currentMouseWindow;
251 static QWindow *currentMousePressWindow;
252 static Qt::ApplicationState applicationState;
253 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy;
254 static QPointer<QWindow> currentDragWindow;
257 struct TabletPointData {
258 TabletPointData(qint64 devId = 0) : deviceId(devId), state(Qt::NoButton), target(
nullptr) {}
260 Qt::MouseButtons state;
263 static QList<TabletPointData> tabletDevicePoints;
264 static TabletPointData &tabletDevicePoint(qint64 deviceId);
266#ifndef QT_NO_CLIPBOARD
267 static QClipboard *qt_clipboard;
270 static QPalette *app_pal;
272 static QWindowList window_list;
273 static QWindowList popup_list;
274 static const QWindow *active_popup_on_press;
275 static QWindow *focus_window;
278 QList<QCursor> cursor_list;
280 static QList<QScreen *> screen_list;
282 static QFont *app_font;
284 static QString styleOverride;
285 static QStyleHints *styleHints;
286 static bool obey_desktop_settings;
287 static bool popup_closed_on_press;
288 QInputMethod *inputMethod;
290 QString firstWindowTitle;
291 QIcon forcedWindowIcon;
293 static QList<QObject *> generic_plugin_list;
294#if QT_CONFIG(shortcut)
295 QShortcutMap shortcutMap;
298#ifndef QT_NO_SESSIONMANAGER
299 QSessionManager *session_manager;
300 bool is_session_restored;
301 bool is_saving_session;
306 QEvent::Type lastTouchType;
307 struct SynthesizedMouseData {
308 SynthesizedMouseData(
const QPointF &p,
const QPointF &sp, QWindow *w)
309 : pos(p), screenPos(sp), window(w) { }
312 QPointer<QWindow> window;
314 QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
316 static QInputDeviceManager *inputDeviceManager();
318 const QColorTrcLut *colorProfileForA8Text();
319 const QColorTrcLut *colorProfileForA32Text();
322 virtual QPixmap applyQIconStyleHelper(QIcon::Mode,
const QPixmap &basePixmap)
const {
return basePixmap; }
324 virtual void notifyWindowIconChanged();
326 static void applyWindowGeometrySpecificationTo(QWindow *window);
328 static void setApplicationState(Qt::ApplicationState state,
bool forcePropagate =
false);
330 static void resetCachedDevicePixelRatio();
333 virtual QActionPrivate *createActionPrivate()
const;
335#ifndef QT_NO_SHORTCUT
336 virtual QShortcutPrivate *createShortcutPrivate()
const;
339 static void updatePalette();
341 static QEvent::Type contextMenuEventType();
343 static QThreadPool *qtGuiThreadPool();
346 bool ownGlobalShareContext =
false;
350 virtual void handleThemeChanged();
352 static bool setPalette(
const QPalette &palette);
353 virtual QPalette basePalette()
const;
354 virtual void handlePaletteChanged(
const char *className =
nullptr);
356#if QT_CONFIG(draganddrop)
357 virtual void notifyDragStarted(
const QDrag *);
361 static void clearPalette();
363 friend class QDragManager;
364 friend class QWindowPrivate;
366 static QGuiApplicationPrivate *self;
367 static int m_fakeMouseSourcePointId;
369 std::shared_ptr<QColorTrcLut> m_a8ColorProfile;
371 std::shared_ptr<QColorTrcLut> m_a32ColorProfile;
373 static QInputDeviceManager *m_inputDeviceManager;
377 static qreal m_maxDevicePixelRatio;