diff options
Diffstat (limited to 'macosx/tkMacOSXNotify.c')
-rw-r--r-- | macosx/tkMacOSXNotify.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index fa359f0..f14e1b8 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -7,7 +7,7 @@ * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net> - * Copyright 2015 Marc Culler. + * Copyright 2015 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -25,8 +25,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 +36,12 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); @interface NSApplication(TKNotify) /* We need to declare this hidden method. */ -- (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]; } @@ -50,9 +51,10 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); @implementation TKApplication(TKNotify) /* Display all windows each time an event is removed from the queue.*/ -- (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 +{ NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration inMode:mode @@ -63,10 +65,11 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); return event; } - /* +/* * Call super then check the pasteboard. - */ -- (void)sendEvent:(NSEvent *)theEvent { + */ +- (void) sendEvent: (NSEvent *) theEvent +{ [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; } @@ -128,6 +131,7 @@ void Tk_MacOSXSetupTkNotifier(void) { TSD_INIT(); + if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -177,6 +181,7 @@ TkMacOSXNotifyExitHandler( ClientData clientData) /* Not used. */ { TSD_INIT(); + Tcl_DeleteEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, GetMainEventQueue()); @@ -213,7 +218,7 @@ TkMacOSXEventsSetupProc( NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; /* runloopMode will be nil if we are in the Tcl event loop. */ if (flags & TCL_WINDOW_EVENTS && !runloopMode) { - static Tcl_Time zeroBlockTime = { 0, 0 }; + static const Tcl_Time zeroBlockTime = { 0, 0 }; /* Call this with dequeue=NO -- just checking if the queue is empty. */ NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] @@ -265,10 +270,15 @@ TkMacOSXEventsCheckProc( inMode:GetRunLoopMode(modalSession) dequeue:NO]; /* We must not steal any events during LiveResize. */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (testEvent && [[testEvent window] inLiveResize]) { break; } - +#else + if (testEvent && [[[testEvent window] contentView] inLiveResize]) { + break; + } +#endif currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) |