From: Michiel de H. <mjl...@ya...> - 2014-01-18 12:42:47
|
Hi all, In tkMacOSXNotify.c I came across a piece of code that seems unnecessary and causes a complication when using an external event loop. In the nextEventMatchingMask method: @implementation TKApplication(TKNotify) - (NSEvent *) nextEventMatchingMask: (NSUInteger) mask untilDate: (NSDate *) expiration inMode: (NSString *) mode dequeue: (BOOL) deqFlag { NSAutoreleasePool *pool = [NSAutoreleasePool new]; [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO]; ... } the tkDisplayIfNeeded method is applied to all windows each time there is an event. The tkDisplayIfNeeded method is the following: @implementation NSWindow(TKNotify) - (id) tkDisplayIfNeeded { if (![self isAutodisplay]) { [self displayIfNeeded]; } return nil; } @end In the code creating the window (TkMacOSXMakeRealWindowExist in tkMacOSXWm.c), we call [window setAutodisplay:NO], so [self isAutodisplay] is false, and tkDisplayIfNeeded calls [self displayIfNeeded]. Why is this code needed? The Cocoa documentation seems to discourage the use of [NSWindow displayIfNeeded], and setting [window setAutodisplay:YES] seems to work perfectly fine without having to call tkDisplayIfNeeded. I looked at the history of tkMacOSXNotify.c and it seems that this piece of code was introduced when the TkAqua Cocoa port was merged into Tk. However the logs don't explain the purpose of tkDisplayIfNeeded. Thanks, -Michiel. |