X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fjwxyz-timers.m;h=6e478f61725b1104be9f66f54bf7761e8d3f0b8f;hb=c70f94f648d51bb4828193124f325fa52b0e57f3;hp=ec6f4394f73ec1d87b3aec925a9d523ffb247d06;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/OSX/jwxyz-timers.m b/OSX/jwxyz-timers.m index ec6f4394..6e478f61 100644 --- a/OSX/jwxyz-timers.m +++ b/OSX/jwxyz-timers.m @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2006 Jamie Zawinski +/* xscreensaver, Copyright (c) 2006-2012 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -12,11 +12,6 @@ /* This is the OSX implementation of Xt timers, for libjwxyz. */ -#import -#import -#import "jwxyz.h" -#import "jwxyz-timers.h" - //#define DEBUG_TIMERS //#define DEBUG_SOURCES @@ -30,6 +25,17 @@ #undef USE_COCOA_SOURCES +#import + +#ifdef USE_COCOA_SOURCES +# import +#endif + +#import "jwxyz.h" +#import "jwxyz-timers.h" + + + #ifdef DEBUG_TIMERS # define LOGT(str,arg1,arg2) NSLog(str,arg1,arg2) #else @@ -80,7 +86,7 @@ jwxyz_timer_retain (const void *arg) { struct jwxyz_XtIntervalId *data = (struct jwxyz_XtIntervalId *) arg; data->refcount++; - LOGT(@"timer 0x%08X: retain %d\n", (unsigned int) data, data->refcount); + LOGT(@"timer 0x%08X: retain %d", (unsigned int) data, data->refcount); return arg; } @@ -89,7 +95,7 @@ jwxyz_timer_release (const void *arg) { struct jwxyz_XtIntervalId *data = (struct jwxyz_XtIntervalId *) arg; data->refcount--; - LOGT(@"timer 0x%08X: release %d\n", (unsigned int) data, data->refcount); + LOGT(@"timer 0x%08X: release %d", (unsigned int) data, data->refcount); if (data->refcount < 0) abort(); if (data->refcount == 0) free (data); } @@ -99,7 +105,7 @@ jwxyz_source_retain (const void *arg) { struct jwxyz_XtInputId *data = (struct jwxyz_XtInputId *) arg; data->refcount++; - LOGI(@"source 0x%08X %2d: retain %d\n", (unsigned int) data, data->fd, + LOGI(@"source 0x%08X %2d: retain %d", (unsigned int) data, data->fd, data->refcount); return arg; } @@ -109,7 +115,7 @@ jwxyz_source_release (const void *arg) { struct jwxyz_XtInputId *data = (struct jwxyz_XtInputId *) arg; data->refcount--; - LOGI(@"source 0x%08X %2d: release %d\n", (unsigned int) data, data->fd, + LOGI(@"source 0x%08X %2d: release %d", (unsigned int) data, data->fd, data->refcount); if (data->refcount < 0) abort(); if (data->refcount == 0) { @@ -130,7 +136,7 @@ static void jwxyz_timer_cb (CFRunLoopTimerRef timer, void *arg) { struct jwxyz_XtIntervalId *data = (struct jwxyz_XtIntervalId *) arg; - LOGT(@"timer 0x%08X: fire\n", (unsigned int) data, 0); + LOGT(@"timer 0x%08X: fire", (unsigned int) data, 0); data->cb (data->closure, &data); // Our caller (__CFRunLoopDoTimer) will now call CFRunLoopTimerInvalidate, @@ -166,11 +172,11 @@ jwxyz_source_cb (CFSocketRef s, CFSocketCallBackType type, // So don't call data->cb if we're being fed a pack of lies. // if (! input_available_p (data->fd)) { - LOGI(@"source 0x%08X %2d: false alarm!\n", (unsigned int) data, data->fd, 0); + LOGI(@"source 0x%08X %2d: false alarm!", (unsigned int) data, data->fd, 0); return; } - LOGI(@"source 0x%08X %2d: fire\n", (unsigned int) data, data->fd, 0); + LOGI(@"source 0x%08X %2d: fire", (unsigned int) data, data->fd, 0); data->cb (data->closure, &data->fd, &data); } @@ -187,7 +193,7 @@ XtAppAddTimeOut (XtAppContext app, unsigned long msecs, data->cb = cb; data->closure = closure; - LOGT(@"timer 0x%08X: alloc %d\n", (unsigned int) data, msecs); + LOGT(@"timer 0x%08X: alloc %d", (unsigned int) data, msecs); CFRunLoopTimerContext ctx = { 0, }; ctx.info = data; @@ -211,7 +217,7 @@ XtAppAddTimeOut (XtAppContext app, unsigned long msecs, void XtRemoveTimeOut (XtIntervalId id) { - LOGT(@"timer 0x%08X: remove\n", (unsigned int) id, 0); + LOGT(@"timer 0x%08X: remove", (unsigned int) id, 0); if (id->refcount <= 0) abort(); if (!id->cftimer) abort(); @@ -309,7 +315,7 @@ XtAppAddInput (XtAppContext app, int fd, XtPointer flags, data->fd = fd; data->closure = closure; - LOGI(@"source 0x%08X %2d: alloc\n", (unsigned int) data, data->fd, 0); + LOGI(@"source 0x%08X %2d: alloc", (unsigned int) data, data->fd, 0); # ifdef USE_COCOA_SOURCES @@ -346,7 +352,7 @@ XtAppAddInput (XtAppContext app, int fd, XtPointer flags, void XtRemoveInput (XtInputId id) { - LOGI(@"source 0x%08X %2d: remove\n", (unsigned int) id, id->fd, 0); + LOGI(@"source 0x%08X %2d: remove", (unsigned int) id, id->fd, 0); if (id->refcount <= 0) abort(); # ifdef USE_COCOA_SOURCES if (! id->cfsource) abort(); @@ -381,3 +387,17 @@ jwxyz_XtRemoveInput_all (Display *dpy) # endif /* !USE_COCOA_SOURCES */ } + + +XtInputMask +XtAppPending (XtAppContext app) +{ + return XtIMAlternateInput; /* just always say yes */ +} + +void +XtAppProcessEvent (XtAppContext app, XtInputMask mask) +{ + jwxyz_sources_data *td = display_sources_data (app_to_display (app)); + jwxyz_sources_run (td); +}