summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp19
-rw-r--r--src/gui/kernel/qguiapplication_p.h3
-rw-r--r--src/gui/kernel/qinputmethod.h2
-rw-r--r--src/gui/kernel/qplatformscreen_p.h2
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.h2
-rw-r--r--src/gui/kernel/qplatformwindow_p.h2
-rw-r--r--src/gui/kernel/qscreen_p.h2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp42
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h43
10 files changed, 110 insertions, 13 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index a67917ca3b..64d2f8001f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1211,6 +1211,12 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QGuiApplicationPrivate::processFileOpenEvent(
static_cast<QWindowSystemInterfacePrivate::FileOpenEvent *>(e));
break;
+#ifndef QT_NO_CONTEXTMENU
+ case QWindowSystemInterfacePrivate::ContextMenu:
+ QGuiApplicationPrivate::processContextMenuEvent(
+ static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e));
+ break;
+#endif
default:
qWarning() << "Unknown user input event type:" << e->type;
break;
@@ -1639,6 +1645,19 @@ void QGuiApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePri
QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev);
}
+#ifndef QT_NO_CONTEXTMENU
+void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e)
+{
+ // Widgets do not care about mouse triggered context menu events. Also, do not forward event
+ // to a window blocked by a modal window.
+ if (!e->window || e->mouseTriggered || e->window->d_func()->blockedByModalWindow)
+ return;
+
+ QContextMenuEvent ev(QContextMenuEvent::Keyboard, e->pos, e->globalPos, e->modifiers);
+ QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev);
+}
+#endif
+
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k)
{
return qHash(k.device) + k.touchPointId;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 0c81d78f86..44a9275688 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -138,6 +138,9 @@ public:
static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e);
+#ifndef QT_NO_CONTEXTMENU
+ static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
+#endif
#ifndef QT_NO_DRAGANDDROP
static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h
index 25b133ec0a..d038542dc3 100644
--- a/src/gui/kernel/qinputmethod.h
+++ b/src/gui/kernel/qinputmethod.h
@@ -48,8 +48,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
class QInputMethodPrivate;
class QWindow;
class QRectF;
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h
index 8aaa8192c8..a63f8298ec 100644
--- a/src/gui/kernel/qplatformscreen_p.h
+++ b/src/gui/kernel/qplatformscreen_p.h
@@ -57,8 +57,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
class QScreen;
class QPlatformScreenPrivate
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h
index 9c07b0e03c..707e862fbc 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.h
+++ b/src/gui/kernel/qplatformsharedgraphicscache.h
@@ -58,8 +58,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
class Q_GUI_EXPORT QPlatformSharedGraphicsCache: public QObject
{
Q_OBJECT
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index f4bb8ed388..ac9abfa10b 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_p.h
@@ -59,8 +59,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
class QPlatformWindowPrivate
{
public:
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 0bd63ca57b..f3b6082c15 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -51,8 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
class QScreenPrivate : public QObjectPrivate
{
public:
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index d05dc8cbdc..6fb10b6c75 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -89,6 +89,26 @@ void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
+/*!
+ This method can be used to ensure leave and enter events are both in queue when moving from
+ one QWindow to another. This allows QWindow subclasses to check for a queued enter event
+ when handling the leave event (\c QWindowSystemInterfacePrivate::peekWindowSystemEvent) to
+ determine where mouse went and act accordingly. E.g. QWidgetWindow needs to know if mouse
+ cursor moves between windows in same window hierarchy.
+*/
+void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave)
+{
+ bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents;
+ if (wasSynchronous)
+ setSynchronousWindowsSystemEvents(false);
+ handleLeaveEvent(leave);
+ handleEnterEvent(enter);
+ if (wasSynchronous) {
+ flushWindowSystemEvents();
+ setSynchronousWindowsSystemEvents(true);
+ }
+}
+
void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
{
QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
@@ -324,6 +344,16 @@ QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate
return windowSystemEventQueue.takeFirstOrReturnNull();
}
+QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)
+{
+ return windowSystemEventQueue.peekAtFirstOfType(t);
+}
+
+void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *event)
+{
+ windowSystemEventQueue.remove(event);
+}
+
void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
{
if (synchronousWindowsSystemEvents) {
@@ -600,6 +630,18 @@ void QWindowSystemInterface::handlePlatformPanelEvent(QWindow *w)
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
+#ifndef QT_NO_CONTEXTMENU
+void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTriggered,
+ const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers)
+{
+ QWindowSystemInterfacePrivate::ContextMenuEvent *e =
+ new QWindowSystemInterfacePrivate::ContextMenuEvent(w, mouseTriggered, pos,
+ globalPos, modifiers);
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+}
+#endif
+
Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
QWindowSystemInterface::handleMouseEvent(w, local, global, b, mods);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index cf5d22edbd..b4b2e845fc 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -136,6 +136,7 @@ public:
static void handleCloseEvent(QWindow *w);
static void handleEnterEvent(QWindow *w);
static void handleLeaveEvent(QWindow *w);
+ static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave);
static void handleWindowActivated(QWindow *w);
static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
@@ -174,6 +175,11 @@ public:
static void handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid);
static void handlePlatformPanelEvent(QWindow *w);
+#ifndef QT_NO_CONTEXTMENU
+ static void handleContextMenuEvent(QWindow *w, bool mouseTriggered,
+ const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers);
+#endif
// For event dispatcher implementations
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index e9d2fadc84..1b5351db71 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -52,7 +52,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QWindowSystemInterfacePrivate {
+class Q_GUI_EXPORT QWindowSystemInterfacePrivate {
public:
enum EventType {
Close,
@@ -77,7 +77,8 @@ public:
Tablet,
TabletEnterProximity,
TabletLeaveProximity,
- PlatformPanel
+ PlatformPanel,
+ ContextMenu
};
class WindowSystemEvent {
@@ -333,6 +334,21 @@ public:
QPointer<QWindow> window;
};
+#ifndef QT_NO_CONTEXTMENU
+ class ContextMenuEvent : public WindowSystemEvent {
+ public:
+ explicit ContextMenuEvent(QWindow *w, bool mouseTriggered, const QPoint &pos,
+ const QPoint &globalPos, Qt::KeyboardModifiers modifiers)
+ : WindowSystemEvent(ContextMenu), window(w), mouseTriggered(mouseTriggered), pos(pos),
+ globalPos(globalPos), modifiers(modifiers) { }
+ QPointer<QWindow> window;
+ bool mouseTriggered;
+ QPoint pos; // Only valid if triggered by mouse
+ QPoint globalPos; // Only valid if triggered by mouse
+ Qt::KeyboardModifiers modifiers;
+ };
+#endif
+
class WindowSystemEventList {
QList<WindowSystemEvent *> impl;
mutable QMutex mutex;
@@ -349,6 +365,25 @@ public:
{ const QMutexLocker locker(&mutex); impl.append(e); }
int count() const
{ const QMutexLocker locker(&mutex); return impl.count(); }
+ WindowSystemEvent *peekAtFirstOfType(EventType t) const
+ {
+ const QMutexLocker locker(&mutex);
+ for (int i = 0; i < impl.size(); ++i) {
+ if (impl.at(i)->type == t)
+ return impl.at(i);
+ }
+ return 0;
+ }
+ void remove(const WindowSystemEvent *e)
+ {
+ const QMutexLocker locker(&mutex);
+ for (int i = 0; i < impl.size(); ++i) {
+ if (impl.at(i) == e) {
+ impl.removeAt(i);
+ break;
+ }
+ }
+ }
private:
Q_DISABLE_COPY(WindowSystemEventList);
};
@@ -356,7 +391,9 @@ public:
static WindowSystemEventList windowSystemEventQueue;
static int windowSystemEventsQueued();
- static WindowSystemEvent * getWindowSystemEvent();
+ static WindowSystemEvent *getWindowSystemEvent();
+ static WindowSystemEvent *peekWindowSystemEvent(EventType t);
+ static void removeWindowSystemEvent(WindowSystemEvent *event);
static void handleWindowSystemEvent(WindowSystemEvent *ev);
static QElapsedTimer eventTime;