macOS: Improve mouse logging

Change-Id: Icc81f73e728d9b3669afc37b0c1ef73588f24749
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-02-28 13:49:11 +01:00
parent 18da1dac20
commit 4eda22ea0d
3 changed files with 35 additions and 10 deletions

View File

@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window");
Q_LOGGING_CATEGORY(lcQpaDrawing, "qt.qpa.drawing");
Q_LOGGING_CATEGORY(lcQpaMouse, "qt.qpa.input.mouse");
Q_LOGGING_CATEGORY(lcQpaMouse, "qt.qpa.input.mouse", QtCriticalMsg);
Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen");
//

View File

@ -177,17 +177,17 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
{
return [self handleDrag:sender];
return [self handleDrag:(QEvent::DragEnter) sender:sender];
}
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
{
QScopedValueRollback<bool> rollback(m_updatingDrag, true);
return [self handleDrag:sender];
return [self handleDrag:(QEvent::DragMove) sender:sender];
}
// Sends drag update to Qt, return the action
- (NSDragOperation)handleDrag:(id<NSDraggingInfo>)sender
- (NSDragOperation)handleDrag:(QEvent::Type)dragType sender:(id<NSDraggingInfo>)sender
{
if (!m_platformWindow)
return NSDragOperationNone;
@ -204,6 +204,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
const auto buttons = currentlyPressedMouseButtons();
const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
if (dragType == QEvent::DragEnter)
qCDebug(lcQpaMouse) << dragType << self << "at" << windowPoint;
else
qCDebug(lcQpaMouse) << dragType << "at" << windowPoint << "with" << buttons;
QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect());
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
if (nativeDrag->currentDrag()) {
@ -231,6 +236,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint();
qCDebug(lcQpaMouse) << QEvent::DragLeave << self << "at" << windowPoint;
// Send 0 mime data to indicate drag exit
QWindowSystemInterface::handleDrag(target, nullptr,
mapWindowCoordinates(m_platformWindow->window(), target, windowPoint),
@ -257,6 +264,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
const auto buttons = currentlyPressedMouseButtons();
const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
qCDebug(lcQpaMouse) << QEvent::Drop << "at" << windowPoint << "with" << buttons;
if (nativeDrag->currentDrag()) {
// The drag was started from within the application
response = QWindowSystemInterface::handleDrop(target, nativeDrag->dragMimeData(),
@ -285,6 +294,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
m_buttons = currentlyPressedMouseButtons();
qCDebug(lcQpaMouse) << "Drag session" << session << "ended, with" << m_buttons;
}
@end

View File

@ -93,6 +93,7 @@
- (void)resetMouseButtons
{
qCDebug(lcQpaMouse) << "Reseting mouse buttons";
m_buttons = Qt::NoButton;
m_frameStrutButtons = Qt::NoButton;
}
@ -145,6 +146,9 @@
QPoint qtScreenPoint = QCocoaScreen::mapFromNative(screenPoint).toPoint();
ulong timestamp = [theEvent timestamp] * 1000;
auto eventType = cocoaEvent2QtMouseEvent(theEvent);
qCInfo(lcQpaMouse) << "Frame-strut" << eventType << "at" << qtWindowPoint << "with" << m_frameStrutButtons << "in" << self.window;
QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
}
@end
@ -254,6 +258,11 @@
button = Qt::RightButton;
const auto eventType = cocoaEvent2QtMouseEvent(theEvent);
if (eventType == QEvent::MouseMove)
qCDebug(lcQpaMouse) << eventType << "at" << qtWindowPoint << "with" << buttons;
else
qCInfo(lcQpaMouse) << eventType << "of" << button << "at" << qtWindowPoint << "with" << buttons;
QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(),
timestamp, qtWindowPoint, qtScreenPoint,
buttons, button, eventType, modifiers);
@ -459,16 +468,16 @@
- (void)cursorUpdate:(NSEvent *)theEvent
{
qCDebug(lcQpaMouse) << "Updating cursor for" << self << "to" << self.cursor;
// Note: We do not get this callback when moving from a subview that
// uses the legacy cursorRect API, so the cursor is reset to the arrow
// cursor. See rdar://34183708
if (self.cursor)
if (self.cursor && self.cursor != NSCursor.currentCursor) {
qCInfo(lcQpaMouse) << "Updating cursor for" << self << "to" << self.cursor;
[self.cursor set];
else
} else {
[super cursorUpdate:theEvent];
}
}
- (void)mouseMovedImpl:(NSEvent *)theEvent
@ -523,6 +532,8 @@
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
qCInfo(lcQpaMouse) << QEvent::Enter << self << "at" << windowPoint << "with" << currentlyPressedMouseButtons();
QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
}
@ -541,6 +552,7 @@
if (!m_platformWindow->isContentView())
return;
qCInfo(lcQpaMouse) << QEvent::Leave << self;
QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow);
m_platformWindow->m_enterLeaveTargetWindow = 0;
}
@ -639,8 +651,10 @@
// "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective.
bool isInverted = [theEvent isDirectionInvertedFromDevice];
qCDebug(lcQpaMouse) << "scroll wheel @ window pos" << qt_windowPoint << "delta px" << pixelDelta
<< "angle" << angleDelta << "phase" << phase << (isInverted ? "inverted" : "");
qCInfo(lcQpaMouse).nospace() << phase << " at " << qt_windowPoint
<< " pixelDelta=" << pixelDelta << " angleDelta=" << angleDelta
<< (isInverted ? " inverted=true" : "");
QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint,
qt_screenPoint, pixelDelta, angleDelta, m_currentWheelModifiers, phase, source, isInverted);
}