Use QWindowSystemInterface::handleWheelEvent.

This commit is contained in:
John Preston 2023-06-29 20:48:38 +04:00
parent ed00cd2809
commit 08f8054866

View file

@ -25,6 +25,7 @@
#include <QtWidgets/QStyleFactory> #include <QtWidgets/QStyleFactory>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#include <qpa/qwindowsysteminterface.h>
#include <dwmapi.h> #include <dwmapi.h>
#include <uxtheme.h> #include <uxtheme.h>
@ -32,8 +33,6 @@
Q_DECLARE_METATYPE(QMargins); Q_DECLARE_METATYPE(QMargins);
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
namespace Ui::Platform { namespace Ui::Platform {
namespace { namespace {
@ -422,20 +421,19 @@ void WindowHelper::handleDirectManipulationEvent(
using Type = DirectManipulationEventType; using Type = DirectManipulationEventType;
const auto send = [&](Qt::ScrollPhase phase) { const auto send = [&](Qt::ScrollPhase phase) {
if (const auto windowHandle = window()->windowHandle()) { if (const auto windowHandle = window()->windowHandle()) {
const auto global = QCursor::pos(); auto global = POINT();
const auto local = windowHandle->mapFromGlobal(global); ::GetCursorPos(&global);
auto e = QWheelEvent( auto local = global;
QPointF(local), ::ScreenToClient(_handle, &local);
QPointF(global), QWindowSystemInterface::handleWheelEvent(
windowHandle,
QPointF(local.x, local.y),
QPointF(global.x, global.y),
event.delta, event.delta,
event.delta, event.delta,
QGuiApplication::mouseButtons(),
QGuiApplication::keyboardModifiers(), QGuiApplication::keyboardModifiers(),
phase, phase,
false, Qt::MouseEventSynthesizedBySystem);
Qt::MouseEventSynthesizedByApplication);
e.setTimestamp(crl::now());
qt_sendSpontaneousEvent(windowHandle, &e);
} }
}; };
switch (event.type) { switch (event.type) {