revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

feat(native): add initial tray-support for macOS #972

Open lessp opened 4 years ago

lessp commented 4 years ago

This adds tray-support for macOS like so:

Native.Tray.make(~title=`Image("absolute/path/to/image.png"), ());
Native.Tray.make(~title=`Text("SomeTitle"), ());

image

Begins to address #322

github-actions[bot] commented 4 years ago

I have updated your lock dirs and formatted the code. Please @lessp pull the last commit before pushing any more changes.

lessp commented 4 years ago

Not sure how we'd like to separate things going forward without naked pointers. I guess we could keep a similar structure but we'd need to import the ocaml-ffi-helpers in foo_cocoa.h as well?

Currently src/Native/tray_cocoa.c is unused and I dumped all of that into tray.c

cc @zbaylin

cdaringe commented 3 years ago

I can't wait to try this! Is it on pause indefinitely or just delayed?

lessp commented 3 years ago

I can't wait to try this! Is it on pause indefinitely or just delayed?

hey @cdaringe, currently (unfortunately) I have extremely limited free-time for OSS, so if anyone wants to take this further feel free. 🙂

lessp commented 3 years ago

Merged with master and moved the examples to a separate file, I believe what's left here is:

lessp commented 3 years ago

Hey Zach, I believe this covers the first minimal surface area, albeit for macOS only:

The API surface is fairly large, so we should start by thinking of a minimal subset - perhaps addressing the following scenarios:

Create a tray icon Destroy a tray icon

Very possible that I might have missed something!

lessp commented 3 years ago

Hey @lessp -- so happy to finally see this getting in! I had some minor comments (mostly just rebasing with new APIs like the revery_wrapPointer). I also wonder if it's possible to hook into the NSMenu stuff here too. Maybe that should be a separate PR, though.

Thanks for the review Zach, feels like I left quite a bit for you there! 😄

I also wonder if it's possible to hook into the NSMenu stuff here too. Maybe that should be a separate PR, though.

Yeah, that would have to be up for grabs, just thought I'd try to get this in!