40 #include "qplatformdefs.h"
49 #if QT_CONFIG(graphicsview)
51 #include <QtWidgets/qgraphicsproxywidget.h>
60 #if QT_CONFIG(tooltip)
66 #if QT_CONFIG(draganddrop)
67 #include <private/qdnd_p.h>
69 #include "private/qguiapplication_p.h"
72 #include "private/qstylesheetstyle_p.h"
73 #include "private/qstyle_p.h"
74 #if QT_CONFIG(messagebox)
78 #include <QtGui/qstylehints.h>
79 #include <QtGui/qinputmethod.h>
80 #include <QtGui/private/qwindow_p.h>
81 #include <QtGui/qpointingdevice.h>
82 #include <QtGui/private/qpointingdevice_p.h>
83 #include <qpa/qplatformtheme.h>
84 #if QT_CONFIG(whatsthis)
85 #include <QtWidgets/QWhatsThis>
88 #include "private/qkeymapper_p.h"
89 #include "private/qaccessiblewidgetfactory_p.h"
92 #include <private/qthread_p.h>
94 #include <QtGui/private/qevent_p.h>
95 #include <QtGui/private/qeventpoint_p.h>
96 #include <private/qfont_p.h>
98 #include <private/qaction_p.h>
107 #include "private/qgesturemanager_p.h"
108 #include <qpa/qplatformfontdatabase.h>
112 #include <qpa/qplatformwindow.h>
114 #include <qtwidgets_tracepoints_p.h>
121 static void initResources()
125 #if QT_CONFIG(messagebox)
133 #define CHECK_QAPP_INSTANCE(...) \
134 if (Q_LIKELY(QCoreApplication::instance())) { \
136 qWarning("Must construct a QApplication first."); \
137 return __VA_ARGS__; \
152 #ifndef QT_NO_GESTURES
320 return widgetWindow->widget();
338 #ifndef QT_NO_STYLE_STYLESHEET
350 #if QT_CONFIG(wheelevent)
357 #ifdef QT_KEYPAD_NAVIGATION
359 QWidget *QApplicationPrivate::oldEditFocus =
nullptr;
387 if (styleOverride.isEmpty() && qEnvironmentVariableIsSet(
"QT_STYLE_OVERRIDE"))
397 for (
i=1;
i<argc;
i++) {
400 if (*argv[
i] !=
'-') {
404 const char *
arg = argv[
i];
409 #ifndef QT_NO_STYLE_STYLESHEET
410 }
else if (
strcmp(
arg,
"-stylesheet") == 0 &&
i < argc -1) {
413 }
else if (
strncmp(
arg,
"-stylesheet=", 12) == 0) {
417 }
else if (
qstrcmp(
arg,
"-widgetcount") == 0) {
491 #if defined(Q_OS_MACOS)
492 QMacAutoReleasePool
pool;
499 qt_is_tty_app = (application_type == QApplicationPrivate::Tty);
509 eventDispatcher->startingUp();
511 #ifndef QT_NO_ACCESSIBILITY
520 #if QT_CONFIG(tooltip)
533 is_app_running =
false;
544 if (application_type != QApplicationPrivate::Tty) {
545 if (!styleOverride.isEmpty()) {
549 qWarning(
"QApplication: invalid style override '%s' passed, ignoring it.\n"
550 "\tAvailable styles: %s", qPrintable(styleOverride),
559 if (qEnvironmentVariableIntValue(
"QT_USE_NATIVE_WINDOWS") > 0)
570 is_app_running =
true;
670 return widgetWindow ? widgetWindow->
widget() :
nullptr;
686 d->toolTipWakeUp.stop();
687 d->toolTipFallAsleep.stop();
689 QApplicationPrivate::is_app_closing =
true;
690 QApplicationPrivate::is_app_running =
false;
702 w->destroy(
true,
true);
716 app_fonts()->clear();
721 #if QT_CONFIG(draganddrop)
726 d->cleanupMultitouch();
733 QApplicationPrivate::obey_desktop_settings =
true;
875 #ifndef QT_NO_STYLE_STYLESHEET
887 if (!styleSheetStyle)
890 }
else if (styleSheetStyle) {
911 Q_ASSERT(!
"No style available without QApplication!");
920 for (
const auto &
style : styles) {
931 defaultStyle->setParent(
qApp);
935 #ifndef QT_NO_STYLE_STYLESHEET
941 defaultStyle->polish(
qApp);
979 if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
993 #ifndef QT_NO_STYLE_STYLESHEET
1020 if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
1026 #ifndef QT_NO_STYLE_STYLESHEET
1028 w->setStyleSheet(
w->styleSheet());
1043 #ifndef QT_NO_STYLE_STYLESHEET
1045 oldStyleSheetStyle->deref();
1098 if (
const QPalette *themePalette = platformTheme() ? platformTheme()->
palette() :
nullptr)
1125 if (
w && !widgetPalettes.isEmpty()) {
1126 auto it = widgetPalettes.constFind(
w->metaObject()->className());
1127 const auto cend = widgetPalettes.constEnd();
1130 for (
it = widgetPalettes.constBegin();
it !=
cend; ++
it) {
1131 if (
w->inherits(
it.key()))
1148 if (
className && !widgetPalettes.isEmpty()) {
1150 if (
it != widgetPalettes.constEnd())
1199 if (!is_app_running || is_app_closing)
1216 #if QT_CONFIG(graphicsview)
1217 for (
auto scene : qAsConst(scene_list))
1237 static const ThemedWidget themedWidgets[] = {
1255 for (
const auto themedWidget : themedWidgets) {
1256 if (
auto *
palette = platformTheme->
palette(themedWidget.palette))
1299 const FontHashConstIt
cend =
hash->constEnd();
1300 while (
it ==
cend && metaObj != &QWidget::staticMetaObject) {
1322 if (
it !=
hash->constEnd())
1358 if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
1367 #if QT_CONFIG(graphicsview)
1401 #if defined(QT_BUILD_INTERNAL)
1403 if (qEnvironmentVariableIsSet(
"QT_DESKTOP_STYLE_KEY"))
1427 for (
auto *
w :
list) {
1434 for (
int i = 0;
i < windowList.
size(); ++
i)
1454 const auto isTopLevelWidget = [] (
const QWidget *
w) {
1458 std::back_inserter(
list), isTopLevelWidget);
1497 #if QT_CONFIG(graphicsview)
1498 if (
focus &&
focus->window()->graphicsProxyWidget())
1526 #ifdef QT_KEYPAD_NAVIGATION
1527 if (QApplicationPrivate::keyboardNavigationEnabled()) {
1529 prev->setEditFocus(
false);
1565 #if QT_DEPRECATED_SINCE(6,0)
1579 bool QApplicationPrivate::tryCloseAllWidgetWindows(
QWindowList *processedWindows)
1583 if (!
w->isVisible() ||
w->data->is_closing)
1594 for (
auto *
w :
list) {
1627 QApplicationPrivate::tryCloseAllWidgetWindows(&processedWindows);
1641 #if QT_CONFIG(messagebox)
1674 if (
w->data->is_closing)
1691 for (
auto *
w :
list) {
1694 w->d_func()->setLocale_helper(
QLocale(),
true);
1701 if (te->
timerId() ==
d->toolTipWakeUp.timerId()) {
1702 d->toolTipWakeUp.stop();
1703 if (
d->toolTipWidget) {
1704 QWidget *
w =
d->toolTipWidget->window();
1709 while (
w && !showToolTip) {
1710 showToolTip =
w->isActiveWindow();
1711 w =
w->parentWidget();
1712 w =
w ?
w->window() :
nullptr;
1717 if (
e.isAccepted()) {
1718 QStyle *
s =
d->toolTipWidget->style();
1720 d->toolTipFallAsleep.start(sleepDelay,
this);
1724 }
else if (te->
timerId() ==
d->toolTipFallAsleep.timerId()) {
1725 d->toolTipFallAsleep.stop();
1727 #if QT_CONFIG(whatsthis)
1740 for (
auto *
w :
list) {
1759 for (
auto *
w :
list) {
1767 for (
int i = 0;
i < windowList.
size(); ++
i) {
1798 #if QT_CONFIG(graphicsview)
1811 for (
auto *
w :
list) {
1812 if (
w->isVisible() &&
w->isActiveWindow())
1833 for (
auto *
w :
list) {
1834 if (
w->isVisible() &&
w->isActiveWindow())
1848 for (
int i = 0;
i < toBeActivated.
size(); ++
i) {
1850 sendSpontaneousEvent(
w, &windowActivate);
1851 sendSpontaneousEvent(
w, &activationChange);
1854 for(
int i = 0;
i < toBeDeactivated.
size(); ++
i) {
1856 sendSpontaneousEvent(
w, &windowDeactivate);
1857 sendSpontaneousEvent(
w, &activationChange);
1866 if (
w &&
w->isVisible() )
1889 while (wnd && !wnd->isTopLevel()) {
1895 if (
parent->handle() &&
parent->handle()->isForeignWindow())
1898 wnd = wnd->parent();
1903 if (tlw->windowHandle() == wnd)
1922 if (focusWindow && focusWidget && focusWindow != focusWidget->
windowHandle()) {
1923 if (
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(focusWindow))
1932 if (previous && !qobject_cast<QWidgetWindow *>(previous)) {
1937 if (focusWindow && !qobject_cast<QWidgetWindow *>(focusWindow)) {
1951 bool *wrappingOccurred)
1960 QWidget *test =
f->d_func()->focus_next;
1961 bool seenWindow =
false;
1962 bool focusWidgetAfterWindow =
false;
1963 while (test && test !=
f) {
1964 if (test->isWindow())
1971 QWidget *focusProxy = test->d_func()->deepestFocusProxy();
1975 const bool canTakeFocus = (effectiveFocusPolicy(focusProxy ? focusProxy : test)
1976 & focus_flag) == focus_flag;
1977 const bool composites = focusProxy ? (
next ? focusProxy->
isAncestorOf(test)
1978 : test->isAncestorOf(focusProxy))
1980 if (canTakeFocus && !composites
1981 && test->isVisibleTo(toplevel) && test->isEnabled()
1984 &&
f != focusProxy) {
1987 focusWidgetAfterWindow =
true;
1991 test = test->d_func()->focus_next;
1994 if (wrappingOccurred !=
nullptr)
1995 *wrappingOccurred =
next ? focusWidgetAfterWindow : !focusWidgetAfterWindow;
2032 qDebug() <<
"QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter <<
"LEAVE:" <<
leave;
2038 if (
leave && !sameWindow) {
2042 }
while (!
w->isWindow() && (
w =
w->parentWidget()));
2044 if (enter && !sameWindow) {
2048 }
while (!
w->isWindow() && (
w =
w->parentWidget()));
2054 while (!
e->isWindow() && (
e =
e->parentWidget()))
2057 while (!
l->isWindow() && (
l =
l->parentWidget()))
2061 while (enterDepth > leaveDepth) {
2065 while (leaveDepth > enterDepth) {
2069 while (!wenter->
isWindow() && wenter != wleave) {
2082 for (
int i = 0;
i < leaveList.
size(); ++
i) {
2083 auto *
w = leaveList.
at(
i);
2091 qApp->d_func()->notify_helper(
w, &he);
2100 const QPointF windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos);
2104 const QPointF localPos =
w->mapFromGlobal(globalPos);
2105 QEnterEvent enterEvent(localPos, windowPos, globalPos);
2111 qApp->d_func()->notify_helper(
w, &he);
2117 #ifndef QT_NO_CURSOR
2123 QWidget *parentOfLeavingCursor =
nullptr;
2124 for (
int i = 0;
i < leaveList.
size(); ++
i) {
2125 auto *
w = leaveList.
at(
i);
2132 parentOfLeavingCursor =
parent;
2138 if (parentOfLeavingCursor && (!enterOnAlien
2140 #if QT_CONFIG(graphicsview)
2141 if (!parentOfLeavingCursor->
window()->graphicsProxyWidget())
2152 QWidget *cursorWidget = enter;
2159 #if QT_CONFIG(graphicsview)
2160 if (cursorWidget->
window()->graphicsProxyWidget()) {
2161 QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->
setCursor(cursorWidget->
cursor());
2191 qWarning().nospace() <<
"window == 0 passed.";
2194 if (!blockingWindow)
2195 blockingWindow = &unused;
2197 if (modalWindowList.isEmpty()) {
2198 *blockingWindow =
nullptr;
2204 *blockingWindow =
nullptr;
2208 for (
int i = 0;
i < modalWindowList.count(); ++
i) {
2209 QWindow *modalWindow = modalWindowList.at(
i);
2213 if (
window == modalWindow || modalWindow->isAncestorOf(
window, QWindow::IncludeTransients)) {
2214 *blockingWindow =
nullptr;
2225 switch (windowModality) {
2227 if (modalWindow !=
window) {
2228 *blockingWindow = modalWindow;
2239 *blockingWindow =
m;
2244 p =
m->transientParent();
2249 p =
w->transientParent();
2255 Q_ASSERT_X(
false,
"QApplication",
"internal error, a modal window cannot be modeless");
2259 *blockingWindow =
nullptr;
2288 bool block_event =
false;
2302 if (block_event &&
top &&
top->parentWidget() ==
nullptr)
2305 return !block_event;
2310 return !
self->modalWindowList.isEmpty();
2318 Qt::MouseButtons buttons,
QWidget *buttonDown,
2325 && !buttonDown && !mouseGrabber) {
2330 alienWidget =
nullptr;
2332 QWidget *receiver = candidate;
2335 mouseGrabber = (buttonDown && !
isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
2337 if (mouseGrabber && mouseGrabber != candidate) {
2338 receiver = mouseGrabber;
2341 qDebug() <<
" ** receiver adjusted to:" << receiver <<
"pos:" <<
pos;
2355 bool spontaneous,
bool onlyDispatchEnterLeave)
2362 if (alienWidget && !isAlien(alienWidget))
2363 alienWidget =
nullptr;
2381 if (!graphicsWidget) {
2387 *buttonDown =
nullptr;
2389 }
else if (lastMouseReceiver && widgetUnderMouse) {
2394 if ((alienWidget && alienWidget != lastMouseReceiver)
2395 || (isAlien(lastMouseReceiver) && !alienWidget)) {
2396 if (activePopupWidget) {
2407 qDebug() <<
"QApplicationPrivate::sendMouseEvent: receiver:" << receiver
2408 <<
"pos:" <<
event->position() <<
"alien" << alienWidget <<
"button down"
2409 << *buttonDown <<
"last" << lastMouseReceiver <<
"leave after release"
2421 if (!onlyDispatchEnterLeave) {
2423 result = QApplication::sendSpontaneousEvent(receiver,
event);
2435 enter = alienGuard ? alienWidget : nativeWidget;
2440 lastMouseReceiver = enter;
2441 }
else if (!wasLeaveAfterRelease) {
2442 if (activePopupWidget) {
2444 lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget :
nullptr);
2463 #ifndef QT_NO_CURSOR
2474 if (mouseGrabber && mouseGrabber !=
widget)
2478 if (tlw->data->in_destructor || tlw->data->is_closing)
2490 QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(windowPos,
widget->data->in_destructor);
2491 if (!widgetUnderCursor)
2492 widgetUnderCursor = tlw;
2640 if (QApplicationPrivate::is_app_closing)
2644 qWarning(
"QApplication::notify: Unexpected null receiver");
2661 #ifndef QT_NO_GESTURES
2663 if (
d->gestureManager) {
2664 switch (
e->type()) {
2688 if (
d->gestureManager->filterEvent(
static_cast<QWidget *
>(receiver),
e))
2694 if (
d->gestureManager->filterEvent(receiver,
e))
2703 switch (
e->type()) {
2709 d->closeAllPopups();
2720 d->toolTipFallAsleep.stop();
2723 d->toolTipWakeUp.stop();
2728 switch (
e->type()) {
2731 const int key = keyEvent->
key();
2756 switch (
e->type()) {
2780 res =
d->notify_helper(
w,
e);
2782 if (
res &&
key->isAccepted())
2784 if (!pr ||
w->isWindow())
2787 w =
w->parentWidget();
2799 if (
e->spontaneous()) {
2801 QApplicationPrivate::giveFocusAccordingToFocusPolicy(
w,
e, relpos);
2811 &&
w->rect().contains(relpos)) {
2812 d->toolTipWidget =
w;
2813 d->toolTipPos = relpos;
2815 QStyle *
s =
d->toolTipWidget->style();
2817 d->toolTipWakeUp.start(
d->toolTipFallAsleep.isActive() ? 20 : wakeDelay,
this);
2832 if (!
w->hasMouseTracking()
2835 d->sendThroughApplicationEventFilters(
w,
w == receiver ? mouse : &me);
2839 res =
d->notify_helper(
w,
w == receiver ? mouse : &me);
2842 eventAccepted = (
w == receiver ? mouse : &me)->isAccepted();
2843 if (
res && eventAccepted)
2848 w =
w->parentWidget();
2857 w =
static_cast<QWidget *
>(receiver);
2864 d->notify_helper(
w, &he);
2869 w =
w->parentWidget();
2876 #if QT_CONFIG(wheelevent)
2880 if (
w->window() != popup)
2884 QWheelEvent* wheel =
static_cast<QWheelEvent*
>(
e);
2885 if (!wheel->spontaneous()) {
2891 res =
d->notify_helper(
w, wheel);
2896 QPoint relpos = wheel->position().toPoint();
2919 if (QApplicationPrivate::wheel_widget) {
2921 w = QApplicationPrivate::wheel_widget;
2922 relpos =
w->mapFromGlobal(wheel->globalPosition().toPoint());
2931 QApplicationPrivate::wheel_widget =
nullptr;
2934 QApplicationPrivate::wheel_widget =
w;
2938 if (!QApplicationPrivate::wheel_widget)
2939 QApplicationPrivate::wheel_widget =
w;
2942 QApplicationPrivate::giveFocusAccordingToFocusPolicy(
w,
e, relpos);
2947 QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(),
2948 wheel->modifiers(), phase, wheel->inverted(), wheel->source(), wheel->pointingDevice());
2950 we.setTimestamp(wheel->timestamp());
2955 we.setAccepted(
true);
2956 we.m_spont = wheel->spontaneous() &&
w == receiver;
2957 res =
d->notify_helper(
w, &we);
2958 eventAccepted = we.isAccepted();
2959 if (
res && eventAccepted)
2964 QMutableEventPoint::setPosition(we.point(0), we.position() +
w->pos());
2965 w =
w->parentWidget();
2967 wheel->setAccepted(eventAccepted);
2971 #ifndef QT_NO_CONTEXTMENU
2975 bool eventAccepted =
context->isAccepted();
2978 ce.m_spont =
e->spontaneous();
2980 eventAccepted = ((
w == receiver) ?
context : &ce)->isAccepted();
2983 if (
res && eventAccepted)
2989 w =
w->parentWidget();
2991 context->setAccepted(eventAccepted);
2995 #if QT_CONFIG(tabletevent)
2999 QTabletEvent *tablet =
static_cast<QTabletEvent*
>(
e);
3000 QPointF relpos = tablet->position();
3001 bool eventAccepted = tablet->isAccepted();
3003 QTabletEvent te(tablet->type(), tablet->pointingDevice(), relpos, tablet->globalPosition(),
3004 tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
3005 tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
3006 tablet->modifiers(), tablet->button(), tablet->buttons());
3007 te.m_spont =
e->spontaneous();
3008 te.setAccepted(
false);
3009 res =
d->notify_helper(
w,
w == receiver ? tablet : &te);
3010 eventAccepted = ((
w == receiver) ? tablet : &te)->isAccepted();
3012 if (
res && eventAccepted)
3018 w =
w->parentWidget();
3020 tablet->setAccepted(eventAccepted);
3025 #if QT_CONFIG(tooltip) || QT_CONFIG(whatsthis)
3031 bool eventAccepted =
help->isAccepted();
3034 he.m_spont =
e->spontaneous();
3035 res =
d->notify_helper(
w,
w == receiver ?
help : &he);
3037 eventAccepted = (
w == receiver ?
help : &he)->isAccepted();
3038 if (
res && eventAccepted)
3044 w =
w->parentWidget();
3046 help->setAccepted(eventAccepted);
3050 #if QT_CONFIG(statustip) || QT_CONFIG(whatsthis)
3054 res =
d->notify_helper(
w,
e);
3055 if (
res &&
e->isAccepted())
3059 w =
w->parentWidget();
3064 #if QT_CONFIG(draganddrop)
3066 QDragEnterEvent *dragEvent =
static_cast<QDragEnterEvent *
>(
e);
3067 #if QT_CONFIG(graphicsview)
3070 const auto &extra =
w->window()->d_func()->extra;
3071 if (extra && extra->proxyWidget) {
3072 res =
d->notify_helper(
w, dragEvent);
3077 if (
w->isEnabled() &&
w->acceptDrops()) {
3078 res =
d->notify_helper(
w, dragEvent);
3079 if (
res && dragEvent->isAccepted()) {
3086 dragEvent->m_pos =
w->mapToParent(dragEvent->m_pos);
3087 w =
w->parentWidget();
3094 #if QT_CONFIG(graphicsview)
3097 const auto &extra =
w->window()->d_func()->extra;
3098 bool isProxyWidget = extra && extra->proxyWidget;
3106 QDropEvent *dragEvent =
static_cast<QDropEvent *
>(
e);
3108 while (origReceiver &&
w != origReceiver) {
3109 dragEvent->m_pos = origReceiver->
mapToParent(dragEvent->m_pos);
3113 res =
d->notify_helper(
w,
e);
3115 #if QT_CONFIG(graphicsview)
3126 bool eventAccepted =
touchEvent->isAccepted();
3129 if (acceptTouchEvents &&
e->spontaneous()) {
3131 QApplicationPrivate::giveFocusAccordingToFocusPolicy(
w,
e, localPos);
3134 #ifndef QT_NO_GESTURES
3153 if (
res && eventAccepted) {
3158 #ifndef QT_NO_GESTURES
3160 gesturePendingWidget =
w;
3166 w =
w->parentWidget();
3170 QMutableEventPoint::setPosition(pt, pt.position() +
offset);
3174 #ifndef QT_NO_GESTURES
3175 if (!eventAccepted && !gesturePendingWidget.
isNull()) {
3191 res =
d->notify_helper(
w,
e);
3200 #ifndef QT_NO_GESTURES
3204 res =
d->notify_helper(
w,
e);
3205 if (
res &&
e->isAccepted())
3209 w =
w->parentWidget();
3217 bool eventAccepted = gestureEvent->
isAccepted();
3218 bool wasAccepted = eventAccepted;
3223 for (
int i = 0;
i < allGestures.
size();) {
3240 ge.
t = gestureEvent->
t;
3242 ge.m_accept = wasAccepted;
3243 ge.m_accepted = gestureEvent->m_accepted;
3244 res =
d->notify_helper(
w, &ge);
3245 gestureEvent->m_spont =
false;
3247 for (
int i = 0;
i < gestures.
size(); ++
i) {
3253 gestureEvent->m_targetWidgets[
g->gestureType()] =
w;
3266 w =
w->parentWidget();
3268 for (
QGesture *
g : qAsConst(allGestures))
3270 gestureEvent->m_accept =
false;
3276 typedef void (*RegisterTouchWindowFn)(
QWindow *, bool);
3279 RegisterTouchWindowFn registerTouchWindow =
reinterpret_cast<RegisterTouchWindowFn
>
3281 if (registerTouchWindow)
3282 registerTouchWindow(
w->window()->windowHandle(),
true);
3284 res =
d->notify_helper(receiver,
e);
3288 RegisterTouchWindowFn registerTouchWindow =
reinterpret_cast<RegisterTouchWindowFn
>
3290 if (registerTouchWindow)
3291 registerTouchWindow(
w->window()->windowHandle(),
false);
3293 res =
d->notify_helper(receiver,
e);
3297 res =
d->notify_helper(receiver,
e);
3301 res =
d->notify_helper(receiver,
e);
3313 Q_TRACE(QApplication_notify_entry, receiver,
e,
e->type());
3314 bool consumed =
false;
3319 if (threadRequiresCoreApplication()
3320 && receiver->d_func()->threadData.loadRelaxed()->
thread.loadAcquire() == mainThread()
3321 && sendThroughApplicationEventFilters(receiver,
e)) {
3329 #if !defined(QT_NO_CURSOR)
3344 if (sendThroughObjectEventFilters(receiver,
e)) {
3350 consumed = receiver->
event(
e);
3361 static void ungrabKeyboardForPopup(
QWidget *popup)
3369 static void ungrabMouseForPopup(
QWidget *popup)
3377 static bool popupGrabOk;
3379 static void grabForPopup(
QWidget *popup)
3387 ungrabKeyboardForPopup(popup);
3425 popupGrabOk =
false;
3429 auto mousePressPos = devPriv->pointById(0)->eventPoint.globalPressPosition();
3439 ungrabMouseForPopup(popup);
3442 ungrabKeyboardForPopup(popup);
3480 grabForPopup(popup);
3495 #ifdef QT_KEYPAD_NAVIGATION
3505 QApplicationPrivate::navigationMode =
mode;
3517 return QApplicationPrivate::navigationMode;
3552 for (
QWidget *topLevel : topLevels)
3639 #if QT_CONFIG(wheelevent)
3640 int QApplication::wheelScrollLines()
3645 void QApplication::setWheelScrollLines(
int lines)
3685 int effectFlags = uiEffectToFlag(
effect);
3742 return QGuiApplication::sendSpontaneousEvent(receiver,
event);
3751 switch (
event->type()) {
3756 if (setFocusOnRelease)
3761 if (!setFocusOnRelease)
3777 while (focusWidget) {
3780 && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
3789 if (focusWidget->d_func()->extra && focusWidget->d_func()->extra->focus_proxy)
3790 f = focusWidget->d_func()->extra->focus_proxy;
3796 localPos += focusWidget->
pos();
3804 while (
f->d_func()->extra &&
f->d_func()->extra->focus_proxy)
3805 f =
f->d_func()->extra->focus_proxy;
3816 bool containsPress =
false;
3822 if (pt.state() == QEventPoint::State::Pressed)
3823 containsPress =
true;
3825 return containsPress;
3848 const QPointF globalPos = touchPoint.globalPosition();
3849 int closestTouchPointId = -1;
3850 QObject *closestTarget =
nullptr;
3851 qreal closestDistance = 0;
3854 const auto &pt = epd.eventPoint;
3855 if (pt.id() != touchPoint.id()) {
3856 qreal dx = globalPos.
x() - pt.globalPosition().x();
3857 qreal dy = globalPos.
y() - pt.globalPosition().y();
3859 if (closestTouchPointId == -1 ||
distance < closestDistance) {
3860 closestTouchPointId = pt.id();
3866 return static_cast<QWidget *
>(closestTarget);
3881 QMutableEventPoint::setTarget(ep,
widget);
3894 auto touchPoints = te->
points();
3895 for (
auto &touchPoint : touchPoints) {
3898 if (touchPoint.state() == QEventPoint::State::Pressed) {
3911 target =
window->childAt(
window->mapFromGlobal(touchPoint.globalPosition().toPoint()));
3916 bool usingClosestWidget =
false;
3918 QWidget *closestWidget =
d->findClosestTouchPointTarget(
device, touchPoint);
3923 usingClosestWidget =
true;
3930 QMutableEventPoint::setTarget(touchPoint,
target);
3943 if (touchPoints.count() == 1
3949 StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[targetWidget];
3951 maskAndPoints.second.append(touchPoint);
3954 if (widgetsNeedingEvents.
isEmpty())
3957 bool accepted =
false;
3966 switch (
it.value().first) {
3967 case QEventPoint::State::Pressed:
3970 case QEventPoint::State::Released:
3973 case QEventPoint::State::Stationary:
4006 #ifndef QT_NO_GESTURES
4032 const auto &pt = epd.eventPoint;
4038 widItEnd = widgetsNeedingCancel.
constEnd(); widIt != widItEnd; ++widIt) {
4052 #if QT_CONFIG(draganddrop)
4053 void QApplicationPrivate::notifyDragStarted(
const QDrag *drag)
4055 QGuiApplicationPrivate::notifyDragStarted(drag);
4065 #ifndef QT_NO_GESTURES
4091 #include "moc_qapplication.cpp"
small capitals from c petite p scientific i
[1]
static void(* setWidgetParent)(QObject *, QObject *)
static void installFactory(InterfaceFactory)
The QApplication class manages the GUI application's control flow and main settings.
static void setStyle(QStyle *)
static void closeAllWindows()
static bool isEffectEnabled(Qt::UIEffect)
static void setPalette(const QPalette &, const char *className=nullptr)
static QWidget * widgetAt(const QPoint &p)
static void alert(QWidget *widget, int duration=0)
static QPalette palette()
static QWidget * activeModalWidget()
static QWidget * topLevelAt(const QPoint &p)
static QWidget * focusWidget()
static QWidgetList topLevelWidgets()
bool autoSipEnabled
toggles automatic SIP (software input panel) visibility
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
static QWidget * activePopupWidget()
int startDragTime
the time in milliseconds that a mouse button must be held down before a drag and drop operation will ...
static void setCursorFlashTime(int)
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
int doubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
int cursorFlashTime
the text cursor's flash (blink) time in milliseconds
static void setStartDragTime(int ms)
int startDragDistance
the minimum distance required for a drag and drop operation to start.
bool event(QEvent *) override
void setAutoSipEnabled(const bool enabled)
bool notify(QObject *, QEvent *) override
static void setStartDragDistance(int l)
static QWidget * activeWindow()
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override
int keyboardInputInterval
the time limit in milliseconds that distinguishes a key press from two consecutive key presses
void setStyleSheet(const QString &sheet)
QString styleSheet
the application style sheet
static void setKeyboardInputInterval(int)
static void setActiveWindow(QWidget *act)
static void setFont(const QFont &, const char *className=nullptr)
static void setDoubleClickInterval(int)
static QWidgetList allWidgets()
static QWidget * pickMouseReceiver(QWidget *candidate, const QPoint &windowPos, QPoint *pos, QEvent::Type type, Qt::MouseButtons buttons, QWidget *buttonDown, QWidget *alienWidget)
virtual void notifyLayoutDirectionChange() override
static void initializeWidgetPalettesFromTheme()
void handlePaletteChanged(const char *className=nullptr) override
void sendSyntheticEnterLeave(QWidget *widget)
static QWidget * desktop()
static QWindow * windowForWidget(const QWidget *widget)
QApplicationPrivate(int &argc, char **argv, int flags)
static QWidget * focus_widget
static QPointer< QWidget > leaveAfterRelease
QGestureManager * gestureManager
static void initializeWidgetFontHash()
void notifyThemeChanged() override
bool notify_helper(QObject *receiver, QEvent *e)
virtual void notifyActiveWindowChange(QWindow *) override
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow=nullptr) const override
static QWidget * hidden_focus_widget
QPalette basePalette() const override
static QWidget * active_window
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
void closePopup(QWidget *popup)
static PaletteHash widgetPalettes
static int enabledAnimations
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next, bool *wrappingOccurred=nullptr)
static QString styleSheet
void initializeMultitouch()
QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap &base) const override
static bool inPopupMode()
void initializeMultitouch_sys()
void openPopup(QWidget *popup)
static QWidgetList * popupWidgets
void activateImplicitTouchGrab(QWidget *widget, QTouchEvent *touchBeginEvent, ImplicitTouchGrabMode grabMode=GrabAcceptedPoints)
void notifyWindowIconChanged() override
QWidget * findClosestTouchPointTarget(const QPointingDevice *device, const QEventPoint &touchPoint)
bool closeAllPopups() override
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF)
static QString desktopStyleKey()
static bool isBlockedByModal(QWidget *widget)
static QStyle * app_style
void createEventDispatcher() override
static QWidget * main_widget
static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent)
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true, bool onlyDispatchEnterLeave=false)
static void setSystemFont(const QFont &font)
static bool autoSipEnabled
static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
static QApplicationPrivate * instance()
static bool tryModalHelper(QWidget *widget, QWidget **rettop=nullptr)
static void translateTouchCancel(const QPointingDevice *device, ulong timestamp)
void cleanupMultitouch_sys()
static QColormap instance(int screen=-1)
void * resolveInterface(const char *name, int revision) const
static QCoreApplication * instance()
static bool sendEvent(QObject *receiver, QEvent *event)
bool event(QEvent *) override
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
[95]
static bool testAttribute(Qt::ApplicationAttribute attribute)
friend class QApplication
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
static void setEventSpontaneous(QEvent *e, bool spontaneous)
static void checkReceiverThread(QObject *receiver)
The QDrag class provides support for MIME-based drag and drop data transfer.
void setCurrentTarget(QObject *target, bool dropped=false)
static QDragManager * self()
The QEnterEvent class contains parameters that describe an enter event.
The QEvent class is the base class of all event classes. Event objects contain event parameters.
@ ApplicationPaletteChange
@ CloseSoftwareInputPanel
@ ApplicationLayoutDirectionChange
@ ApplicationWindowIconChange
@ RequestSoftwareInputPanel
The QEventPoint class provides information about a point in a QPointerEvent.
const mapped_container_type & values() const noexcept
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
The QFont class specifies a query for a font used for drawing text.
bool isCopyOf(const QFont &) const
The QFontMetrics class provides font metrics information.
The QGestureEvent class provides the description of triggered gestures.
bool isAccepted(QGesture *) const
QList< QGesture * > gestures() const
void setAccepted(QGesture *, bool)
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Qt::GestureType gestureType
the type of the gesture
static bool gesturePending(QObject *o)
static QGestureManager * instance(InstanceCreation ic=ForceCreation)
QGestureManager(QObject *parent)
The QGuiApplication class manages the GUI application's control flow and main settings.
static QPlatformNativeInterface * platformNativeInterface()
static QWindowList topLevelWindows()
static QWindow * modalWindow()
static QWindow * topLevelAt(const QPoint &pos)
static void setFont(const QFont &)
static QPalette palette()
static void setPalette(const QPalette &pal)
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override
static QStyleHints * styleHints()
static QInputMethod * inputMethod()
static Qt::KeyboardModifiers keyboardModifiers()
bool event(QEvent *) override
static bool desktopSettingsAware()
static QPlatformIntegration * platformIntegration()
static QPlatformTheme * platformTheme()
static QWindow * focus_window
static void updatePalette()
static void captureGlobalModifierState(QEvent *e)
virtual void handlePaletteChanged(const char *className=nullptr)
void createEventDispatcher() override
static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event)
virtual void notifyThemeChanged()
The QHash::const_iterator class provides an STL-style const iterator for QHash.
const_iterator constEnd() const noexcept
const_iterator constBegin() const noexcept
friend class const_iterator
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
bool isEmpty() const noexcept
iterator insert(const Key &key, const T &value)
The QHelpEvent class provides an event that is used to request helpful information about a particular...
The QHoverEvent class contains parameters that describe a mouse event.
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
bool isAutoRepeat() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLayout class is the base class of geometry managers.
void widgetEvent(QEvent *)
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
const_reverse_iterator crbegin() const noexcept
const_iterator constBegin() const noexcept
qsizetype removeAll(const AT &t)
qsizetype count() const noexcept
const T & constLast() const noexcept
void append(parameter_type t)
const_iterator constEnd() const noexcept
const_iterator ConstIterator
const_reverse_iterator crend() const noexcept
T value(const Key &key, const T &defaultValue=T()) const
iterator find(const Key &key)
static void aboutQt(QWidget *parent, const QString &title=QString())
The QMouseEvent class contains parameters that describe a mouse event.
The QMoveEvent class contains event parameters for move events. \inmodule QtGui.
const QPoint & pos() const
static QObject * target(const QEventPoint &p)
static QMutableSinglePointEvent * from(QSinglePointEvent *e)
void setDoubleClick(bool d=true)
static QMutableTouchEvent * from(QTouchEvent *e)
The QObject class is the base class of all Qt objects.
bool isWindowType() const
virtual bool event(QEvent *event)
void setParent(QObject *parent)
bool inherits(const char *classname) const
bool isWidgetType() const
The QPalette class contains color groups for each widget state.
void setResolveMask(ResolveMask mask)
ResolveMask resolveMask() const
The QPixmap class is an off-screen image representation that can be used as a paint device.
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
constexpr QPoint toPoint() const
The QPoint class defines a point in the plane using integer precision.
constexpr int x() const noexcept
constexpr int y() const noexcept
const QPointingDevice * pointingDevice() const
void setTimestamp(quint64 timestamp) override
virtual void setAccepted(bool accepted) override
const QList< QEventPoint > & points() const
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static const QPointingDevice * primaryPointingDevice(const QString &seatName=QString())
QObject * firstActiveTarget() const
EventPointMap activePoints
static QPointingDevicePrivate * get(QPointingDevice *q)
The QRectF class defines a finite rectangle in the plane using floating point precision.
bool contains(const QRectF &r) const noexcept
bool contains(const QRect &r, bool proper=false) const noexcept
The QRegion class specifies a clip region for a painter.
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
const QSize & size() const
QList< T > values() const
const_iterator ConstIterator
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
QPointF globalPosition() const
QPointF scenePosition() const
Qt::MouseButton button() const
Qt::MouseButtons buttons() const
The QString class provides a Unicode character string.
static QString fromLocal8Bit(QByteArrayView ba)
QString & append(QChar c)
The QStringList class provides a list of strings.
static QStringList keys()
static QStyle * create(const QString &)
void setKeyboardInputInterval(int keyboardInputInterval)
void setWheelScrollLines(int scrollLines)
int keyboardInputInterval
the time limit, in milliseconds, that distinguishes a key press from two consecutive key presses.
void setStartDragDistance(int startDragDistance)
int startDragTime
the time, in milliseconds, that a mouse button must be held down before a drag and drop operation wil...
int startDragDistance
the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop ...
bool setFocusOnTouchRelease
the event that should set input focus on focus objects.
Qt::TabFocusBehavior tabFocusBehavior
The focus behavior on press of the tab key.
void setCursorFlashTime(int cursorFlashTime)
int mouseDoubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.
int cursorFlashTime
the text cursor's flash (blink) time in milliseconds.
int wheelScrollLines
Number of lines to scroll by default for each wheel click.
void setMouseDoubleClickInterval(int mouseDoubleClickInterval)
void setStartDragTime(int startDragTime)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual void polish(QWidget *widget)
virtual QPalette standardPalette() const
@ SH_Widget_ShareActivation
@ SH_ToolTip_FallAsleepDelay
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
virtual void unpolish(QWidget *widget)
The QStyleOption class stores the parameters used by QStyle functions.
void repolish(QWidget *widget)
QEventPoint & point(int touchId)
QMap< int, QEventPoint > points
static QThread * currentThread()
The QTimerEvent class contains parameters that describe a timer event.
The QTouchEvent class contains parameters that describe a touch event.
static void enterWhatsThisMode()
The QWindow class represents a window in the underlying windowing system.
Qt::WindowModality modality
the modality of the window
static QWindowPrivate * get(QWindow *window)
QHash< int, QWidget * > hash
[35multi]
typename C::const_iterator const_iterator
const PluginKeyMapConstIterator cend
std::chrono::milliseconds ms
QTouchEventSequence touchEvent(QWindow *window, QPointingDevice *device, bool autoCommit=true)
QFuture< typename std::decay_t< Sequence >::value_type > filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
@ NavigationModeKeypadTabOrder
@ WA_TouchPadAcceptSingleTouchEvents
@ WA_TransparentForMouseEvents
@ WA_WState_AcceptedTouchBeginEvent
@ ActiveWindowFocusReason
decltype(auto) cbegin(const T &t)
int PRIV() strcmp(PCRE2_SPTR str1, PCRE2_SPTR str2)
int PRIV() strncmp(PCRE2_SPTR str1, PCRE2_SPTR str2, size_t len)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if
Q_CORE_EXPORT void qt_call_post_routines()
bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
void qt_init_tooltip_palette()
bool qt_replay_popup_mouse_event
bool qt_popup_down_closed
Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
int qt_antialiasing_threshold
QWidget * qt_desktopWidget
Q_WIDGETS_EXPORT QWidget * qt_button_down
QWidget * qt_tlw_for_window(QWindow *wnd)
void qRegisterWidgetsVariant()
#define CHECK_QAPP_INSTANCE(...)
FontHash * qt_app_fonts_hash()
QPointer< QWidget > qt_last_mouse_receiver
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
bool qt_try_modal(QWidget *widget, QEvent::Type type)
void qt_qpa_set_cursor(QWidget *w, bool force)
#define QApplicationPrivateBase
#define QByteArrayLiteral(str)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
std::pair< T1, T2 > QPair
bool qIsInf(qfloat16 f) noexcept
QT_END_INCLUDE_NAMESPACE typedef double qreal
#define Q_INIT_RESOURCE(name)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
Q_GUI_EXPORT bool qt_is_tty_app
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei GLsizei GLfloat distance
GLenum GLuint GLintptr offset
#define Q_ASSERT_X(cond, x, msg)
QStyleSheetStyle * qt_styleSheet(QStyle *style)
#define Q_TRACE_EXIT(x,...)
QT_BEGIN_NAMESPACE typedef QHash< WId, QWidget * > QWidgetMapper
QSet< QWidget * > QWidgetSet
QList< QWidget * > QWidgetList
const char className[16]
[1]
QTextStream out(stdout)
[7]
QList< QWidget * > widgets
[11]
QGraphicsOpacityEffect * effect
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent