diff options
Diffstat (limited to 'src/carbon.c')
-rw-r--r-- | src/carbon.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/carbon.c b/src/carbon.c index 98e2793..9af606a 100644 --- a/src/carbon.c +++ b/src/carbon.c @@ -1,17 +1,10 @@ -#include <Carbon/Carbon.h> +#include "carbon.h" -struct carbon_event -{ - EventTargetRef target; - EventHandlerUPP handler; - EventTypeSpec type; - EventHandlerRef handler_ref; - char * volatile process_name; -}; +#define internal static #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated" -static OSStatus +internal OSStatus carbon_event_handler(EventHandlerCallRef ref, EventRef event, void *context) { struct carbon_event *carbon = (struct carbon_event *) context; @@ -29,9 +22,12 @@ carbon_event_handler(EventHandlerCallRef ref, EventRef event, void *context) CFStringRef process_name_ref; if (CopyProcessName(&psn, &process_name_ref) == noErr) { - if (carbon->process_name) free(carbon->process_name); + if (carbon->process_name) { + free(carbon->process_name); + carbon->process_name = NULL; + } + carbon->process_name = copy_cfstring(process_name_ref); - printf("front app changed: %s\n", carbon->process_name); CFRelease(process_name_ref); } |