diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-04 13:59:06 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-04 14:59:52 +0200 |
commit | bb65ac80977c277b6cba1abee423ccfd5f1b1f4b (patch) | |
tree | 515f9d38167c9563d3be595435c1f1b111882e07 /src/gui/kernel | |
parent | 9a9bdebb92eda34939c8a7442f06d24ded82b799 (diff) |
Modernize QWindowSystemInterface::handleCloseEvent
The base WindowSystemEvent has had an eventAccepted flag since 2014.
Change-Id: Ia0aa795083cd98ece83a4c1cc010d3a25e2489fd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 5 |
5 files changed, 10 insertions, 16 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index fe73278c62..13de8af8b5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2527,9 +2527,8 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl QCloseEvent event; QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); - if (e->accepted) { - *(e->accepted) = event.isAccepted(); - } + + e->eventAccepted = event.isAccepted(); } void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 4e95751397..2a0cb1094c 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -348,9 +348,7 @@ void QPlatformWindow::setWindowIcon(const QIcon &icon) { Q_UNUSED(icon); } */ bool QPlatformWindow::close() { - bool accepted = false; - QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window(), &accepted); - return accepted; + return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window()); } /*! diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 40a298226a..03be72ca30 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -340,13 +340,11 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleExposeEvent, QWindow *window, const QReg QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } -QT_DEFINE_QPA_EVENT_HANDLER(void, handleCloseEvent, QWindow *window, bool *accepted) +QT_DEFINE_QPA_EVENT_HANDLER(bool, handleCloseEvent, QWindow *window) { - if (window) { - QWindowSystemInterfacePrivate::CloseEvent *e = - new QWindowSystemInterfacePrivate::CloseEvent(window, accepted); - QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); - } + Q_ASSERT(window); + auto *event = new QWindowSystemInterfacePrivate::CloseEvent(window); + return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(event); } /*! diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index fd70eda9ff..4a0bc858a9 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -194,7 +194,7 @@ public: static void handleExposeEvent(QWindow *window, const QRegion ®ion); template<typename Delivery = QWindowSystemInterface::DefaultDelivery> - static void handleCloseEvent(QWindow *window, bool *accepted = nullptr); + static bool handleCloseEvent(QWindow *window); template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleEnterEvent(QWindow *window, const QPointF &local = QPointF(), const QPointF& global = QPointF()); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index d6513f1836..540170f733 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -123,11 +123,10 @@ public: class CloseEvent : public WindowSystemEvent { public: - explicit CloseEvent(QWindow *w, bool *a = nullptr) - : WindowSystemEvent(Close), window(w), accepted(a) + explicit CloseEvent(QWindow *w) + : WindowSystemEvent(Close), window(w) { } QPointer<QWindow> window; - bool *accepted; }; class GeometryChangeEvent : public WindowSystemEvent { |