From 3a0583564b8109ec563e8de7cd4099d122b32fc7 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 17 May 2021 10:45:16 +0200 Subject: [PATCH] app/internal/wm: [macOS] avoid NSView.isFlipped When using Gio with ANGLE, the isFlipped coordinate system flip will apply to rendering as well. Fortunately we're no longer using NSOpenGLView so isFlipped only applies to mouse events. Convert them manually to avoid isFlipped and support ANGLE. Signed-off-by: Elias Naur --- app/internal/wm/os_macos.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/internal/wm/os_macos.m b/app/internal/wm/os_macos.m index 89053fe6..649a6a4f 100644 --- a/app/internal/wm/os_macos.m +++ b/app/internal/wm/os_macos.m @@ -49,16 +49,15 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo dx *= 10; dy *= 10; } - gio_onMouse((__bridge CFTypeRef)view, typ, [NSEvent pressedMouseButtons], p.x, p.y, dx, dy, [event timestamp], [event modifierFlags]); + // Origin is in the lower left corner. Convert to upper left. + CGFloat height = view.bounds.size.height; + gio_onMouse((__bridge CFTypeRef)view, typ, [NSEvent pressedMouseButtons], p.x, height - p.y, dx, dy, [event timestamp], [event modifierFlags]); } @interface GioView : NSView @end @implementation GioView -- (BOOL)isFlipped { - return YES; -} - (void)drawRect:(NSRect)r { gio_onDraw((__bridge CFTypeRef)self); }