From: Kevin W. <kw...@co...> - 2014-01-18 13:28:14
|
Hi Michiel, On 1/18/14, 7:42 AM, Michiel de Hoon wrote: > 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. > Thank you for bringing this up. Can you clarify the context of your observation? When you mention "an external event loop," what are you referring to? What kinds of problems arise? Windows locking up, glitchy redraw, or something else? Would you be able to provide a patch that implements the cleaner solution you are suggesting? I'd be very interested to see a bit more of your thinking; I am wondering if this might solve some of the long-standing issues with the event loop in Tk Cocoa. Although I'm the current maintainer of Tk on the Mac, I'm not familiar with all the design decisions that went into the Cocoa port and so I'm not sure why it was set up this way. Thanks, Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |