diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 43ce7ac9..a52e1927 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -239,6 +239,11 @@ void MainWindow::closeEvent(QCloseEvent *event) QVCocoaFunctions::setFullSizeContentView(windowHandle(), false); #endif +#if defined COCOA_LOADED && QT_VERSION == QT_VERSION_CHECK(6, 8, 1) + // Workaround for QTBUG-131783 + QVCocoaFunctions::flushLastInputEvent(windowHandle()); +#endif + if (qvApp->isSessionStateSaveRequested()) qvApp->addClosedWindowSessionState(getSessionState(), getLastActivatedTimestamp()); diff --git a/src/qvcocoafunctions.h b/src/qvcocoafunctions.h index 94ff2318..2d39b9a2 100644 --- a/src/qvcocoafunctions.h +++ b/src/qvcocoafunctions.h @@ -25,6 +25,8 @@ class QVCocoaFunctions static void closeWindow(QWindow *window); + static void flushLastInputEvent(QWindow *window); + static void setWindowMenu(QMenu *menu); static void setAlternate(QMenu *menu, int index); diff --git a/src/qvcocoafunctions.mm b/src/qvcocoafunctions.mm index 57b55602..5754e501 100644 --- a/src/qvcocoafunctions.mm +++ b/src/qvcocoafunctions.mm @@ -155,6 +155,12 @@ static void fixNativeMenuEccentricities(QMenu *menu, NSMenu *nativeMenu) [view.window close]; } +void QVCocoaFunctions::flushLastInputEvent(QWindow *window) +{ + auto *view = reinterpret_cast(window->winId()); + [view touchesCancelledWithEvent:nil]; +} + void QVCocoaFunctions::setWindowMenu(QMenu *menu) { NSMenu *nativeMenu = menu->toNSMenu();