diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index e04dbfa49..fca541090 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -402,9 +402,8 @@ void radioMenuItemPressed(id self, SEL cmd, id sender) { // closeWindow is called when the close button is pressed void closeWindow(id self, SEL cmd, id sender) { - printf("\n\n\ncloseWindow called!!!!\n\n\n"); - // struct Application *app = (struct Application *) objc_getAssociatedObject(self, "application"); - // app->sendMessageToBackend("WC"); + struct Application *app = (struct Application *) objc_getAssociatedObject(self, "application"); + app->sendMessageToBackend("WC"); } bool isDarkMode(struct Application *app) { @@ -985,10 +984,10 @@ void DarkModeEnabled(struct Application *app, const char *callbackID) { void createDelegate(struct Application *app) { // Define delegate - Class delegateClass = objc_allocateClassPair((Class) c("NSResponder"), "AppDelegate", 0); - class_addProtocol(delegateClass, objc_getProtocol("NSTouchBarProvider")); + Class delegateClass = objc_allocateClassPair((Class) c("NSObject"), "AppDelegate", 0); + bool resultAddProtoc = class_addProtocol(delegateClass, objc_getProtocol("NSApplicationDelegate")); class_addMethod(delegateClass, s("applicationShouldTerminateAfterLastWindowClosed:"), (IMP) yes, "c@:@"); - class_addMethod(delegateClass, s("windowWillClose:"), (IMP) closeWindow, "v@:@"); + class_addMethod(delegateClass, s("applicationWillTerminate:"), (IMP) closeWindow, "v@:@"); // Menu Callbacks class_addMethod(delegateClass, s("menuCallback:"), (IMP)menuItemPressed, "v@:@");