Fix gesture processing on OS X 10.11

Starting from 10.11 beginGestureWithEvent/endGestureWithEvent never
gets called, we must test event.phase instead (magnify/rotate gestures).
For a magnify/rotate gesture, we'll first test phase (on 10.11)
and manually call our begin/endGestureWithEvent.

Task-number: QTBUG-48666
Change-Id: I69752b3c6578360b98607ceea2cffb5c166bb7c9
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Timur Pocheptsov 2016-04-11 14:36:12 +02:00
parent d229ed77db
commit 455f5df541

View File

@ -47,6 +47,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/QTextFormat>
#include <QtCore/QDebug>
#include <QtCore/qsysinfo.h>
#include <private/qguiapplication_p.h>
#include "qcocoabackingstore.h"
#ifndef QT_NO_OPENGL
@ -1252,8 +1253,29 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
#ifndef QT_NO_GESTURES
- (bool)handleGestureAsBeginEnd:(NSEvent *)event
{
if (QSysInfo::QSysInfo::MacintoshVersion < QSysInfo::MV_10_11)
return false;
if ([event phase] == NSEventPhaseBegan) {
[self beginGestureWithEvent:event];
return true;
}
if ([event phase] == NSEventPhaseEnded) {
[self endGestureWithEvent:event];
return true;
}
return false;
}
- (void)magnifyWithEvent:(NSEvent *)event
{
if ([self handleGestureAsBeginEnd:event])
return;
qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification];
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
@ -1280,7 +1302,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- (void)rotateWithEvent:(NSEvent *)event
{
qCDebug(lcQpaGestures) << "rotateWithEvent" << [event rotation];
if ([self handleGestureAsBeginEnd:event])
return;
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
QPointF screenPoint;