Tk Source Code

Check-in [b1645f5c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Fix bug [4d2e8d4d5c]: Aqua notebooks sometimes do not draw a new pane immediately
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-4d2e8d4d5c
Files: files | file ages | folders
SHA3-256: b1645f5cd3e00c9e357fae10a319c07d3a13ef8e7113462d7c898c08d28be93f
User & Date: culler 2019-04-24 15:52:16
Context
2019-04-24
16:04
Fix bug [4d2e8d4d5c]: Aqua notebooks sometimes do not draw a new pane immediately check-in: f656b303 user: culler tags: core-8-6-branch
15:52
Fix bug [4d2e8d4d5c]: Aqua notebooks sometimes do not draw a new pane immediately Closed-Leaf check-in: b1645f5c user: culler tags: bug-4d2e8d4d5c
2019-04-20
15:03
On macOS, edit comments and documentation; fix compiler warnings. check-in: 476cf7ba user: culler tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXKeyEvent.c.

253
254
255
256
257
258
259








260
261
262
263
264
265
266
...
445
446
447
448
449
450
451


452
453
454
455
456
457
458
    savedModifiers = modifiers;
    return theEvent;
}
@end
 

@implementation TKContentView








/* <NSTextInput> implementation (called through interpretKeyEvents:]). */

/* <NSTextInput>: called when done composing;
   NOTE: also called when we delete over working text, followed immed.
         by doCommandBySelector: deleteBackward: */
- (void)insertText: (id)aString
{
................................................................................
    }
    if (NS_KEYLOG) {
	TKLog(@"attributedSubstringFromRange request");
    }
    return str;
}
/* End <NSTextInput> impl. */


@end
 

@implementation TKContentView(TKKeyEvent)
/* delete display of composing characters [not in <NSTextInput>] */
- (void)deleteWorkingText
{






>
>
>
>
>
>
>
>







 







>
>







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
...
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
    savedModifiers = modifiers;
    return theEvent;
}
@end
 

@implementation TKContentView

-(id)init {
    if (self = [super init]) {
        _needsRedisplay = NO;
    }
    return self;
}

/* <NSTextInput> implementation (called through interpretKeyEvents:]). */

/* <NSTextInput>: called when done composing;
   NOTE: also called when we delete over working text, followed immed.
         by doCommandBySelector: deleteBackward: */
- (void)insertText: (id)aString
{
................................................................................
    }
    if (NS_KEYLOG) {
	TKLog(@"attributedSubstringFromRange request");
    }
    return str;
}
/* End <NSTextInput> impl. */

@synthesize needsRedisplay = _needsRedisplay;
@end
 

@implementation TKContentView(TKKeyEvent)
/* delete display of composing characters [not in <NSTextInput>] */
- (void)deleteWorkingText
{

Changes to macosx/tkMacOSXPrivate.h.

328
329
330
331
332
333
334

335




336

337
338
339
340
341
342
343
- (void) handleDoScriptEvent:          (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
@end

VISIBILITY_HIDDEN
@interface TKContentView : NSView <NSTextInput>
{

    NSString *privateWorkingText;




}

@end

@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
@end

@interface TKContentView(TKWindowEvent)






>

>
>
>
>

>







328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
- (void) handleDoScriptEvent:          (NSAppleEventDescriptor *)event
		   withReplyEvent:     (NSAppleEventDescriptor *)replyEvent;
@end

VISIBILITY_HIDDEN
@interface TKContentView : NSView <NSTextInput>
{
@private
    NSString *privateWorkingText;
#ifdef __i386__
    /* The Objective C runtime used on i386 requires this. */
    Bool _needsRedisplay;
#endif
}
@property Bool needsRedisplay;
@end

@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
@end

@interface TKContentView(TKWindowEvent)

Changes to macosx/tkMacOSXSubwindows.c.

126
127
128
129
130
131
132


133
134
135
136
137
138
139
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
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
void
XMapWindow(
    Display *display,		/* Display. */
    Window window)		/* Window. */
{
    MacDrawable *macWin = (MacDrawable *) window;


    XEvent event;

    /*
     * Under certain situations it's possible for this function to be called
     * before the toplevel window it's associated with has actually been
     * mapped. In that case we need to create the real Macintosh window now as
     * this function as well as other X functions assume that the portPtr is
................................................................................
     */

    if (!TkMacOSXHostToplevelExists(macWin->toplevel->winPtr)) {
	TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr);
    }

    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];
................................................................................
	     * 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 --
 *






>
>







 







|
|
|
<









|







 







>






<
<



>
|












|


>

|
>


|
<
>
>
>
>
>










|
<
<
<
<
<
<







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
143
144
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
...
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
void
XMapWindow(
    Display *display,		/* Display. */
    Window window)		/* Window. */
{
    MacDrawable *macWin = (MacDrawable *) window;
    TkWindow *winPtr = macWin->winPtr;
    NSWindow *win = TkMacOSXDrawableWindow(window);
    XEvent event;

    /*
     * Under certain situations it's possible for this function to be called
     * before the toplevel window it's associated with has actually been
     * mapped. In that case we need to create the real Macintosh window now as
     * this function as well as other X functions assume that the portPtr is
................................................................................
     */

    if (!TkMacOSXHostToplevelExists(macWin->toplevel->winPtr)) {
	TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr);
    }

    display->request++;
    winPtr->flags |= TK_MAPPED;
    if (Tk_IsTopLevel(winPtr)) {
	if (!Tk_IsEmbedded(winPtr)) {


	    /*
	     * 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(winPtr, win);
	    [win setExcludedFromWindowsMenu:NO];
	    [NSApp activateIgnoringOtherApps:NO];
	    [[win contentView] setNeedsDisplay:YES];
	    if ([win canBecomeKeyWindow]) {
		[win makeKeyAndOrderFront:NSApp];
	    } else {
		[win orderFrontRegardless];
................................................................................
	     * all pending events now.  See ticket 56a1823c73.
	     */

	    [NSApp _lockAutoreleasePool];
	    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
	    [NSApp _unlockAutoreleasePool];
	} else {
	    TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);

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



	    TkMacOSXInvalClipRgns((Tk_Window) contWinPtr);
	    TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	}

	TkMacOSXInvalClipRgns((Tk_Window) 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 = winPtr->atts.override_redirect;
	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
    } else {

	/*
	 * For non-toplevel windows, rebuild the parent's clipping region
	 * and redisplay the window.
	 */

	TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);

	if ([NSApp isDrawing]) {
	    [[win contentView] setNeedsRedisplay:YES];
	} else {
	    [[win contentView] setNeedsDisplay:YES];
	}
    }

    /*
     * 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(winPtr, &event);






}
 
/*
 *----------------------------------------------------------------------
 *
 * NotifyVisibility --
 *

Changes to macosx/tkMacOSXWindowEvent.c.

852
853
854
855
856
857
858

859


860
861
862
863
864
865
866
867
868

869


870
871
872
873
874
875
876
























877
878
879
880
881
882
883
...
916
917
918
919
920
921
922





923
924
925
926
927
928
929
 * Widgets it was necessary to use Apple private API calls.  In order to avoid
 * using private API calls, the NSView-based widgets have been replaced with
 * normal Tk widgets which draw themselves as native widgets by using the
 * HITheme API.
 *
 */


/*Restrict event processing to Expose events.*/


static Tk_RestrictAction
ExposeRestrictProc(
    ClientData arg,
    XEvent *eventPtr)
{
    return (eventPtr->type==Expose && eventPtr->xany.serial==PTR2UINT(arg)
	    ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}


/*Restrict event processing to ConfigureNotify events.*/


static Tk_RestrictAction
ConfigureRestrictProc(
    ClientData arg,
    XEvent *eventPtr)
{
    return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}

























@implementation TKContentView(TKWindowEvent)

- (void) drawRect: (NSRect) rect
{
    const NSRect *rectsBeingDrawn;
    NSInteger rectsBeingDrawnCount;
................................................................................

	r.origin.y = height - (r.origin.y + r.size.height);
	HIShapeUnionWithRect(drawShape, &r);
    }
    [self generateExposeEvents:(HIShapeRef)drawShape];
    CFRelease(drawShape);
    [NSApp setIsDrawing: NO];






#ifdef TK_MAC_DEBUG_DRAWING
    fprintf(stderr, "drawRect: done.\n");
#endif
}

-(void) setFrameSize: (NSSize)newsize






>
|
>
>









>
|
>
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>







852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
...
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
 * Widgets it was necessary to use Apple private API calls.  In order to avoid
 * using private API calls, the NSView-based widgets have been replaced with
 * normal Tk widgets which draw themselves as native widgets by using the
 * HITheme API.
 *
 */

/*
 * Restrict event processing to Expose events.
 */

static Tk_RestrictAction
ExposeRestrictProc(
    ClientData arg,
    XEvent *eventPtr)
{
    return (eventPtr->type==Expose && eventPtr->xany.serial==PTR2UINT(arg)
	    ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}

/*
 * Restrict event processing to ConfigureNotify events.
 */

static Tk_RestrictAction
ConfigureRestrictProc(
    ClientData arg,
    XEvent *eventPtr)
{
    return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}

/*
 * If a window gets mapped inside the drawRect method, this will be run as an
 * idle task, after drawRect returns, to clean up the mess.
 */

static void
RedisplayView(
    ClientData clientdata)
{
    NSView *view = (NSView *) clientdata;

    /*
     * Make sure that we are not trying to displaying a view that no longer
     * exists.
     */
    
    for (NSWindow *w in [NSApp orderedWindows]) {
	if ([w contentView] == view) {
	    [view setNeedsDisplay:YES];
	    break;
	}
    }
}

@implementation TKContentView(TKWindowEvent)

- (void) drawRect: (NSRect) rect
{
    const NSRect *rectsBeingDrawn;
    NSInteger rectsBeingDrawnCount;
................................................................................

	r.origin.y = height - (r.origin.y + r.size.height);
	HIShapeUnionWithRect(drawShape, &r);
    }
    [self generateExposeEvents:(HIShapeRef)drawShape];
    CFRelease(drawShape);
    [NSApp setIsDrawing: NO];

    if ([self needsRedisplay]) {
	[self setNeedsRedisplay:NO];
	Tcl_DoWhenIdle(RedisplayView, self);
    }

#ifdef TK_MAC_DEBUG_DRAWING
    fprintf(stderr, "drawRect: done.\n");
#endif
}

-(void) setFrameSize: (NSSize)newsize