Commit c83495d977af2d1bfb7eb792e0ddd285ed1ed443

Thomas de Grivel 2023-11-23T16:54:54

window cairo quartz demo

diff --git a/libc3/window/cairo/c3_window_cairo_demo.c b/libc3/window/cairo/c3_window_cairo_demo.c
index 732857b..32a81b8 100644
--- a/libc3/window/cairo/c3_window_cairo_demo.c
+++ b/libc3/window/cairo/c3_window_cairo_demo.c
@@ -193,8 +193,7 @@ static void star_render (s_tag *star, s_window_cairo *window,
   q = (1 + *speed / 10);
   cairo_line_to(cr, *x * q, *y * q);
   cairo_stroke(cr);
-  q = (1 + *speed / 1000);
-  printf("%%{speed: %f, x: %f, y: %f}\n", *speed, *x, *y); 
+  q = (1 + *speed / 100);
   *x = *x * q;
   *y = *y * q;
   *speed += seq->dt;
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 2f03da0..0314a3f 100644
--- a/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
+++ b/libc3/window/cairo/quartz/window_cairo_quartz_app_delegate.m
@@ -34,7 +34,7 @@
                                        NSWindowStyleMaskResizable)
                               backing:NSBackingStoreBuffered
                                 defer:NO];
-  self.window.delegate = self;
+  [self.window setDelegate:self];
   [self.window makeKeyAndOrderFront:nil];
   [self.window
       setTitle:[NSString
@@ -66,6 +66,18 @@
   [self.view setNeedsDisplay:YES];
 }
 
+- (void)windowDidResize:(NSNotification *)notification {
+  printf("windowDidResize\n");
+  NSWindow *window = (NSWindow *)notification.object;
+  NSSize size = window.frame.size;
+  [self.view setFrameSize:size];
+  if (! self.window_cairo->resize(self.window_cairo, (uw) size.width,
+                                  size.height))
+    [NSApp stop:nil];
+  self.window_cairo->w = size.width;
+  self.window_cairo->h = size.height;
+}
+
 - (void)windowWillClose:(NSNotification *)notification {
   [NSApp stop:nil];
 }
diff --git a/libc3/window/cairo/window_cairo.c b/libc3/window/cairo/window_cairo.c
index ca9d276..4e7a3a0 100644
--- a/libc3/window/cairo/window_cairo.c
+++ b/libc3/window/cairo/window_cairo.c
@@ -74,7 +74,11 @@ bool window_cairo_motion_default (s_window_cairo *window, sw x, sw y)
 {
   assert(window);
   (void) window;
+  (void) x;
+  (void) y;
+  /*
   printf("window_cairo_motion_default (%ld, %ld)\n", x, y);
+  */
   return true;
 }