Tk Source Code

View Ticket
Login
Ticket UUID: 56a1823c73d45b29c2b7e7fdde85012a1495b17
Title: In Aqua, tk_GetOpenFile causes toplevels to open off screen
Type: Bug Version: 8.6.9
Submitter: marc_culler Created on: 2019-02-17 04:10:32
Subsystem: 37. [tk_get*File] Assigned To: marc_culler
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2019-02-23 02:16:27
Resolution: Fixed Closed By: marc_culler
    Closed on: 2019-02-23 02:16:27
Description: (text/x-fossil-wiki)
In Aqua, running this script in Wish causes a toplevel to appear containing the
text "this is a filename":
<verbatim>
wm iconify .
set filename "this is a filename"
toplevel .t -width 80 -height 100 
text .t.text
pack .t.text
.t.text insert end $filename
</verbatim>

Running the following script opens a file dialog, but when the dialog is
dismissed no toplevel appears.  Clicking the feather icon in the dock makes
a toplevel appear, containing the pathname of the selected file:
<verbatim>
wm iconify .
set filename [tk_getOpenFile]
toplevel .t -width 80 -height 100 
text .t.text
pack .t.text
.t.text insert end $filename
</verbatim>

Adding these three lines makes an empty toplevel appear:
<verbatim>
update
wm iconify .t
wm deiconify .t
</verbatim>

Adding an additional focus command makes the pathname appear in the window:
<verbatim>
focus .t.text
</verbatim>

None of those additional lines should be necessary.  It seems that when the
filedialog is closed the NSApplication is left for some time in a state where
any new NSWindows that are created are opened off screen.  Testing indicates
that [NSWindow isVisible] returns YES even though the window is not visible.
User Comments: marc_culler (claiming to be Marc Culler) added on 2019-02-23 02:16:27:
Thanks to Kevin Walzer for reviewing these changes!  We agree that the
bugs are fixed and neither of us were able to produce any crashes or
regressions related to the fix.  Also, there are no changes in the regression
test results. So I will merge the fix and close this ticket.

marc_culler (claiming to be Marc Culler) added on 2019-02-18 18:53:49: (text/x-fossil-wiki)
I also noticed that if the root window is withdrawn rather than iconified a
dead window with black background appears on the screen after the root
disappears.

Both of these problems are fixed in check-in [https://core.tcl.tk/tk/info/60edb6d429c976c5|60edb6d4] by processing all pending events in XMapWindow
and in the NSApplication method applicationDidFinishLaunching.