macOS: Improve mouse logging
Change-Id: Icc81f73e728d9b3669afc37b0c1ef73588f24749 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
18da1dac20
commit
4eda22ea0d
@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window");
|
Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window");
|
||||||
Q_LOGGING_CATEGORY(lcQpaDrawing, "qt.qpa.drawing");
|
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");
|
Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -177,17 +177,17 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
|
|||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
|
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
return [self handleDrag:sender];
|
return [self handleDrag:(QEvent::DragEnter) sender:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
|
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
QScopedValueRollback<bool> rollback(m_updatingDrag, true);
|
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
|
// 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)
|
if (!m_platformWindow)
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
@ -204,6 +204,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
|
|||||||
const auto buttons = currentlyPressedMouseButtons();
|
const auto buttons = currentlyPressedMouseButtons();
|
||||||
const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
|
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());
|
QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect());
|
||||||
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
|
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
|
||||||
if (nativeDrag->currentDrag()) {
|
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();
|
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
|
// Send 0 mime data to indicate drag exit
|
||||||
QWindowSystemInterface::handleDrag(target, nullptr,
|
QWindowSystemInterface::handleDrag(target, nullptr,
|
||||||
mapWindowCoordinates(m_platformWindow->window(), target, windowPoint),
|
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 buttons = currentlyPressedMouseButtons();
|
||||||
const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
|
const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
|
||||||
|
|
||||||
|
qCDebug(lcQpaMouse) << QEvent::Drop << "at" << windowPoint << "with" << buttons;
|
||||||
|
|
||||||
if (nativeDrag->currentDrag()) {
|
if (nativeDrag->currentDrag()) {
|
||||||
// The drag was started from within the application
|
// The drag was started from within the application
|
||||||
response = QWindowSystemInterface::handleDrop(target, nativeDrag->dragMimeData(),
|
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));
|
nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
|
||||||
|
|
||||||
m_buttons = currentlyPressedMouseButtons();
|
m_buttons = currentlyPressedMouseButtons();
|
||||||
|
|
||||||
|
qCDebug(lcQpaMouse) << "Drag session" << session << "ended, with" << m_buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -93,6 +93,7 @@
|
|||||||
|
|
||||||
- (void)resetMouseButtons
|
- (void)resetMouseButtons
|
||||||
{
|
{
|
||||||
|
qCDebug(lcQpaMouse) << "Reseting mouse buttons";
|
||||||
m_buttons = Qt::NoButton;
|
m_buttons = Qt::NoButton;
|
||||||
m_frameStrutButtons = Qt::NoButton;
|
m_frameStrutButtons = Qt::NoButton;
|
||||||
}
|
}
|
||||||
@ -145,6 +146,9 @@
|
|||||||
QPoint qtScreenPoint = QCocoaScreen::mapFromNative(screenPoint).toPoint();
|
QPoint qtScreenPoint = QCocoaScreen::mapFromNative(screenPoint).toPoint();
|
||||||
|
|
||||||
ulong timestamp = [theEvent timestamp] * 1000;
|
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);
|
QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
@ -254,6 +258,11 @@
|
|||||||
button = Qt::RightButton;
|
button = Qt::RightButton;
|
||||||
const auto eventType = cocoaEvent2QtMouseEvent(theEvent);
|
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(),
|
QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(),
|
||||||
timestamp, qtWindowPoint, qtScreenPoint,
|
timestamp, qtWindowPoint, qtScreenPoint,
|
||||||
buttons, button, eventType, modifiers);
|
buttons, button, eventType, modifiers);
|
||||||
@ -459,16 +468,16 @@
|
|||||||
|
|
||||||
- (void)cursorUpdate:(NSEvent *)theEvent
|
- (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
|
// 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
|
// uses the legacy cursorRect API, so the cursor is reset to the arrow
|
||||||
// cursor. See rdar://34183708
|
// 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];
|
[self.cursor set];
|
||||||
else
|
} else {
|
||||||
[super cursorUpdate:theEvent];
|
[super cursorUpdate:theEvent];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseMovedImpl:(NSEvent *)theEvent
|
- (void)mouseMovedImpl:(NSEvent *)theEvent
|
||||||
@ -523,6 +532,8 @@
|
|||||||
QPointF screenPoint;
|
QPointF screenPoint;
|
||||||
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||||
m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
|
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);
|
QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,6 +552,7 @@
|
|||||||
if (!m_platformWindow->isContentView())
|
if (!m_platformWindow->isContentView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
qCInfo(lcQpaMouse) << QEvent::Leave << self;
|
||||||
QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow);
|
QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow);
|
||||||
m_platformWindow->m_enterLeaveTargetWindow = 0;
|
m_platformWindow->m_enterLeaveTargetWindow = 0;
|
||||||
}
|
}
|
||||||
@ -639,8 +651,10 @@
|
|||||||
// "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective.
|
// "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective.
|
||||||
bool isInverted = [theEvent isDirectionInvertedFromDevice];
|
bool isInverted = [theEvent isDirectionInvertedFromDevice];
|
||||||
|
|
||||||
qCDebug(lcQpaMouse) << "scroll wheel @ window pos" << qt_windowPoint << "delta px" << pixelDelta
|
qCInfo(lcQpaMouse).nospace() << phase << " at " << qt_windowPoint
|
||||||
<< "angle" << angleDelta << "phase" << phase << (isInverted ? "inverted" : "");
|
<< " pixelDelta=" << pixelDelta << " angleDelta=" << angleDelta
|
||||||
|
<< (isInverted ? " inverted=true" : "");
|
||||||
|
|
||||||
QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint,
|
QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint,
|
||||||
qt_screenPoint, pixelDelta, angleDelta, m_currentWheelModifiers, phase, source, isInverted);
|
qt_screenPoint, pixelDelta, angleDelta, m_currentWheelModifiers, phase, source, isInverted);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user