Swipe back/forward should respect system preferences

This commit is contained in:
Anthony Tseng 2016-08-01 11:26:51 +08:00
parent f8025d95b8
commit beca2d26f3
3 changed files with 18 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include "atom/common/color_util.h"
#include "atom/common/draggable_region.h"
#include "atom/common/options_switches.h"
#include "atom/common/platform_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h"
@ -577,6 +578,9 @@ NativeWindowMac::NativeWindowMac(
if (!web_contents)
return event;
if (!platform_util::IsSwipeTrackingFromScrollEventsEnabled())
return event;
if (!began && (([event phase] == NSEventPhaseMayBegin) ||
([event phase] == NSEventPhaseBegan))) {
this->NotifyWindowScrollTouchBegin();

View file

@ -42,6 +42,13 @@ bool MoveItemToTrash(const base::FilePath& full_path);
void Beep();
#if defined(OS_MACOSX)
// On 10.7+, back and forward swipe gestures can be triggered using a scroll
// gesture, if enabled in System Preferences. This function returns true if
// the feature is supported and enabled, and false otherwise.
bool IsSwipeTrackingFromScrollEventsEnabled();
#endif
} // namespace platform_util
#endif // ATOM_COMMON_PLATFORM_UTIL_H_

View file

@ -11,6 +11,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
#import "base/mac/sdk_forward_declarations.h"
#include "base/mac/scoped_aedesc.h"
#include "base/strings/sys_string_conversions.h"
#include "net/base/mac/url_conversions.h"
@ -168,4 +169,10 @@ void Beep() {
NSBeep();
}
bool IsSwipeTrackingFromScrollEventsEnabled() {
SEL selector = @selector(isSwipeTrackingFromScrollEventsEnabled);
return [NSEvent respondsToSelector:selector]
&& [NSEvent performSelector:selector];
}
} // namespace platform_util