From: Michiel de H. <mjl...@ya...> - 2014-09-26 14:38:14
|
Hi Kevin, Typically in Cocoa the event loop looks something like this: while (true) { NSEvent* event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: date inMode: NSDefaultRunLoopMode dequeue: YES]; [NSApp sendEvent: event]; } This event loop waits for events and dispatches them, but does not actually process them; processing the events should be done in the callbacks. Usually you would want to keep the event loop as simple as possible. Instead, in tkMacOSXNotify.c nextEventMatchingMask is overridden (which is an odd thing to do in itself) and now calls [NSApp tkProcessEvent:event], thereby processing the event in the event loop rather than in the callback. You will also see in tkMacOSXNotify.c that sendEvent is also being overridden to keep track of its nesting level, and that [NSApp tkProcessEvent:currentEvent] is being called in TkMacOSXEventsCheckProc, thereby again processing an event in the event loop rather than in the callback. The end result is a very complex event loop, which is likely to be fragile. I would suggest to move the code in tkProcessEvent to the appropriate callback functions, and after that see how much of the complexity of tkMacOSXNotify.c is still needed. > My understanding is that this is mainly a hook into tclMacOSXNotifier.c, which is quite complex. Yes. Therefore I think that tclMacOSXNotifier.c should be fixed first, before touching tkMacOSXNotifier.c Best, -Michiel -------------------------------------------- On Thu, 9/25/14, Kevin Walzer <kw...@co...> wrote: Subject: Re: [TCLCORE] Commits to improve drawing in Tk-Cocoa after removal of private API's To: "Michiel de Hoon" <mjl...@ya...>, "tc...@li... List" <tc...@li...>, "Tcl Core List" <tcl...@li...> Date: Thursday, September 25, 2014, 11:38 PM On 9/25/14, 10:21 AM, Michiel de Hoon wrote: > The only changes would be needed in tclMacOSXNotify.c and in tkMacOSX*.c (mainly tkMacOSXNotify.c). > Regarding threading: I think we agree there. I am suggesting to use the event loop instead of a thread to monitor file descriptor events. I'd be interested to hear your suggestions for tkMaCOSXNotify.c. My understanding is that this is mainly a hook into tclMacOSXNotifier.c, which is quite complex. Anything involving threading is currently outside my skill set, so I will defer to those more expert than myself on this. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |