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

Make right mouse button configurable.

parent 5cac76b9
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Button,1,1,,</key>
<dict>
<key>Action</key>
<string>kContextMenuPointerAction</string>
</dict>
<key>Button,2,1,,</key>
<dict>
<key>Action</key>
Loading
Loading
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Loading
Loading
@@ -48,7 +48,11 @@
 
- (void)rightMouseUp:(NSEvent *)theEvent
{
[self showNotSupported];
int buttonNumber = 1;
int clickCount = [theEvent clickCount];
int modMask = [theEvent modifierFlags];
[pointerPrefs_ setButtonNumber:buttonNumber clickCount:clickCount modifiers:modMask];
[super mouseDown:theEvent];
}
 
- (void)otherMouseDown:(NSEvent *)theEvent
Loading
Loading
Loading
Loading
@@ -2361,6 +2361,9 @@ NSMutableArray* screens=0;
 
- (void)rightMouseDown:(NSEvent*)event
{
if ([pointer_ mouseDown:event withTouches:numTouches_]) {
return;
}
NSPoint locationInWindow, locationInTextView;
locationInWindow = [event locationInWindow];
locationInTextView = [self convertPoint: locationInWindow fromView: nil];
Loading
Loading
@@ -2399,6 +2402,9 @@ NSMutableArray* screens=0;
 
- (void)rightMouseUp:(NSEvent *)event
{
if ([pointer_ mouseUp:event withTouches:numTouches_]) {
return;
}
NSPoint locationInWindow, locationInTextView;
locationInWindow = [event locationInWindow];
locationInTextView = [self convertPoint: locationInWindow fromView: nil];
Loading
Loading
@@ -2687,6 +2693,10 @@ NSMutableArray* screens=0;
}
return NO;
}
if ([pointer_ eventEmulatesRightClick:event]) {
[pointer_ mouseDown:event withTouches:numTouches_];
return NO;
}
const BOOL altPressed = ([event modifierFlags] & NSAlternateKeyMask) != 0;
const BOOL cmdPressed = ([event modifierFlags] & NSCommandKeyMask) != 0;
const BOOL shiftPressed = ([event modifierFlags] & NSShiftKeyMask) != 0;
Loading
Loading
@@ -2920,6 +2930,10 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
dragOk_ = NO;
trouterDragged = NO;
if ([pointer_ eventEmulatesRightClick:event]) {
[pointer_ mouseUp:event withTouches:numTouches_];
return;
}
PTYTextView* frontTextView = [[iTermController sharedInstance] frontTextView];
const BOOL cmdPressed = ([event modifierFlags] & NSCommandKeyMask) != 0;
if (!cmdPressed &&
Loading
Loading
@@ -3656,26 +3670,8 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
if (theEvent) {
// Not for "synthetic" events, as the session title view sends.
PTYTextView* frontTextView = [[iTermController sharedInstance] frontTextView];
NSRect visibleRect = [[self enclosingScrollView] documentVisibleRect];
NSPoint locationInWindow = [theEvent locationInWindow];
NSPoint locationInTextView = [self convertPoint:locationInWindow fromView:nil];
VT100Terminal *terminal = [dataSource terminal];
MouseMode mm = [terminal mouseMode];
if (frontTextView == self &&
([self xtermMouseReporting]) &&
(mm == MOUSE_REPORTING_NORMAL ||
mm == MOUSE_REPORTING_BUTTON_MOTION ||
mm == MOUSE_REPORTING_ALL_MOTION) &&
(locationInTextView.y > visibleRect.origin.y) &&
[[frontTextView->dataSource session] tab] == [[dataSource session] tab] &&
[theEvent type] == NSLeftMouseDown &&
([theEvent modifierFlags] & NSControlKeyMask) &&
[[PreferencePanel sharedInstance] passOnControlLeftClick]) {
// All the many conditions are met for having the click passed on via xterm mouse reporting.
return nil;
}
// Context menu is opened by the PointerController, not organically.
return nil;
}
NSMenu *theMenu;
 
Loading
Loading
Loading
Loading
@@ -44,8 +44,9 @@
 
@property (nonatomic, assign) NSObject<PointerControllerDelegate> *delegate;
 
- (void)mouseDown:(NSEvent *)event withTouches:(int)numTouches;
- (void)mouseUp:(NSEvent *)event withTouches:(int)numTouches;
- (BOOL)mouseDown:(NSEvent *)event withTouches:(int)numTouches;
- (BOOL)mouseUp:(NSEvent *)event withTouches:(int)numTouches;
- (void)swipeWithEvent:(NSEvent *)event;
- (BOOL)eventEmulatesRightClick:(NSEvent *)event;
 
@end
Loading
Loading
@@ -8,6 +8,7 @@
 
#import "PointerController.h"
#import "PointerPrefsController.h"
#import "PreferencePanel.h"
 
@implementation PointerController
 
Loading
Loading
@@ -66,30 +67,63 @@
}
}
 
- (void)mouseDown:(NSEvent *)event withTouches:(int)numTouches
- (BOOL)eventEmulatesRightClick:(NSEvent *)event
{
mouseDownButton_ = [event buttonNumber];
return ![[PreferencePanel sharedInstance] passOnControlLeftClick] &&
[event buttonNumber] == 0 &&
[event clickCount] == 1 &&
([event modifierFlags] & (NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask)) == NSControlKeyMask;
}
 
- (void)mouseUp:(NSEvent *)event withTouches:(int)numTouches
- (NSString *)actionForEvent:(NSEvent *)event withTouches:(int)numTouches
{
NSString *action = nil;
NSString *argument = nil;
if ([self eventEmulatesRightClick:event]) {
// Ctrl-click emulates right button
return [PointerPrefsController actionWithButton:1 numClicks:1 modifiers:0];
}
if (numTouches <= 2) {
return [PointerPrefsController actionWithButton:[event buttonNumber]
numClicks:[event clickCount]
modifiers:[event modifierFlags]];
} else {
return [PointerPrefsController actionForTapWithTouches:numTouches
modifiers:[event modifierFlags]];
}
}
- (NSString *)argumentForEvent:(NSEvent *)event withTouches:(int)numTouches
{
if ([self eventEmulatesRightClick:event]) {
// Ctrl-click emulates right button
return [PointerPrefsController argumentWithButton:1
numClicks:1
modifiers:0];
}
if (numTouches <= 2) {
action = [PointerPrefsController actionWithButton:[event buttonNumber]
return [PointerPrefsController argumentWithButton:[event buttonNumber]
numClicks:[event clickCount]
modifiers:[event modifierFlags]];
argument = [PointerPrefsController argumentWithButton:[event buttonNumber]
numClicks:[event clickCount]
modifiers:[event modifierFlags]];
} else {
action = [PointerPrefsController actionForTapWithTouches:numTouches
return [PointerPrefsController argumentForTapWithTouches:numTouches
modifiers:[event modifierFlags]];
argument = [PointerPrefsController argumentForTapWithTouches:numTouches
modifiers:[event modifierFlags]];
}
}
- (BOOL)mouseDown:(NSEvent *)event withTouches:(int)numTouches
{
mouseDownButton_ = [event buttonNumber];
return [self actionForEvent:event withTouches:numTouches] != nil;
}
- (BOOL)mouseUp:(NSEvent *)event withTouches:(int)numTouches
{
NSString *argument = [self argumentForEvent:event withTouches:numTouches];
NSString *action = [self actionForEvent:event withTouches:numTouches];
if (action) {
[self performAction:action forEvent:event withArgument:argument];
return YES;
} else {
return NO;
}
}
 
Loading
Loading
Loading
Loading
@@ -680,7 +680,7 @@ typedef enum {
 
- (void)setButtonNumber:(int)buttonNumber clickCount:(int)clickCount modifiers:(int)modMask
{
if (buttonNumber >= 2 && clickCount > 0 && clickCount < 5) {
if (buttonNumber >= 1 && clickCount > 0 && clickCount < 5) {
[editButton_ selectItemWithTag:buttonNumber];
[editClickType_ selectItemWithTag:clickCount];
[self setModifierButtons:modMask];
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