Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't do trackpad gestures on anything except the toplevel window
  • Loading branch information
tomsci committed Aug 20, 2021
commit cff26175041e213b5b509bc15c5ac1a998d13295
26 changes: 15 additions & 11 deletions src/platform/guimac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,20 @@ @implementation SSView
double rotationGestureCurrent;
Point2d trackpadPositionShift;
bool inTrackpadScrollGesture;
Platform::Window::Kind kind;
}

@synthesize acceptsFirstResponder;

- (id)initWithFrame:(NSRect)frameRect {
- (id)initWithKind:(Platform::Window::Kind)aKind {
NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFADepthSize, 24,
0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
if(self = [super initWithFrame:frameRect pixelFormat:pixelFormat]) {
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0) pixelFormat:pixelFormat]) {
self.wantsBestResolutionOpenGLSurface = YES;
self.wantsLayer = YES;
editor = [[NSTextField alloc] init];
Expand All @@ -394,13 +395,16 @@ - (id)initWithFrame:(NSRect)frameRect {
editor.action = @selector(didEdit:);

inTrackpadScrollGesture = false;
NSGestureRecognizer *mag = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self
action:@selector(magnifyGesture:)];
[self addGestureRecognizer:mag];

NSRotationGestureRecognizer* rot = [[NSRotationGestureRecognizer alloc] initWithTarget:self
action:@selector(rotateGesture:)];
[self addGestureRecognizer:rot];
kind = aKind;
if(kind == Platform::Window::Kind::TOPLEVEL) {
NSGestureRecognizer *mag = [[NSMagnificationGestureRecognizer alloc] initWithTarget:self
action:@selector(magnifyGesture:)];
[self addGestureRecognizer:mag];

NSRotationGestureRecognizer* rot = [[NSRotationGestureRecognizer alloc] initWithTarget:self
action:@selector(rotateGesture:)];
[self addGestureRecognizer:rot];
}
}
return self;
}
Expand Down Expand Up @@ -567,7 +571,7 @@ - (void)scrollWheel:(NSEvent *)nsEvent {
using Platform::MouseEvent;

MouseEvent event = [self convertMouseEvent:nsEvent];
if(nsEvent.subtype == NSEventSubtypeTabletPoint) {
if(nsEvent.subtype == NSEventSubtypeTabletPoint && kind == Platform::Window::Kind::TOPLEVEL) {
// This is how Cocoa represents 2 finger trackpad drag gestures, rather than going via
// NSPanGestureRecognizer which is how you might expect this to work... We complicate this
// further by also handling shift-two-finger-drag to mean rotate. Fortunately we're using
Expand Down Expand Up @@ -867,7 +871,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification {
NSString *nsToolTip;

WindowImplCocoa(Window::Kind kind, std::shared_ptr<WindowImplCocoa> parentWindow) {
ssView = [[SSView alloc] init];
ssView = [[SSView alloc] initWithKind:kind];
ssView.translatesAutoresizingMaskIntoConstraints = NO;
ssView.receiver = this;

Expand Down