Tk Source Code

Check-in [60edb6d4]
Login

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 | bug-56a1823c73
Files: files | file ages | folders
SHA3-256: 60edb6d429c976c5b53d7bb5b6ab96e094b2cb6c592fbb6e47672d85cf06ffb0
User & Date: culler 2019-02-18 18:48:45
Context
2019-02-23
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-18
18:48
Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen. Closed-Leaf check-in: 60edb6d4 user: culler tags: bug-56a1823c73
2019-02-13
21:32
Remove a missed unused variable. check-in: 4c2dacd6 user: culler tags: core-8-6-branch
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
181
182
183
184
185
186
187
188
189
190
191
192

193

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    }

    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);

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

	event.xany.serial = LastKnownRequestProcessed(display);
	event.xany.send_event = False;
	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);
    }

    /*
     * Generate VisibilityNotify events for window and all mapped children.
     */

    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 --
 *







>








>









>
>
>
>
>
>
>
>
>

>




>



















>

>




















|



<







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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

233
234
235
236
237
238
239
    }

    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);

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

	event.xany.serial = LastKnownRequestProcessed(display);
	event.xany.send_event = False;
	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);
    }

    /*
     * Generate VisibilityNotify events for window and all mapped children.
     */

    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 --
 *
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    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.
	 */








<
<
<
|
<







294
295
296
297
298
299
300



301

302
303
304
305
306
307
308
    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.
	 */