4#include <QtCore/private/qohoscommon_p.h>
5#include <QtGui/private/qhighdpiscaling_p.h>
6#include <render/qohoshovereventsgenerator.h>
19 QtOhos::QThreadSafeRef<QWindow> qWindowRef,
20 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> imEventHandlerRef);
26 void sendQtHoverEvent(
bool isHover);
28 QtOhos::QThreadSafeRef<QWindow> m_qWindowRef;
29 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> m_imEventHandlerRef;
31 QOhosOptional<QPointF> m_optCurrentLocalPosition;
32 QOhosOptional<QPointF> m_optCurrentGlobalPosition;
37 QtOhos::QThreadSafeRef<QWindow> qWindowRef,
38 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> imEventHandlerRef)
47 m_optCurrentLocalPosition = mouseEvent.localPosition;
48 m_optCurrentGlobalPosition = mouseEvent.globalPosition;
51 sendQtHoverEvent(
true);
58 const auto localPosition = m_optCurrentLocalPosition.valueOr(fallbackLocalPositionWhenUnknown);
59 const auto globalPosition = m_optCurrentGlobalPosition.valueOr(fallbackGlobalPositionWhenUnknown);
61 m_imEventHandlerRef.visitInQtThreadIfAlive(
62 [isHover, localPosition, globalPosition, qWindowRef = m_qWindowRef](QOhosInputMethodEventHandler &imEventHandler) {
63 QWindow *qWindow = qWindowRef.data();
64 if (qWindow !=
nullptr) {
65 auto *platformScreen =
static_cast<QOhosPlatformScreen *>(qWindow->screen()->handle());
66 const auto scaledLocalPosition = QHighDpi::toNative(localPosition, platformScreen->pixelScalingCoefficient());
67 const auto scaledGlobalPosition = QHighDpi::toNative(globalPosition, platformScreen->pixelScalingCoefficient());
68 imEventHandler.onHoverEvent(isHover, scaledLocalPosition, scaledGlobalPosition, qWindow);
75 if (!hovered && m_hovered) {
76 sendQtHoverEvent(
false);
88 QtOhos::QThreadSafeRef<QWindow> qWindowRef,
89 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> imEventHandlerRef)
91 return std::make_shared<QOhosHoverEventsGeneratorImpl>(qWindowRef, imEventHandlerRef);
virtual ~QOhosHoverEventsGenerator()
QOhosHoverEventsGenerator()
void handleQOhosMouseEvent(const QOhosMouseEvent &mouseEvent) override
QOhosHoverEventsGeneratorImpl(QtOhos::QThreadSafeRef< QWindow > qWindowRef, QtOhos::QThreadSafeRef< QOhosInputMethodEventHandler > imEventHandlerRef)
void handleQOhosHoverEvent(bool hovered) override
Combined button and popup list for selecting options.
const QPointF fallbackGlobalPositionWhenUnknown
const QPointF fallbackLocalPositionWhenUnknown
std::shared_ptr< QOhosHoverEventsGenerator > makeQOhosHoverEventsGenerator(QtOhos::QThreadSafeRef< QWindow > qWindowRef, QtOhos::QThreadSafeRef< QOhosInputMethodEventHandler > imEventHandlerRef)