From 1af2b861d8915cfa9fe2d79f6ebb2ae22749f37b Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Date: Mon, 7 Sep 2015 15:00:09 +0200
Subject: [PATCH] Ensure the accepted state of mouse events is passed to
 QWindowSystemInterface.

On Windows, Qt needs to return false in case it does not handle the "extra"
buttons (like WM_XBUTTONDOWN) which causes Windows to send the
corresponding WM_APPCOMMAND message (like APPCOMMAND_BROWSER_FORWARD).

Task-number: QTBUG-48117
Change-Id: I093cd2d8205a39c3a042dd8a0d19c7229003761f
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
---
 src/gui/kernel/qguiapplication.cpp   | 1 +
 src/widgets/kernel/qwidgetwindow.cpp | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 94c831e18cd..736580f5478 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1809,6 +1809,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
     }
 
     QGuiApplication::sendSpontaneousEvent(window, &ev);
+    e->eventAccepted = ev.isAccepted();
     if (!e->synthetic() && !ev.isAccepted()
         && !frameStrut
         && qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index deaac4e263d..09b4edaf1da 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -552,6 +552,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
         translated.setTimestamp(event->timestamp());
         QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
                                             &qt_button_down, qt_last_mouse_receiver);
+        event->setAccepted(translated.isAccepted());
     }
 #ifndef QT_NO_CONTEXTMENU
     if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton
-- 
GitLab