diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AppleEvents.cc | 32 | ||||
-rw-r--r-- | src/AppleEvents.h | 6 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/AppleEvents.cc b/src/AppleEvents.cc new file mode 100644 index 0000000..470c4f3 --- /dev/null +++ b/src/AppleEvents.cc @@ -0,0 +1,32 @@ +#include <Carbon/Carbon.h> +#include <QApplication.h> +#include "MainWindow.h" + +extern "C" { + OSErr eventHandler(const AppleEvent *ev, AppleEvent *reply, SRefCon refcon); +} + +OSErr eventHandler(const AppleEvent *, AppleEvent *, SRefCon ) +{ +// FIXME: Ugly hack; just using the first MainWindow we can find + MainWindow *mainwin = NULL; + foreach (QWidget *w, QApplication::topLevelWidgets()) { + mainwin = qobject_cast<MainWindow*>(w); + if (mainwin) break; + } + if (mainwin) { + mainwin->actionReloadCompile(); + } + return noErr; +} + +void installAppleEventHandlers() +{ + // Reload handler + OSErr err = AEInstallEventHandler('SCAD', 'relo', NewAEEventHandlerUPP(eventHandler), 0, true); + require_noerr(err, CantInstallAppleEventHandler); + return; + +CantInstallAppleEventHandler: + fprintf(stderr, "AEInstallEventHandler() failed: %d\n", err); ; +} diff --git a/src/AppleEvents.h b/src/AppleEvents.h new file mode 100644 index 0000000..9002399 --- /dev/null +++ b/src/AppleEvents.h @@ -0,0 +1,6 @@ +#ifndef APPLEEVENTS_H_ +#define APPLEEVENTS_H_ + +void installAppleEventHandlers(); + +#endif |