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>
This commit is contained in:
parent
9a9bdebb92
commit
bb65ac8097
@ -2527,9 +2527,8 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
|
|||||||
|
|
||||||
QCloseEvent event;
|
QCloseEvent event;
|
||||||
QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
|
QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
|
||||||
if (e->accepted) {
|
|
||||||
*(e->accepted) = event.isAccepted();
|
e->eventAccepted = event.isAccepted();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
|
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
|
||||||
|
@ -348,9 +348,7 @@ void QPlatformWindow::setWindowIcon(const QIcon &icon) { Q_UNUSED(icon); }
|
|||||||
*/
|
*/
|
||||||
bool QPlatformWindow::close()
|
bool QPlatformWindow::close()
|
||||||
{
|
{
|
||||||
bool accepted = false;
|
return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
|
||||||
QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window(), &accepted);
|
|
||||||
return accepted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -340,13 +340,11 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleExposeEvent, QWindow *window, const QReg
|
|||||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
|
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) {
|
Q_ASSERT(window);
|
||||||
QWindowSystemInterfacePrivate::CloseEvent *e =
|
auto *event = new QWindowSystemInterfacePrivate::CloseEvent(window);
|
||||||
new QWindowSystemInterfacePrivate::CloseEvent(window, accepted);
|
return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(event);
|
||||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -194,7 +194,7 @@ public:
|
|||||||
static void handleExposeEvent(QWindow *window, const QRegion ®ion);
|
static void handleExposeEvent(QWindow *window, const QRegion ®ion);
|
||||||
|
|
||||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||||
static void handleCloseEvent(QWindow *window, bool *accepted = nullptr);
|
static bool handleCloseEvent(QWindow *window);
|
||||||
|
|
||||||
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
|
||||||
static void handleEnterEvent(QWindow *window, const QPointF &local = QPointF(), const QPointF& global = QPointF());
|
static void handleEnterEvent(QWindow *window, const QPointF &local = QPointF(), const QPointF& global = QPointF());
|
||||||
|
@ -123,11 +123,10 @@ public:
|
|||||||
|
|
||||||
class CloseEvent : public WindowSystemEvent {
|
class CloseEvent : public WindowSystemEvent {
|
||||||
public:
|
public:
|
||||||
explicit CloseEvent(QWindow *w, bool *a = nullptr)
|
explicit CloseEvent(QWindow *w)
|
||||||
: WindowSystemEvent(Close), window(w), accepted(a)
|
: WindowSystemEvent(Close), window(w)
|
||||||
{ }
|
{ }
|
||||||
QPointer<QWindow> window;
|
QPointer<QWindow> window;
|
||||||
bool *accepted;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GeometryChangeEvent : public WindowSystemEvent {
|
class GeometryChangeEvent : public WindowSystemEvent {
|
||||||
|
@ -1279,10 +1279,7 @@ bool QCocoaWindow::windowShouldClose()
|
|||||||
// should (be allowed to) close, but since our QPA API to determine
|
// should (be allowed to) close, but since our QPA API to determine
|
||||||
// that also involves actually closing the window we do both at the
|
// that also involves actually closing the window we do both at the
|
||||||
// same time, instead of doing the latter in windowWillClose.
|
// same time, instead of doing the latter in windowWillClose.
|
||||||
bool accepted = false;
|
return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
|
||||||
QWindowSystemInterface::handleCloseEvent(window(), &accepted);
|
|
||||||
QWindowSystemInterface::flushWindowSystemEvents();
|
|
||||||
return accepted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------- QPA forwarding -----------------------------
|
// ----------------------------- QPA forwarding -----------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user