diff options
author | Rafael Roquetto <rafael.roquetto.qnx@kdab.com> | 2013-03-05 16:31:53 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-06 16:48:39 (GMT) |
commit | df2cc57a592e11b464ec21ea530dad33f6fbee3e (patch) | |
tree | 459f5bab12654ee6343224ff7410d1a5ee729ee5 | |
parent | 08ea1e66b8dc701ce49643d193c923c011298a63 (diff) | |
download | Qt-df2cc57a592e11b464ec21ea530dad33f6fbee3e.zip Qt-df2cc57a592e11b464ec21ea530dad33f6fbee3e.tar.gz Qt-df2cc57a592e11b464ec21ea530dad33f6fbee3e.tar.bz2 |
Add WindowStateChanged event
Not currently considering activation state.
backport from qt5 8dc2f81c9f0e6eb8cab09e5d682358fd140b49b8
Change-Id: Ib46e554b08cc8d15f83e9865a8f0be3f8d7b9d16
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_qpa.cpp | 17 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_qpa.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_qpa.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_qpa_p.h | 11 |
5 files changed, 37 insertions, 0 deletions
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 400d1ef..1955c5b 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -499,6 +499,7 @@ public: static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e); static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e); + static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e); // static void reportScreenCount(int count); static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e); diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 0010ee2..e065a8a 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -118,6 +118,9 @@ void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate case QWindowSystemInterfacePrivate::ActivatedWindow: QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e)); break; + case QWindowSystemInterfacePrivate::WindowStateChanged: + QApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); + break; case QWindowSystemInterfacePrivate::Close: QApplicationPrivate::processCloseEvent( static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); @@ -147,6 +150,20 @@ void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate } } +void QApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) +{ + if (wse->tlw.isNull()) + return; + + QWidget *tlw = wse->tlw.data(); + if (!tlw->isWindow()) + return; + + QWindowStateChangeEvent e(tlw->windowState()); + tlw->setWindowState(wse->newState); + QApplication::sendSpontaneousEvent(tlw, &e); +} + QString QApplicationPrivate::appName() const { return QT_PREPEND_NAMESPACE(appName); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 0a3a3f6..53f0a59 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -89,6 +89,13 @@ void QWindowSystemInterface::handleWindowActivated(QWidget *tlw) QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } +void QWindowSystemInterface::handleWindowStateChanged(QWidget *tlw, Qt::WindowState newState) +{ + QWindowSystemInterfacePrivate::WindowStateChangedEvent *e = + new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) { if (tlw) { diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 64439a4..c211c46 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -95,6 +95,7 @@ public: static void handleEnterEvent(QWidget *w); static void handleLeaveEvent(QWidget *w); static void handleWindowActivated(QWidget *w); + static void handleWindowStateChanged(QWidget *w, Qt::WindowState newState); // Changes to the screen static void handleScreenGeometryChange(int screenIndex); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 32aa9b0..9cc82ff 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, @@ -114,6 +115,16 @@ public: QWeakPointer<QWidget> activated; }; + class WindowStateChangedEvent : public WindowSystemEvent { + public: + WindowStateChangedEvent(QWidget *_tlw, Qt::WindowState _newState) + : WindowSystemEvent(WindowStateChanged), tlw(_tlw), newState(_newState) + { } + + QWeakPointer<QWidget> tlw; + Qt::WindowState newState; + }; + class UserEvent : public WindowSystemEvent { public: UserEvent(QWidget * w, ulong time, EventType t) |