QNSView: Reset the internal buttons state after dragging ends

We only track left and right mouse buttons when dragging. But
some applications may do this with other mouse buttons.

In this case, instead of tracking which button was pressed and
which one was released, we just ask Cocoa for the current state.

Change-Id: I0df7799b7ae6d7816377f881bc0ede867737d245
Task-number: QTBUG-53374
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
bb10
Gabriel de Dietrich 2016-05-19 16:49:45 -07:00 committed by Timur Pocheptsov
parent a324194b59
commit b092f681cf
1 changed files with 5 additions and 1 deletions

View File

@ -2070,7 +2070,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
// keep our state, and QGuiApplication state (buttons member) in-sync,
// or future mouse events will be processed incorrectly
m_buttons &= ~(m_sendUpAsRightButton ? Qt::RightButton : Qt::LeftButton);
NSUInteger pmb = [NSEvent pressedMouseButtons];
for (int buttonNumber = 0; buttonNumber < 32; buttonNumber++) { // see cocoaButton2QtButton() for the 32 value
if (!(pmb & (1 << buttonNumber)))
m_buttons &= ~cocoaButton2QtButton(buttonNumber);
}
NSPoint windowPoint = [self convertPoint: point fromView: nil];
QPoint qtWindowPoint(windowPoint.x, windowPoint.y);