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. |
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 |
From: Michiel de H. <mjl...@ya...> - 2014-01-18 14:06:01
|
Hi Kevin. > Can you clarify the context of your observation? When you > mention "an external event loop," what are you referring to? I am using Tcl/Tk from Python, so Python is running the event loop, and Tcl/Tk hooks into it using the notifier approach as described e.g. here: http://www.tcl.tk/man/tcl8.5/TclLib/Notifier.htm > What kinds of problems arise? The external event loop handles both windows created by Tcl/Tk, and windows created independently of Tcl/Tk. This external event loop is similar to the one in Tcl/Tk, using [self nextEventMatchingMask:...] just like Tcl/Tk. The windows created by Tcl/Tk need the call to tkDisplayIfNeeded before each event; the windows created independently of Tcl/Tk don't need that. I cannot use [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO], because the Tcl/Tk-independent windows obviously don't have the tkDisplayIfNeeded method. Instead I would have to get a list of windows, check if they can handle tkDisplayIfNeeded, and if so, apply tkDisplayIfNeeded to them. This would have to be done before each and every event, slowing down the code and making it rather complex. > Would you be able to provide a patch that implements the > cleaner solution you are suggesting? That is simple: remove tkDisplayIfNeeded and the call to it from tkMacOSXNotify.c, and remove the line [window setAutodisplay:NO] from kMacOSXWm.c. If any glitches show up when we do that, we can think again what is the best solution for it. > 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. I have some experience with a Cocoa event loop (with Python though, but I guess the issues are the same), so I may be able to help. Best, -Michiel. |
From: Kevin W. <kw...@co...> - 2014-01-18 17:52:35
|
On 1/18/14, 9:05 AM, Michiel de Hoon wrote: > > That is simple: remove tkDisplayIfNeeded and the call to it from tkMacOSXNotify.c, and remove the line [window setAutodisplay:NO] from kMacOSXWm.c. > If any glitches show up when we do that, we can think again what is the best solution for it. > Just bringing some off-list discussion back to onto the list, it appears that the [window setAutodisplay:NO] line is needed to address some issues with drawing Tk windows under Cocoa, though the details are no longer readily available. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Michiel de H. <mjl...@ya...> - 2014-01-21 10:10:09
|
Hi all, I have summarized this discussion and provided a patch at https://core.tcl.tk/tcl/tktview?name=883155fb98 This patch removes the [window setAutodisplay:NO] line and the tkDisplayIfNeeded code. I tried this patch with the Tk test suite and found that it reduces the number of test failures by 1. Best, -Michiel. -------------------------------------------- On Sat, 1/18/14, Kevin Walzer <kw...@co...> wrote: Subject: Re: [MACTCL] What is the purpose of tkDisplayIfNeeded? To: "Michiel de Hoon" <mjl...@ya...>, tc...@li... Date: Saturday, January 18, 2014, 12:52 PM On 1/18/14, 9:05 AM, Michiel de Hoon wrote: > > That is simple: remove tkDisplayIfNeeded and the call to it from tkMacOSXNotify.c, and remove the line [window setAutodisplay:NO] from kMacOSXWm.c. > If any glitches show up when we do that, we can think again what is the best solution for it. > Just bringing some off-list discussion back to onto the list, it appears that the [window setAutodisplay:NO] line is needed to address some issues with drawing Tk windows under Cocoa, though the details are no longer readily available. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Kevin W. <kw...@co...> - 2014-01-24 16:10:05
|
Hi Michiel, On 1/21/14, 5:10 AM, Michiel de Hoon wrote: > Hi all, > > I have summarized this discussion and provided a patch at > https://core.tcl.tk/tcl/tktview?name=883155fb98 > > This patch removes the [window setAutodisplay:NO] line and the tkDisplayIfNeeded code. > I tried this patch with the Tk test suite and found that it reduces the number of test failures by 1. > > Best, > -Michiel. > I've applied this patch, and it doesn't appear to cause any side effects, but I'm still not 100% clear on what problem it solves in terms of Tcl/Tk itself. When you mention that Python is driving your event loop, what's the context? How do you make use of Tcl/Tk in your app? Can you point me to a place where I can download the app and understand it a bit better? --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Michiel de H. <mjl...@ya...> - 2014-01-25 11:14:03
|
Hi Kevin, On Fri, 1/24/14, Kevin Walzer <kw...@co...> wrote: > When you mention that Python is driving your event loop, > what's the context? > How do you make use of Tcl/Tk in your app? > Can you point me to a place where I can download the > app and understand it a bit better? Originally I was writing an extension module to Python to embed Tcl/Tk (for the GUI) into Python using the notifier approach as described in the Tcl/Tk documentation: http://www.tcl.tk/man/tcl8.4/TclLib/Notifier.htm#M12 Then I noticed several issues with the current Tk notifier in macosx/tkMacOSXNotify.c that would need to be resolved first. For example, some pieces of the event loop don't seem to be functional, and currently the event loop leaks memory. These issues occur also with Tcl/Tk itself (irrespective of Python), so now I am using a minimal Tcl/Tk script and running it with Wish to check if the Tcl/Tk event loop is working properly. I have written some small patches for the problems I noticed; hopefully this will also contribute to making the Tcl/Tk event loop more robust. Once the Tcl/Tk event loop is cleaned up, I'll go back and try to run the event loop from Python. Best, -Michiel. |
From: Kevin W. <kw...@co...> - 2014-01-27 02:52:12
|
Michiel, On 1/25/14, 6:13 AM, Michiel de Hoon wrote: > > These issues occur also with Tcl/Tk itself (irrespective of Python), > so now I am using a minimal Tcl/Tk script and running it with > Wish to check if the Tcl/Tk event loop is working properly. I have > written some small patches for the problems I noticed; hopefully > this will also contribute to making the Tcl/Tk event loop more robust. > > Once the Tcl/Tk event loop is cleaned up, I'll go back and try to > run the event loop from Python. Thank you--I will try to review these this week. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |
From: Andrés S. S. <and...@gm...> - 2014-01-18 23:59:00
|
How can I get off the mailing list??? Thanks A > On Jan 18, 2014, at 11:22 PM, Kevin Walzer <kw...@co...> wrote: > >> On 1/18/14, 9:05 AM, Michiel de Hoon wrote: >> >> >> That is simple: remove tkDisplayIfNeeded and the call to it from tkMacOSXNotify.c, and remove the line [window setAutodisplay:NO] from kMacOSXWm.c. >> If any glitches show up when we do that, we can think again what is the best solution for it. > > Just bringing some off-list discussion back to onto the list, it appears > that the [window setAutodisplay:NO] line is needed to address some > issues with drawing Tk windows under Cocoa, though the details are no > longer readily available. > > --Kevin > > -- > Kevin Walzer > Code by Kevin/Mobile Code by Kevin > http://www.codebykevin.com > http://www.wtmobilesoftware.com > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Tcl-mac mailing list > tc...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-mac |
From: Kevin W. <kw...@co...> - 2014-01-19 03:00:17
|
On 1/18/14, 6:58 PM, Andrés Sierra Soler wrote: > How can I get off the mailing list??? > Thanks > A > https://lists.sourceforge.net/lists/listinfo/tcl-mac -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com |