summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-08-04 10:36:48 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-08-05 10:41:43 +0200
commit8dc2f81c9f0e6eb8cab09e5d682358fd140b49b8 (patch)
tree3d6fcd59b6b9f943e1e464fbf2f395939ae051ea
parent7d07ca24882ec49045c33d3cc67457bba6f5f73d (diff)
Add WindowStateChanged event.
Not currently considering activation state. Change-Id: Iea9265d35536947b6cc85639bd9839e9fda69bdf Reviewed-on: http://codereview.qt.nokia.com/2609 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
-rw-r--r--src/gui/kernel/qguiapplication.cpp12
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp7
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h1
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h21
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp14
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa_p.h1
7 files changed, 52 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index f739037cc6..f1edf52b0a 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -510,6 +510,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
case QWindowSystemInterfacePrivate::ActivatedWindow:
QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
break;
+ case QWindowSystemInterfacePrivate::WindowStateChanged:
+ QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
+ break;
case QWindowSystemInterfacePrivate::Close:
QGuiApplicationPrivate::processCloseEvent(
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
@@ -690,6 +693,15 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
self->notifyActiveWindowChange(previous);
}
+void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
+{
+ if (QWindow *window = wse->window.data()) {
+ QWindowStateChangeEvent e(window->windowState());
+ window->d_func()->windowState = wse->newState;
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+}
+
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
{
if (e->tlw.isNull())
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 325c89e363..fc6da6fd31 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -114,6 +114,7 @@ public:
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+ static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index e6fbd5b875..047c134b69 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -80,6 +80,13 @@ void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowState newState)
+{
+ QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
+ new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
{
QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
index 7df7c2deb4..52838e03c5 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.h
@@ -99,6 +99,7 @@ public:
static void handleEnterEvent(QWindow *w);
static void handleLeaveEvent(QWindow *w);
static void handleWindowActivated(QWindow *w);
+ static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
static void handleMapEvent(QWindow *w);
static void handleUnmapEvent(QWindow *w);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
index 912ac877fb..1e772eb2b8 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -55,6 +55,7 @@ public:
Enter,
Leave,
ActivatedWindow,
+ WindowStateChanged,
Mouse,
Wheel,
Key,
@@ -69,14 +70,14 @@ public:
class WindowSystemEvent {
public:
- WindowSystemEvent(EventType t)
+ explicit WindowSystemEvent(EventType t)
: type(t) { }
EventType type;
};
class CloseEvent : public WindowSystemEvent {
public:
- CloseEvent(QWindow *w)
+ explicit CloseEvent(QWindow *w)
: WindowSystemEvent(Close), window(w) { }
QWeakPointer<QWindow> window;
};
@@ -92,7 +93,7 @@ public:
class EnterEvent : public WindowSystemEvent {
public:
- EnterEvent(QWindow *enter)
+ explicit EnterEvent(QWindow *enter)
: WindowSystemEvent(Enter), enter(enter)
{ }
QWeakPointer<QWindow> enter;
@@ -100,7 +101,7 @@ public:
class LeaveEvent : public WindowSystemEvent {
public:
- LeaveEvent(QWindow *leave)
+ explicit LeaveEvent(QWindow *leave)
: WindowSystemEvent(Leave), leave(leave)
{ }
QWeakPointer<QWindow> leave;
@@ -108,12 +109,22 @@ public:
class ActivatedWindowEvent : public WindowSystemEvent {
public:
- ActivatedWindowEvent(QWindow *activatedWindow)
+ explicit ActivatedWindowEvent(QWindow *activatedWindow)
: WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
{ }
QWeakPointer<QWindow> activated;
};
+ class WindowStateChangedEvent : public WindowSystemEvent {
+ public:
+ WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState)
+ : WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState)
+ { }
+
+ QWeakPointer<QWindow> window;
+ Qt::WindowState newState;
+ };
+
class UserEvent : public WindowSystemEvent {
public:
UserEvent(QWindow * w, ulong time, EventType t)
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp
index 24e76f05d6..ab8bacc1c7 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa.cpp
+++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp
@@ -114,6 +114,10 @@ bool QWidgetWindow::event(QEvent *event)
handleExposeEvent(static_cast<QExposeEvent *>(event));
return true;
+ case QEvent::WindowStateChange:
+ handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event));
+ return true;
+
default:
break;
}
@@ -385,4 +389,14 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event)
m_widget->d_func()->syncBackingStore(event->region());
}
+void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event)
+{
+ // QWindow does currently not know 'active'.
+ Qt::WindowStates eventState = event->oldState();
+ if (m_widget->windowState() & Qt::WindowActive)
+ eventState |= Qt::WindowActive;
+ QWindowStateChangeEvent widgetEvent(eventState);
+ QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
+}
+
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h
index f200839b0b..4253072933 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa_p.h
+++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h
@@ -76,6 +76,7 @@ protected:
void handleWheelEvent(QWheelEvent *);
void handleDragEvent(QEvent *);
void handleExposeEvent(QExposeEvent *);
+ void handleWindowStateChangedEvent(QWindowStateChangeEvent *event);
private:
void updateGeometry();