summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/controls/qquickmenupopupwindow.cpp28
-rw-r--r--src/controls/qquickmenupopupwindow_p.h3
2 files changed, 29 insertions, 2 deletions
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index b44b082c..dd68b15c 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -42,14 +42,15 @@
#include "qquickmenupopupwindow_p.h"
#include <qguiapplication.h>
+#include <qpa/qwindowsysteminterface.h>
#include <qquickitem.h>
#include <QtGui/QScreen>
QT_BEGIN_NAMESPACE
QQuickMenuPopupWindow::QQuickMenuPopupWindow(QWindow *parent) :
- QQuickWindow(parent), m_mouseMoved(false), m_itemAt(0),
- m_parentItem(0), m_menuContentItem(0)
+ QQuickWindow(parent), m_mouseMoved(false), m_needsActivatedEvent(true),
+ m_itemAt(0), m_parentItem(0), m_menuContentItem(0)
{
setFlags(Qt::Popup);
setModality(Qt::WindowModal);
@@ -235,4 +236,27 @@ void QQuickMenuPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
}
}
+void QQuickMenuPopupWindow::exposeEvent(QExposeEvent *e)
+{
+ if (isExposed() && m_needsActivatedEvent) {
+ m_needsActivatedEvent = false;
+ QWindowSystemInterface::handleWindowActivated(this, Qt::PopupFocusReason);
+ } else if (!isExposed() && !m_needsActivatedEvent) {
+ m_needsActivatedEvent = true;
+ if (QWindow *tp = transientParent())
+ QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason);
+ }
+ QQuickWindow::exposeEvent(e);
+}
+
+void QQuickMenuPopupWindow::hideEvent(QHideEvent *e)
+{
+ if (QWindow *tp = !m_needsActivatedEvent ? transientParent() : 0) {
+ m_needsActivatedEvent = true;
+ QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason);
+ }
+
+ QQuickWindow::hideEvent(e);
+}
+
QT_END_NAMESPACE
diff --git a/src/controls/qquickmenupopupwindow_p.h b/src/controls/qquickmenupopupwindow_p.h
index aead2bd8..b515ec3d 100644
--- a/src/controls/qquickmenupopupwindow_p.h
+++ b/src/controls/qquickmenupopupwindow_p.h
@@ -81,11 +81,14 @@ protected:
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
+ void exposeEvent(QExposeEvent *);
+ void hideEvent(QHideEvent *);
private:
void forwardEventToTransientParent(QMouseEvent *);
bool m_mouseMoved;
+ bool m_needsActivatedEvent;
QQuickItem *m_itemAt;
QPointF m_oldItemPos;
QQuickItem *m_parentItem;