Tk Source Code

Check-in [5e709226]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA3-256: 5e709226cc664f614155f1a17f5953db8eb3e2573bd1fcb7447f057280e42485
User & Date: culler 2019-02-23 02:30:53
References
2019-05-15
17:25 Ticket [d1989fb7] Aqua: Empty window appears after `package require Tk` status still Open with 4 other changes artifact: 434e1882 user: marc_culler
2019-04-29
03:14 Ticket [d1989fb7]: 5 changes artifact: 0f0ead8e user: chrstphrchvz
Context
2019-02-23
21:16
Fix bug [9771ae0f0b]: In Aqua, deiconifying a transient of a withdrawn window can create a zombie. check-in: b2b91450 user: culler tags: core-8-6-branch
05:44
Fix bug [9771ae0f0b]: In Aqua, deiconifying a transient of a withdrawn window can create a zombie Closed-Leaf check-in: 20029d1c user: culler tags: bug-9771ae0f0b
04:10
Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen. check-in: a3d50fdc user: culler tags: trunk
02:30
Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen. check-in: 5e709226 user: culler tags: core-8-6-branch
2019-02-22
18:50
Fix [30a0fc767a]: spelling error in a comment check-in: f248e1f0 user: fvogel tags: core-8-6-branch
2019-02-18
18:48
Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen. Closed-Leaf check-in: 60edb6d4 user: culler tags: bug-56a1823c73
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXInit.c.

118
119
120
121
122
123
124

125









126
127
128
129
130
131
132
-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
    /*
     * It is not safe to force activation of the NSApp until this
     * method is called.  Activating too early can cause the menu
     * bar to be unresponsive.
     */

    [NSApp activateIgnoringOtherApps: YES];









}

- (void) _setup: (Tcl_Interp *) interp
{
    /*
     * Remember our interpreter.
     */






>

>
>
>
>
>
>
>
>
>







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
    /*
     * It is not safe to force activation of the NSApp until this
     * method is called.  Activating too early can cause the menu
     * bar to be unresponsive.
     */

    [NSApp activateIgnoringOtherApps: YES];

    /*
     * Process events to ensure that the root window is fully
     * initialized. See ticket 56a1823c73.
     */
    
    [NSApp _lockAutoreleasePool];
    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
    [NSApp _unlockAutoreleasePool];
}

- (void) _setup: (Tcl_Interp *) interp
{
    /*
     * Remember our interpreter.
     */

Changes to macosx/tkMacOSXSubwindows.c.

145
146
147
148
149
150
151

152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
167
168









169

170
171
172
173

174
175
176
177
178
179
180
...
186
187
188
189
190
191
192

193

194
195
196
197
198
199
200
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    }

    display->request++;
    macWin->winPtr->flags |= TK_MAPPED;
    if (Tk_IsTopLevel(macWin->winPtr)) {
	if (!Tk_IsEmbedded(macWin->winPtr)) {
	    NSWindow *win = TkMacOSXDrawableWindow(window);

	    /*
	     * We want to activate Tk when a toplevel is mapped
	     * but we must not supply YES here.  This is because
	     * during Tk initialization the root window is mapped
	     * before applicationDidFinishLaunching returns. Forcing
	     * the app to activate too early can make the menu bar
	     * unresponsive.
	     */

	    TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
	    [win setExcludedFromWindowsMenu:NO];
	    [NSApp activateIgnoringOtherApps:NO];
	    [[win contentView] setNeedsDisplay:YES];
	    if ( [win canBecomeKeyWindow] ) {
		[win makeKeyAndOrderFront:NSApp];
	    } else {
		[win orderFrontRegardless];
	    }









	} else {

	    /*
	     * Rebuild the container's clipping region and display
	     * the window.
	     */

	    TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
	    TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
	    TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	}
	TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);

	/*
................................................................................
	event.xany.display = display;

	event.xmap.window = window;
	event.xmap.type = MapNotify;
	event.xmap.event = window;
	event.xmap.override_redirect = macWin->winPtr->atts.override_redirect;
	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);

    } else {

	/*
	 * Rebuild the parent's clipping region and display the window.
	 *
	 */

	TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
	TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
................................................................................
    event.xany.send_event = False;
    event.xany.display = display;
    event.xvisibility.type = VisibilityNotify;
    event.xvisibility.state = VisibilityUnobscured;
    NotifyVisibility(macWin->winPtr, &event);

    /*
     * Make sure that subwindows get displayed.
     */

    GenerateConfigureNotify(macWin->winPtr, 1);

}
 
/*
 *----------------------------------------------------------------------
 *
 * NotifyVisibility --
 *
................................................................................
    XEvent event;

    display->request++;
    if (Tk_IsTopLevel(winPtr)) {
	if (!Tk_IsEmbedded(winPtr) &&
		winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
	    NSWindow *win = TkMacOSXDrawableWindow(window);

	    if ([win isVisible]) {
		[[win parentWindow] removeChildWindow:win];
		[win orderOut:NSApp];
	    }
	}
	TkMacOSXInvalClipRgns((Tk_Window) winPtr);

	/*
	 * We only need to send the UnmapNotify event for toplevel windows.
	 */







>








>









>
>
>
>
>
>
>
>
>

>




>







 







>

>







 







|



<







 







<
<
<
|
<







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
222
223
224
225
226
227
228
229
230
231
232

233
234
235
236
237
238
239
...
294
295
296
297
298
299
300



301

302
303
304
305
306
307
308
    }

    display->request++;
    macWin->winPtr->flags |= TK_MAPPED;
    if (Tk_IsTopLevel(macWin->winPtr)) {
	if (!Tk_IsEmbedded(macWin->winPtr)) {
	    NSWindow *win = TkMacOSXDrawableWindow(window);

	    /*
	     * We want to activate Tk when a toplevel is mapped
	     * but we must not supply YES here.  This is because
	     * during Tk initialization the root window is mapped
	     * before applicationDidFinishLaunching returns. Forcing
	     * the app to activate too early can make the menu bar
	     * unresponsive.
	     */

	    TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
	    [win setExcludedFromWindowsMenu:NO];
	    [NSApp activateIgnoringOtherApps:NO];
	    [[win contentView] setNeedsDisplay:YES];
	    if ( [win canBecomeKeyWindow] ) {
		[win makeKeyAndOrderFront:NSApp];
	    } else {
		[win orderFrontRegardless];
	    }
	    
	    /*
	     * In some cases the toplevel will not be drawn unless we process
	     * all pending events now.  See ticket 56a1823c73.
	     */

	    [NSApp _lockAutoreleasePool];
	    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
	    [NSApp _unlockAutoreleasePool];
	} else {

	    /*
	     * Rebuild the container's clipping region and display
	     * the window.
	     */

	    TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
	    TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
	    TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	}
	TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);

	/*
................................................................................
	event.xany.display = display;

	event.xmap.window = window;
	event.xmap.type = MapNotify;
	event.xmap.event = window;
	event.xmap.override_redirect = macWin->winPtr->atts.override_redirect;
	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);

    } else {

	/*
	 * Rebuild the parent's clipping region and display the window.
	 *
	 */

	TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
	TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
................................................................................
    event.xany.send_event = False;
    event.xany.display = display;
    event.xvisibility.type = VisibilityNotify;
    event.xvisibility.state = VisibilityUnobscured;
    NotifyVisibility(macWin->winPtr, &event);

    /*
     * This seems to be needed to ensure that all subwindows get displayed.
     */

    GenerateConfigureNotify(macWin->winPtr, 1);

}
 
/*
 *----------------------------------------------------------------------
 *
 * NotifyVisibility --
 *
................................................................................
    XEvent event;

    display->request++;
    if (Tk_IsTopLevel(winPtr)) {
	if (!Tk_IsEmbedded(winPtr) &&
		winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
	    NSWindow *win = TkMacOSXDrawableWindow(window);



	    [win orderOut:nil];

	}
	TkMacOSXInvalClipRgns((Tk_Window) winPtr);

	/*
	 * We only need to send the UnmapNotify event for toplevel windows.
	 */