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;
|
||||
QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
|
||||
if (e->accepted) {
|
||||
*(e->accepted) = event.isAccepted();
|
||||
}
|
||||
|
||||
e->eventAccepted = event.isAccepted();
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e)
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -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());
|
||||
|
@ -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 {
|
||||
|
@ -1275,14 +1275,11 @@ void QCocoaWindow::windowWillClose()
|
||||
bool QCocoaWindow::windowShouldClose()
|
||||
{
|
||||
qCDebug(lcQpaWindow) << "QCocoaWindow::windowShouldClose" << window();
|
||||
// This callback should technically only determine if the window
|
||||
// should (be allowed to) close, but since our QPA API to determine
|
||||
// that also involves actually closing the window we do both at the
|
||||
// same time, instead of doing the latter in windowWillClose.
|
||||
bool accepted = false;
|
||||
QWindowSystemInterface::handleCloseEvent(window(), &accepted);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
return accepted;
|
||||
// This callback should technically only determine if the window
|
||||
// should (be allowed to) close, but since our QPA API to determine
|
||||
// that also involves actually closing the window we do both at the
|
||||
// same time, instead of doing the latter in windowWillClose.
|
||||
return QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(window());
|
||||
}
|
||||
|
||||
// ----------------------------- QPA forwarding -----------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user