summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguiapplication.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-03-20 13:46:57 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-03-20 13:49:28 +0100
commit76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch)
treef165b7bc319548fb0082365411a871028f92e89e /src/gui/kernel/qguiapplication.cpp
parent27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff)
parent36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff)
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle Conflicts: src/gui/text/qfontdatabase.cpp src/gui/text/qharfbuzz_copy_p.h src/widgets/kernel/qapplication.cpp src/widgets/kernel/qcoreapplication.cpp Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r--src/gui/kernel/qguiapplication.cpp193
1 files changed, 76 insertions, 117 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d42da6ee79..a1c9af45b8 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;
@@ -664,7 +666,7 @@ QWindowList QGuiApplication::topLevelWindows()
const QWindowList &list = QGuiApplicationPrivate::window_list;
QWindowList topLevelWindows;
for (int i = 0; i < list.size(); i++) {
- if (!list.at(i)->parent()) {
+ if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) {
// Top windows of embedded QAxServers do not have QWindow parents,
// but they are not true top level windows, so do not include them.
const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(0);
@@ -1065,6 +1067,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
delete platform_integration;
platform_integration = 0;
delete m_gammaTables.load();
+
+ window_list.clear();
}
#if 0
@@ -1274,6 +1278,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));
@@ -1499,10 +1509,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;
@@ -1512,7 +1532,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)
@@ -1565,21 +1597,21 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
return;
if (previous) {
- QFocusEvent focusOut(QEvent::FocusOut);
+ QFocusEvent focusOut(QEvent::FocusOut, e->reason);
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);
}
if (QGuiApplicationPrivate::focus_window) {
- QFocusEvent focusIn(QEvent::FocusIn);
+ QFocusEvent focusIn(QEvent::FocusIn, e->reason);
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);
}
@@ -1603,6 +1635,26 @@ 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; }
+ default:
+ break;
+ }
+}
+
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
{
if (self)
@@ -1669,10 +1721,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);
}
@@ -2626,6 +2678,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) {
@@ -2639,8 +2698,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);
+ }
+ }
}
}
@@ -2772,111 +2836,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);