зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1052253 - Part 1: Fix gestures when using macOS 10.11 or later SDK. r=mstange
`beginGestureWithEvent` and `endGestureWithEvent` are not called for applications that link against the macOS 10.11 or later SDK when we're running on macOS 10.11 or later. For compatibility with all supported macOS versions, we have to call {begin,end}GestureWithEvent ourselves based on the event phase when we're using the 10.11+ SDK. See: https://developer.apple.com/reference/appkit/nsresponder/1526368-begingesturewithevent
This commit is contained in:
Родитель
1b1642f523
Коммит
0e52c9ca9e
|
@ -208,6 +208,8 @@ static bool sIsTabletPointerActivated = false;
|
||||||
- (BOOL)inactiveWindowAcceptsMouseEvent:(NSEvent*)aEvent;
|
- (BOOL)inactiveWindowAcceptsMouseEvent:(NSEvent*)aEvent;
|
||||||
- (void)updateWindowDraggableState;
|
- (void)updateWindowDraggableState;
|
||||||
|
|
||||||
|
- (bool)beginOrEndGestureForEventPhase:(NSEvent*)aEvent;
|
||||||
|
|
||||||
- (bool)shouldConsiderStartingSwipeFromEvent:(NSEvent*)aEvent;
|
- (bool)shouldConsiderStartingSwipeFromEvent:(NSEvent*)aEvent;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -4179,8 +4181,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
if (!anEvent || !mGeckoChild)
|
if (!anEvent || !mGeckoChild ||
|
||||||
|
[self beginOrEndGestureForEventPhase:anEvent]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
||||||
|
|
||||||
|
@ -4209,22 +4213,14 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)beginGestureWithEvent:(NSEvent *)anEvent
|
|
||||||
{
|
|
||||||
if (!anEvent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mGestureState = eGestureState_StartGesture;
|
|
||||||
mCumulativeMagnification = 0;
|
|
||||||
mCumulativeRotation = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)magnifyWithEvent:(NSEvent *)anEvent
|
- (void)magnifyWithEvent:(NSEvent *)anEvent
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
if (!anEvent || !mGeckoChild)
|
if (!anEvent || !mGeckoChild ||
|
||||||
|
[self beginOrEndGestureForEventPhase:anEvent]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
||||||
|
|
||||||
|
@ -4265,7 +4261,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
if (!anEvent || !mGeckoChild) {
|
if (!anEvent || !mGeckoChild ||
|
||||||
|
[self beginOrEndGestureForEventPhase:anEvent]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4289,8 +4286,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
if (!anEvent || !mGeckoChild)
|
if (!anEvent || !mGeckoChild ||
|
||||||
|
[self beginOrEndGestureForEventPhase:anEvent]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
nsAutoRetainCocoaObject kungFuDeathGrip(self);
|
||||||
|
|
||||||
|
@ -4332,6 +4331,50 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `beginGestureWithEvent` and `endGestureWithEvent` are not called for
|
||||||
|
// applications that link against the macOS 10.11 or later SDK when we're
|
||||||
|
// running on macOS 10.11 or later. For compatibility with all supported macOS
|
||||||
|
// versions, we have to call {begin,end}GestureWithEvent ourselves based on
|
||||||
|
// the event phase when we're handling gestures.
|
||||||
|
- (bool)beginOrEndGestureForEventPhase:(NSEvent*)aEvent
|
||||||
|
{
|
||||||
|
if (!aEvent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool usingElCapitanOrLaterSDK = true;
|
||||||
|
#if !defined(MAC_OS_X_VERSION_10_11) || \
|
||||||
|
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
|
||||||
|
usingElCapitanOrLaterSDK = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (nsCocoaFeatures::OnElCapitanOrLater() && usingElCapitanOrLaterSDK) {
|
||||||
|
if (aEvent.phase == NSEventPhaseBegan) {
|
||||||
|
[self beginGestureWithEvent:aEvent];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aEvent.phase == NSEventPhaseEnded ||
|
||||||
|
aEvent.phase == NSEventPhaseCancelled) {
|
||||||
|
[self endGestureWithEvent:aEvent];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)beginGestureWithEvent:(NSEvent*)aEvent
|
||||||
|
{
|
||||||
|
if (!aEvent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mGestureState = eGestureState_StartGesture;
|
||||||
|
mCumulativeMagnification = 0;
|
||||||
|
mCumulativeRotation = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)endGestureWithEvent:(NSEvent *)anEvent
|
- (void)endGestureWithEvent:(NSEvent *)anEvent
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче