Skip to content
Snippets Groups Projects
Commit 3ced0678 authored by George Nachman's avatar George Nachman
Browse files

Don't accept touch events if they're not needed

parent d8141ee7
No related branches found
No related tags found
No related merge requests found
// -*- mode:objc -*-
// $Id: PTYTextView.m,v 1.325 2009-02-06 14:33:17 delx Exp $
/*
Loading
Loading
@@ -65,6 +64,7 @@ static const int MAX_WORKING_DIR_COUNT = 50;
#import "SmartSelectionController.h"
#import "ITAddressBookMgr.h"
#import "PointerController.h"
#import "PointerPrefsController.h"
 
#include <sys/time.h>
#include <math.h>
Loading
Loading
@@ -303,6 +303,10 @@ static CGFloat PerceivedBrightness(CGFloat r, CGFloat g, CGFloat b) {
selector:@selector(_settingsChanged:)
name:@"iTermRefreshTerminal"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_pointerSettingsChanged:)
name:kPointerPrefsChangedNotification
object:nil];
 
advancedFontRendering = [[PreferencePanel sharedInstance] advancedFontRendering];
strokeThickness = [[PreferencePanel sharedInstance] strokeThickness];
Loading
Loading
@@ -316,8 +320,10 @@ static CGFloat PerceivedBrightness(CGFloat r, CGFloat g, CGFloat b) {
pointer_ = [[PointerController alloc] init];
pointer_.delegate = self;
 
[self futureSetAcceptsTouchEvents:YES];
[self futureSetWantsRestingTouches:YES];
if ([pointer_ viewShouldTrackTouches]) {
[self futureSetAcceptsTouchEvents:YES];
[self futureSetWantsRestingTouches:YES];
}
 
return self;
}
Loading
Loading
@@ -7647,6 +7653,16 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
}
 
- (void)_pointerSettingsChanged:(NSNotification *)notification
{
BOOL track = [pointer_ viewShouldTrackTouches];
[self futureSetAcceptsTouchEvents:track];
[self futureSetWantsRestingTouches:track];
if (!track) {
numTouches_ = 0;
}
}
- (void)_settingsChanged:(NSNotification *)notification
{
advancedFontRendering = [[PreferencePanel sharedInstance] advancedFontRendering];
Loading
Loading
Loading
Loading
@@ -49,5 +49,6 @@
- (BOOL)mouseUp:(NSEvent *)event withTouches:(int)numTouches;
- (void)swipeWithEvent:(NSEvent *)event;
- (BOOL)eventEmulatesRightClick:(NSEvent *)event;
- (BOOL)viewShouldTrackTouches;
 
@end
Loading
Loading
@@ -69,6 +69,11 @@
}
}
 
- (BOOL)viewShouldTrackTouches
{
return [PointerPrefsController haveThreeFingerTapEvents];
}
- (BOOL)eventEmulatesRightClick:(NSEvent *)event
{
return ![[PreferencePanel sharedInstance] passOnControlLeftClick] &&
Loading
Loading
Loading
Loading
@@ -40,6 +40,8 @@ extern NSString *kThreeFingerSwipeLeft;
extern NSString *kThreeFingerSwipeUp;
extern NSString *kThreeFingerSwipeDown;
 
extern NSString *kPointerPrefsChangedNotification;
@interface PointerPrefsController : NSObject {
IBOutlet NSTableView *tableView_;
IBOutlet NSTableColumn *buttonColumn_;
Loading
Loading
@@ -86,6 +88,7 @@ extern NSString *kThreeFingerSwipeDown;
modifiers:(int)modMask;
+ (NSString *)argumentForGesture:(NSString *)gesture
modifiers:(int)modMask;
+ (BOOL)haveThreeFingerTapEvents;
 
- (void)setButtonNumber:(int)buttonNumber clickCount:(int)clickCount modifiers:(int)modMask;
- (void)setGesture:(NSString *)gesture modifiers:(int)modMask;
Loading
Loading
Loading
Loading
@@ -18,6 +18,7 @@ static NSString *kCommandKeyChar = @"c";
static NSString *kOptionKeyChar = @"o";
static NSString *kShiftKeyChar = @"s";
static NSString *kControlKeyChar = @"^";
#define kLeftButton 0
#define kRightButton 1
#define kMiddleButton 2
Loading
Loading
@@ -65,6 +66,8 @@ NSString *kSelectNextPanePointerAction = @"kSelectNextPanePointerAction";
NSString *kSelectPreviousPanePointerAction = @"kSelectPreviousPanePointerAction";
NSString *kExtendSelectionPointerAction = @"kExtendSelectionPointerAction";
 
NSString *kPointerPrefsChangedNotification = @"kPointerPrefsChangedNotification";
typedef enum {
kNoArg,
kEscPlusArg,
Loading
Loading
@@ -109,6 +112,7 @@ typedef enum {
+ (int)tagForGestureIdentifier:(NSString *)ident;
- (BOOL)okShouldBeEnabled;
- (void)editKey:(NSString *)key;
+ (BOOL)keyIsThreeFingerTap:(NSString *)key;
@end
 
@implementation PointerPrefsController
Loading
Loading
@@ -181,6 +185,16 @@ typedef enum {
return [key hasPrefix:kButtonSchema];
}
 
+ (BOOL)keyIsThreeFingerTap:(NSString *)key
{
if (![key hasPrefix:kGestureSchema]) {
return NO;
}
NSArray *components = [PointerPrefsController gestureKeyComponents:key];
NSString *gesture = [components objectAtIndex:1];
return [gesture isEqualToString:kThreeFingerClickGesture];
}
+ (NSArray *)buttonKeyComponents:(NSString *)key
{
// Parse string like "Button,1,2,cso,freeform text"
Loading
Loading
@@ -562,6 +576,8 @@ typedef enum {
+ (void)setSettings:(NSDictionary *)newSettings
{
[[NSUserDefaults standardUserDefaults] setObject:newSettings forKey:kPointerActionsKey];
[[NSNotificationCenter defaultCenter] postNotificationName:kPointerPrefsChangedNotification
object:nil];
}
 
+ (NSArray *)sortedKeys
Loading
Loading
@@ -649,6 +665,16 @@ typedef enum {
return [[[PointerPrefsController settings] objectForKey:key] objectForKey:kArgumentKey];
}
 
+ (BOOL)haveThreeFingerTapEvents
{
for (NSString *key in [PointerPrefsController sortedKeys]) {
if ([PointerPrefsController keyIsThreeFingerTap:key]) {
return YES;
}
}
return NO;
}
#pragma mark NSTableViewDataSource
 
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment