diff options
Diffstat (limited to 'macosx/tkMacOSXNotify.c')
-rw-r--r-- | macosx/tkMacOSXNotify.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 2274a31..3e0dfde 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -10,8 +10,6 @@ * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id$ */ #include "tkMacOSXPrivate.h" @@ -26,8 +24,8 @@ typedef struct ThreadSpecificData { } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; -#define TSD_INIT() ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, \ - sizeof(ThreadSpecificData)) +#define TSD_INIT() ThreadSpecificData *tsdPtr = \ + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)) static void TkMacOSXNotifyExitHandler(ClientData clientData); static void TkMacOSXEventsSetupProc(ClientData clientData, int flags); @@ -36,11 +34,12 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); #pragma mark TKApplication(TKNotify) @interface NSApplication(TKNotify) -- (void)_modalSession:(NSModalSession)session sendEvent:(NSEvent *)event; +- (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event; @end @implementation NSWindow(TKNotify) -- (id)tkDisplayIfNeeded { +- (id) tkDisplayIfNeeded +{ if (![self isAutodisplay]) { [self displayIfNeeded]; } @@ -49,14 +48,18 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); @end @implementation TKApplication(TKNotify) -- (NSEvent *)nextEventMatchingMask:(NSUInteger)mask - untilDate:(NSDate *)expiration inMode:(NSString *)mode - dequeue:(BOOL)deqFlag { +- (NSEvent *) nextEventMatchingMask: (NSUInteger) mask + untilDate: (NSDate *) expiration inMode: (NSString *) mode + dequeue: (BOOL) deqFlag +{ NSAutoreleasePool *pool = [NSAutoreleasePool new]; + [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO]; + int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *event = [[super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:deqFlag] retain]; + Tcl_SetServiceMode(oldMode); if (event) { TSD_INIT(); @@ -70,9 +73,12 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); [pool drain]; return [event autorelease]; } -- (void)sendEvent:(NSEvent *)theEvent { + +- (void) sendEvent: (NSEvent *) theEvent +{ TSD_INIT(); int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); + tsdPtr->sendEventNestingLevel++; [super sendEvent:theEvent]; tsdPtr->sendEventNestingLevel--; @@ -137,6 +143,7 @@ void Tk_MacOSXSetupTkNotifier(void) { TSD_INIT(); + if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -185,6 +192,7 @@ TkMacOSXNotifyExitHandler( ClientData clientData) /* Not used. */ { TSD_INIT(); + Tcl_DeleteEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, GetMainEventQueue()); tsdPtr->initialized = 0; @@ -216,14 +224,15 @@ TkMacOSXEventsSetupProc( { if (flags & TCL_WINDOW_EVENTS && ![[NSRunLoop currentRunLoop] currentMode]) { - static Tcl_Time zeroBlockTime = { 0, 0 }; - + static const Tcl_Time zeroBlockTime = { 0, 0 }; TSD_INIT(); + if (!tsdPtr->currentEvent) { NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:YES]; + if (currentEvent) { tsdPtr->currentEvent = TkMacOSXMakeUncollectableAndRetain(currentEvent); @@ -265,7 +274,7 @@ TkMacOSXEventsCheckProc( TSD_INIT(); if (tsdPtr->currentEvent) { currentEvent = TkMacOSXMakeCollectableAndAutorelease( - tsdPtr->currentEvent); + tsdPtr->currentEvent); } do { modalSession = TkMacOSXGetModalSession(); @@ -306,7 +315,7 @@ TkMacOSXEventsCheckProc( /* * Local Variables: - * mode: c + * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 |