diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 185 |
1 files changed, 71 insertions, 114 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d0b37b7f1b..7bfc9ccbec 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -111,6 +111,8 @@ bool QGuiApplicationPrivate::tabletState = false; QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; +Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; + QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -1063,6 +1065,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() delete platform_integration; platform_integration = 0; delete m_gammaTables.load(); + + window_list.clear(); } #if 0 @@ -1272,6 +1276,12 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv case QWindowSystemInterfacePrivate::WindowStateChanged: QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); break; + case QWindowSystemInterfacePrivate::ApplicationStateChanged: + QGuiApplicationPrivate::processApplicationStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e)); + break; + case QWindowSystemInterfacePrivate::FlushEvents: + QWindowSystemInterface::deferredFlushWindowSystemEvents(); + break; case QWindowSystemInterfacePrivate::Close: QGuiApplicationPrivate::processCloseEvent( static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); @@ -1497,10 +1507,20 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE { QWindow *window = e->window.data(); modifier_buttons = e->modifiers; - if (e->nullWindow) + if (e->nullWindow +#ifdef Q_OS_ANDROID + || (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) || e->key == Qt::Key_Menu +#endif + ) { window = QGuiApplication::focusWindow(); - if (!window) + } + if (!window +#ifdef Q_OS_ANDROID + && e->keyType != QEvent::KeyRelease && e->key != Qt::Key_Back +#endif + ) { return; + } if (window->d_func()->blockedByModalWindow) { // a modal window is blocking this window, don't allow key events through return; @@ -1510,7 +1530,19 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount); ev.setTimestamp(e->timestamp); - QGuiApplication::sendSpontaneousEvent(window, &ev); + +#ifdef Q_OS_ANDROID + if (e->keyType == QEvent::KeyRelease && e->key == Qt::Key_Back) { + if (!window) { + qApp->quit(); + } else { + QGuiApplication::sendEvent(window, &ev); + if (!ev.isAccepted() && e->key == Qt::Key_Back) + QWindowSystemInterface::handleCloseEvent(window); + } + } else +#endif + QGuiApplication::sendSpontaneousEvent(window, &ev); } void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) @@ -1567,7 +1599,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate QCoreApplication::sendSpontaneousEvent(previous, &focusOut); QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)), qApp, SLOT(_q_updateFocusObject(QObject*))); - } else { + } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { QEvent appActivate(QEvent::ApplicationActivate); qApp->sendSpontaneousEvent(qApp, &appActivate); } @@ -1577,7 +1609,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)), qApp, SLOT(_q_updateFocusObject(QObject*))); - } else { + } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { QEvent appActivate(QEvent::ApplicationDeactivate); qApp->sendSpontaneousEvent(qApp, &appActivate); } @@ -1601,6 +1633,24 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa } } +void QGuiApplicationPrivate::processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e) +{ + if (e->newState == applicationState) + return; + applicationState = e->newState; + + switch (e->newState) { + case Qt::ApplicationActive: { + QEvent appActivate(QEvent::ApplicationActivate); + qApp->sendSpontaneousEvent(qApp, &appActivate); + break; } + case Qt::ApplicationInactive: { + QEvent appDeactivate(QEvent::ApplicationDeactivate); + qApp->sendSpontaneousEvent(qApp, &appDeactivate); + break; } + } +} + void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) { if (self) @@ -1667,10 +1717,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) { - if (e->fileName.isEmpty()) + if (e->url.isEmpty()) return; - QFileOpenEvent event(e->fileName); + QFileOpenEvent event(e->url); QGuiApplication::sendSpontaneousEvent(qApp, &event); } @@ -2624,6 +2674,13 @@ static inline void applyCursor(QWindow *w, QCursor c) cursor->changeCursor(&c, w); } +static inline void unsetCursor(QWindow *w) +{ + if (const QScreen *screen = w->screen()) + if (QPlatformCursor *cursor = screen->handle()->cursor()) + cursor->changeCursor(0, w); +} + static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) { for (int i = 0; i < l.size(); ++i) { @@ -2637,8 +2694,13 @@ static inline void applyWindowCursor(const QList<QWindow *> &l) { for (int i = 0; i < l.size(); ++i) { QWindow *w = l.at(i); - if (w->handle() && w->type() != Qt::Desktop) - applyCursor(w, w->cursor()); + if (w->handle() && w->type() != Qt::Desktop) { + if (qt_window_private(w)->hasCursor) { + applyCursor(w, w->cursor()); + } else { + unsetCursor(w); + } + } } } @@ -2770,111 +2832,6 @@ QInputMethod *QGuiApplication::inputMethod() QFontDatabase::removeApplicationFont() */ -// These pixmaps approximate the images in the Windows User Interface Guidelines. - -// XPM - -static const char * const move_xpm[] = { -"11 20 3 1", -". c None", -"a c #FFFFFF", -"X c #000000", // X11 cursor is traditionally black -"aa.........", -"aXa........", -"aXXa.......", -"aXXXa......", -"aXXXXa.....", -"aXXXXXa....", -"aXXXXXXa...", -"aXXXXXXXa..", -"aXXXXXXXXa.", -"aXXXXXXXXXa", -"aXXXXXXaaaa", -"aXXXaXXa...", -"aXXaaXXa...", -"aXa..aXXa..", -"aa...aXXa..", -"a.....aXXa.", -"......aXXa.", -".......aXXa", -".......aXXa", -"........aa."}; - - -/* XPM */ -static const char * const copy_xpm[] = { -"24 30 3 1", -". c None", -"a c #000000", -"X c #FFFFFF", -"XX......................", -"XaX.....................", -"XaaX....................", -"XaaaX...................", -"XaaaaX..................", -"XaaaaaX.................", -"XaaaaaaX................", -"XaaaaaaaX...............", -"XaaaaaaaaX..............", -"XaaaaaaaaaX.............", -"XaaaaaaXXXX.............", -"XaaaXaaX................", -"XaaXXaaX................", -"XaX..XaaX...............", -"XX...XaaX...............", -"X.....XaaX..............", -"......XaaX..............", -".......XaaX.............", -".......XaaX.............", -"........XX...aaaaaaaaaaa", -".............aXXXXXXXXXa", -".............aXXXXXXXXXa", -".............aXXXXaXXXXa", -".............aXXXXaXXXXa", -".............aXXaaaaaXXa", -".............aXXXXaXXXXa", -".............aXXXXaXXXXa", -".............aXXXXXXXXXa", -".............aXXXXXXXXXa", -".............aaaaaaaaaaa"}; - -/* XPM */ -static const char * const link_xpm[] = { -"24 30 3 1", -". c None", -"a c #000000", -"X c #FFFFFF", -"XX......................", -"XaX.....................", -"XaaX....................", -"XaaaX...................", -"XaaaaX..................", -"XaaaaaX.................", -"XaaaaaaX................", -"XaaaaaaaX...............", -"XaaaaaaaaX..............", -"XaaaaaaaaaX.............", -"XaaaaaaXXXX.............", -"XaaaXaaX................", -"XaaXXaaX................", -"XaX..XaaX...............", -"XX...XaaX...............", -"X.....XaaX..............", -"......XaaX..............", -".......XaaX.............", -".......XaaX.............", -"........XX...aaaaaaaaaaa", -".............aXXXXXXXXXa", -".............aXXXaaaaXXa", -".............aXXXXaaaXXa", -".............aXXXaaaaXXa", -".............aXXaaaXaXXa", -".............aXXaaXXXXXa", -".............aXXaXXXXXXa", -".............aXXXaXXXXXa", -".............aXXXXXXXXXa", -".............aaaaaaaaaaa"}; - QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) { Q_UNUSED(cshape); |