summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXNotify.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXNotify.c')
-rw-r--r--macosx/tkMacOSXNotify.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index 4cfb5a9..1d4c6c5 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)
/* Call super then redisplay all of our windows. */
-- (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
+{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[super sendEvent:theEvent];
[NSApp tkCheckPasteboard];
@@ -130,6 +133,7 @@ void
Tk_MacOSXSetupTkNotifier(void)
{
TSD_INIT();
+
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
@@ -179,6 +183,7 @@ TkMacOSXNotifyExitHandler(
ClientData clientData) /* Not used. */
{
TSD_INIT();
+
Tcl_DeleteEventSource(TkMacOSXEventsSetupProc,
TkMacOSXEventsCheckProc,
GetMainEventQueue());
@@ -191,7 +196,7 @@ TkMacOSXNotifyExitHandler(
* TkMacOSXEventsSetupProc --
*
* This procedure implements the setup part of the MacOSX event
- * source. It is invoked by Tcl_DoOneEvent before calling
+ * source. It is invoked by Tcl_DoOneEvent before calling
* TkMacOSXEventsProc to process all queued NSEvents. In our
* case, all we need to do is to set the Tcl MaxBlockTime to
* 0 before starting the loop to process all queued NSEvents.
@@ -200,7 +205,7 @@ TkMacOSXNotifyExitHandler(
* None.
*
* Side effects:
- *
+ *
* If NSEvents are queued, then the maximum block time will be set
* to 0 to ensure that control returns immediately to Tcl.
*
@@ -213,13 +218,14 @@ TkMacOSXEventsSetupProc(
int flags)
{
if (flags & TCL_WINDOW_EVENTS &&
- ![[NSRunLoop currentRunLoop] currentMode]) {
- static Tcl_Time zeroBlockTime = { 0, 0 };
- /* Call this with dequeue=NO -- just checking if the queue is empty. */
+ ![[NSRunLoop currentRunLoop] currentMode]) {
+ 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]
- inMode:GetRunLoopMode(TkMacOSXGetModalSession())
- dequeue:NO];
+ untilDate:[NSDate distantPast]
+ inMode:GetRunLoopMode(TkMacOSXGetModalSession())
+ dequeue:NO];
if (currentEvent && currentEvent.type > 0) {
Tcl_SetMaxBlockTime(&zeroBlockTime);
}