Skip to content

Commit

Permalink
macOS: Move handleMouseEvent: to MouseAPI category
Browse files Browse the repository at this point in the history
Fixes warning of method definition not found.

Change-Id: I87866785d1564e29fc356c033ae8cf972548ea7f
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
torarnv committed Sep 14, 2021
1 parent de80346 commit 198c24a
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions src/plugins/platforms/cocoa/qnsview_mouse.mm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,59 @@ - (void)resetMouseButtons
m_frameStrutButtons = Qt::NoButton;
}

- (void)handleMouseEvent:(NSEvent *)theEvent
{
if (!m_platformWindow)
return;

#ifndef QT_NO_TABLETEVENT
// Tablet events may come in via the mouse event handlers,
// check if this is a valid tablet event first.
if ([self handleTabletEvent: theEvent])
return;
#endif

QPointF qtWindowPoint;
QPointF qtScreenPoint;
QNSView *targetView = self;
if (!targetView.platformWindow)
return;

// Popups implicitly grap mouse events; forward to the active popup if there is one
if (QCocoaWindow *popup = QCocoaIntegration::instance()->activePopupWindow()) {
// Tooltips must be transparent for mouse events
// The bug reference is QTBUG-46379
if (!popup->window()->flags().testFlag(Qt::ToolTip)) {
if (QNSView *popupView = qnsview_cast(popup->view()))
targetView = popupView;
}
}

[targetView convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;

QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
nativeDrag->setLastMouseEvent(theEvent, self);

const auto modifiers = QAppleKeyMapper::fromCocoaModifiers(theEvent.modifierFlags);
auto button = cocoaButton2QtButton(theEvent);
if (button == Qt::LeftButton && m_sendUpAsRightButton)
button = Qt::RightButton;
const auto eventType = cocoaEvent2QtMouseEvent(theEvent);

const QPointingDevice *device = pointingDeviceFor(theEvent.deviceID);
Q_ASSERT(device);

if (eventType == QEvent::MouseMove)
qCDebug(lcQpaMouse) << eventType << "at" << qtWindowPoint << "with" << m_buttons;
else
qCInfo(lcQpaMouse) << eventType << "of" << button << "at" << qtWindowPoint << "with" << m_buttons;

QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(),
timestamp, qtWindowPoint, qtScreenPoint,
m_buttons, button, eventType, modifiers);
}

- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent
{
if (!m_platformWindow)
Expand Down Expand Up @@ -316,59 +369,6 @@ - (NSPoint)screenMousePoint:(NSEvent *)theEvent
return screenPoint;
}

- (void)handleMouseEvent:(NSEvent *)theEvent
{
if (!m_platformWindow)
return;

#ifndef QT_NO_TABLETEVENT
// Tablet events may come in via the mouse event handlers,
// check if this is a valid tablet event first.
if ([self handleTabletEvent: theEvent])
return;
#endif

QPointF qtWindowPoint;
QPointF qtScreenPoint;
QNSView *targetView = self;
if (!targetView.platformWindow)
return;

// Popups implicitly grap mouse events; forward to the active popup if there is one
if (QCocoaWindow *popup = QCocoaIntegration::instance()->activePopupWindow()) {
// Tooltips must be transparent for mouse events
// The bug reference is QTBUG-46379
if (!popup->window()->flags().testFlag(Qt::ToolTip)) {
if (QNSView *popupView = qnsview_cast(popup->view()))
targetView = popupView;
}
}

[targetView convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;

QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
nativeDrag->setLastMouseEvent(theEvent, self);

const auto modifiers = QAppleKeyMapper::fromCocoaModifiers(theEvent.modifierFlags);
auto button = cocoaButton2QtButton(theEvent);
if (button == Qt::LeftButton && m_sendUpAsRightButton)
button = Qt::RightButton;
const auto eventType = cocoaEvent2QtMouseEvent(theEvent);

const QPointingDevice *device = pointingDeviceFor(theEvent.deviceID);
Q_ASSERT(device);

if (eventType == QEvent::MouseMove)
qCDebug(lcQpaMouse) << eventType << "at" << qtWindowPoint << "with" << m_buttons;
else
qCInfo(lcQpaMouse) << eventType << "of" << button << "at" << qtWindowPoint << "with" << m_buttons;

QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(),
timestamp, qtWindowPoint, qtScreenPoint,
m_buttons, button, eventType, modifiers);
}

- (bool)handleMouseDownEvent:(NSEvent *)theEvent
{
if ([self isTransparentForUserInput])
Expand Down

0 comments on commit 198c24a

Please sign in to comment.