summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-27 13:06:38 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-27 13:06:38 +0200
commit572200989b224ad68e7b8ae4c0aecceb6ca871a2 (patch)
tree5591e8e6c17df64674aa79227ad6b70374c169ff /src/widgets/kernel
parent7ed024226faa9c53c6bad96fb6c9f38a22d25751 (diff)
parent241eca33ed45f112feed18c6256c31e606f47796 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: configure mkspecs/features/create_cmake.prf Change-Id: I94aea83b83833395d5db399209e0e51b92ef23b5
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qapplication.cpp49
-rw-r--r--src/widgets/kernel/qshortcut.cpp27
-rw-r--r--src/widgets/kernel/qwidget.cpp18
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp4
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp2
5 files changed, 77 insertions, 23 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 3fabeb1445..adccee9426 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2842,6 +2842,37 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
}
+ switch (e->type()) {
+ case QEvent::KeyPress:
+ {
+ bool isWidget = receiver->isWidgetType();
+ bool isWindow = receiver->isWindowType();
+ bool isGraphicsWidget = false;
+#ifndef QT_NO_GRAPHICSVIEW
+ isGraphicsWidget = !isWidget && !isWindow && qobject_cast<QGraphicsWidget *>(receiver);
+#endif
+ if (!isWidget && !isGraphicsWidget && !isWindow) {
+ return d->notify_helper(receiver, e);
+ }
+
+ QKeyEvent* key = static_cast<QKeyEvent*>(e);
+#ifndef QT_NO_SHORTCUT
+ // Try looking for a Shortcut before sending key events
+ if (qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key))
+ return true;
+#endif
+ qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
+ || key->key() == Qt::Key_Tab
+ || key->key() == Qt::Key_Left
+ || key->key() == Qt::Key_Up
+ || key->key() == Qt::Key_Right
+ || key->key() == Qt::Key_Down);
+
+ }
+ default:
+ break;
+ }
+
bool res = false;
if (!receiver->isWidgetType()) {
res = d->notify_helper(receiver, e);
@@ -2855,25 +2886,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
#ifndef QT_NO_GRAPHICSVIEW
isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
#endif
- if (!isWidget && !isGraphicsWidget) {
- res = d->notify_helper(receiver, e);
- break;
- }
-
QKeyEvent* key = static_cast<QKeyEvent*>(e);
- if (key->type()==QEvent::KeyPress) {
-#ifndef QT_NO_SHORTCUT
- // Try looking for a Shortcut before sending key events
- if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
- return res;
-#endif
- qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
- || key->key() == Qt::Key_Tab
- || key->key() == Qt::Key_Left
- || key->key() == Qt::Key_Up
- || key->key() == Qt::Key_Right
- || key->key() == Qt::Key_Down);
- }
bool def = key->isAccepted();
QPointer<QObject> pr = receiver;
while (receiver) {
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index c5cdce3d60..471b054a99 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -51,6 +51,7 @@
#include <private/qapplication_p.h>
#include <private/qshortcutmap_p.h>
#include <private/qaction_p.h>
+#include <private/qwidgetwindow_qpa_p.h>
QT_BEGIN_NAMESPACE
@@ -86,6 +87,20 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
if (QApplication::activePopupWidget())
active_window = QApplication::activePopupWidget();
+ if (!active_window) {
+ QWindow *qwindow = QGuiApplication::focusWindow();
+ if (qwindow && qwindow->isActive()) {
+ while (qwindow) {
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widgetWindow) {
+ active_window = widgetWindow->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+ }
+
if (!active_window)
return false;
@@ -106,6 +121,18 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
w = s->parentWidget();
}
+ if (!w) {
+ QWindow *qwindow = qobject_cast<QWindow *>(object);
+ while (qwindow) {
+ QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widget_window) {
+ w = widget_window->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+
if (!w)
return false;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 3eb949f814..a0c723fa0d 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -104,6 +104,8 @@
#include "qtabwidget.h" // Needed in inTabWidget()
#endif // QT_KEYPAD_NAVIGATION
+#include "qwindowcontainer_p.h"
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
@@ -1549,10 +1551,11 @@ void QWidgetPrivate::createTLExtra()
x->inTopLevelResize = false;
x->inRepaint = false;
x->embedded = 0;
+ x->window = 0;
+ x->screenIndex = 0;
#ifdef Q_WS_MAC
x->wasMaximized = false;
#endif // Q_WS_MAC
- createTLSysExtra();
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
qDebug() << "tlextra" << ++count;
@@ -6252,6 +6255,17 @@ bool QWidget::isActiveWindow() const
}
}
+ // Check for an active window container
+ if (QWindow *ww = QGuiApplication::focusWindow()) {
+ while (ww) {
+ QWidgetWindow *qww = qobject_cast<QWidgetWindow *>(ww);
+ QWindowContainer *qwc = qww ? qobject_cast<QWindowContainer *>(qww->widget()) : 0;
+ if (qwc && qwc->topLevelWidget() == tlw)
+ return true;
+ ww = ww->parent();
+ }
+ }
+
// Check if platform adaptation thinks the window is active. This is necessary for
// example in case of ActiveQt servers that are embedded into another application.
// Those are separate processes that are not part of the parent application Qt window/widget
@@ -10112,6 +10126,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break; }
case Qt::WA_NativeWindow: {
d->createTLExtra();
+ if (on)
+ d->createTLSysExtra();
#ifndef QT_NO_IM
QWidget *focusWidget = d->effectiveFocusWidget();
if (on && !internalWinId() && hasFocus()
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 3b6c9ca448..dafe7dc42a 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -890,9 +890,7 @@ void QWidgetPrivate::deleteSysExtra()
void QWidgetPrivate::createTLSysExtra()
{
Q_Q(QWidget);
- extra->topextra->screenIndex = 0;
- extra->topextra->window = 0;
- if (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow()) {
+ if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) {
extra->topextra->window = new QWidgetWindow(q);
if (extra->minw || extra->minh)
extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh));
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index c19b617091..18dd3156c6 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -446,7 +446,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (!widget)
widget = m_widget;
- if (event->type() == QEvent::MouseButtonPress && !qt_button_down)
+ if (event->type() == QEvent::MouseButtonPress)
qt_button_down = widget;
QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),