Commit e224850a8b59660e158ee3fed48d20902cd0a786

Thomas de Grivel 2023-11-19T01:20:04

grab mouse motion on macos

diff --git a/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m b/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
index 56f1bf0..2f03da0 100644
--- a/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
+++ b/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
@@ -48,7 +48,7 @@
       initWithCairoView:view];
   self.view = view;
   [self.window setContentView:view_controller.view];
-
+  [self.window setAcceptsMouseMovedEvents:YES];
   if (! self.window_cairo->load(self.window_cairo)) {
     [self.window close];
     [self.window release];
diff --git a/libc3/window/cairo/quartz/window_cairo_quartz_view.m b/libc3/window/cairo/quartz/window_cairo_quartz_view.m
index c5cb5fe..7383305 100644
--- a/libc3/window/cairo/quartz/window_cairo_quartz_view.m
+++ b/libc3/window/cairo/quartz/window_cairo_quartz_view.m
@@ -72,6 +72,16 @@
   }
 }
 
+- (void)mouseMoved:(NSEvent *)event {
+  NSPoint p = [event locationInWindow];
+  p.y = self.window_cairo->h - p.y;
+  if (! self.window_cairo->motion(self.window_cairo, p.x, p.y)) {
+    [self.window close];
+    [self.window release];
+    [[NSApplication sharedApplication] stop:nil];
+  }
+}
+
 - (void)rightMouseDown:(NSEvent *)event {
   NSPoint p = [event locationInWindow];
   if (! self.window_cairo->button(self.window_cairo, 2, p.x, p.y)) {