Skip to content

Commit

Permalink
allow dependents to turn on debugging, and make "close on window clos…
Browse files Browse the repository at this point in the history
…e" match isAccessory
  • Loading branch information
jaredly committed Feb 5, 2019
1 parent 0b3d85f commit ebad30a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
5 changes: 2 additions & 3 deletions esy.json
@@ -1,8 +1,7 @@
{
"name": "fluid",
"esy": {
"build": "dune build -p #{self.name}",
"buildsInSource": true
"build": "dune build -p #{self.name}"
},
"dependencies": {
"ocaml": ">=4.7.0",
Expand All @@ -14,4 +13,4 @@
"flex": "jaredly/flex#esy",
"RexJson": "jaredly/rex-json#esy"
}
}
}
4 changes: 3 additions & 1 deletion src/core/FluidMaker.re
Expand Up @@ -308,7 +308,9 @@ let runRender = (WithState(component)) => {
Good((tree, effects^));
} {
| SuspendException(evt) => Suspense([evt])
| exn => Bad(exn)
| exn =>
print_endline("Error rending component: " ++ Printexc.to_string(exn));
Bad(exn)
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/native/FluidMac.re
Expand Up @@ -354,7 +354,7 @@ module NativeInterface = {
~dims={left, top, width, height});
(native, getNativeId())
| View(onPress, style) =>
Printf.printf("OCaml side %f,%f %f x %f\n", top, left, width, height);
/* Printf.printf("OCaml side %f,%f %f x %f\n", top, left, width, height); */
let native = createView(~onPress, ~pos=(top, left), ~size=(width, height), ~style);
(native, getNativeId())
| Button(title, onPress) =>
Expand Down
9 changes: 8 additions & 1 deletion src/native/dune
@@ -1,11 +1,18 @@
(* -*- tuareg -*- *)

let flags = match (Sys.getenv "FLUID_DEBUG") with
| exception Not_found -> ""
| _ -> " -DDEBUG"

let () = Jbuild_plugin.V1.send (Printf.sprintf {|
(library
(public_name fluid.MacOS)
(name FluidMac)
(libraries flex belt FluidMaker Layout Files)
(c_names fluid fluid_components fluid_window fluid_shared fluid_hotkeys)
(install_c_headers fluid_shared)
; NOTE(jared): whenever making changes, remove this `-w` arg, which suppresses all warnings
(c_flags -x objective-c -w)
(c_flags -x objective-c -w%s)
(no_dynlink)
(preprocess (pps belt.ppx)))
|} flags)
5 changes: 4 additions & 1 deletion src/native/fluid.c
Expand Up @@ -13,6 +13,7 @@
@end

@interface MLApplicationDelegate : NSObject <NSApplicationDelegate>
@property BOOL shouldLiveOn;
@end

@implementation MLApplicationDelegate {
Expand All @@ -27,7 +28,7 @@
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification {
return NO;
return !self.shouldLiveOn;
}

- (void)applicationDidFinishLaunching:(NSNotification *)__unused not {
Expand Down Expand Up @@ -207,6 +208,7 @@ void fluid_App_launch (value isAccessory, value callback)
[NSApplication sharedApplication];

MLApplicationDelegate* delegate = [[MLApplicationDelegate alloc] initWithOnLaunch:callback];
delegate.shouldLiveOn = isAccessory == Val_true;

if (isAccessory == Val_true) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
Expand Down Expand Up @@ -293,6 +295,7 @@ void fluid_App_setStatusBarItemTitle(value item_v, value title_v) {
} else {
item.button.image = (NSImage*)Unwrap(Field(title_v, 0));
}
CAMLreturn0;
}

CAMLprim value fluid_App_statusBarItem(value title_v, value onClick_v, value isVariableLength) {
Expand Down

0 comments on commit ebad30a

Please sign in to comment.