diff options
author | Kevin Walzer <kw@codebykevin.com> | 2014-12-28 05:24:14 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2014-12-28 05:24:14 (GMT) |
commit | 6c03075e924a24f235fe3d6156eb7f62299b9f4d (patch) | |
tree | e850e31e968dfe815ebde16bb2e02bc9eb19c0f9 /macosx/tkMacOSXWindowEvent.c | |
parent | f28383d3280d92c9ff8c3dbb11c8fb41615470af (diff) | |
download | tk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.zip tk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.tar.gz tk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.tar.bz2 |
Refinement of redraw during window resizing in Cocoa; refinement of button display
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 13a9f10..9fd4867 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -800,10 +800,12 @@ ExposeRestrictProc( - (void) drawRect: (NSRect) rect { + const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; + #ifdef TK_MAC_DEBUG_DRAWING TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect)); [[NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:.1] setFill]; @@ -811,12 +813,12 @@ ExposeRestrictProc( NSCompositeSourceOver); #endif + CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); while (rectsBeingDrawnCount--) { CGRect r = NSRectToCGRect(*rectsBeingDrawn++); - r.origin.y = height - (r.origin.y + r.size.height); HIShapeUnionWithRect(drawShape, &r); } @@ -829,11 +831,21 @@ ExposeRestrictProc( NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, nil]]; } + CFRelease(drawShape); + } + /*Provide more fine-grained control over resizing of content to reduce flicker after removal of private API's.*/ +-(void) viewWillDraw +{ + + [super viewWillDraw]; +} + + - (BOOL) preservesContentDuringLiveResize { return YES; @@ -841,19 +853,25 @@ ExposeRestrictProc( - (void)viewWillStartLiveResize { + NSDisableScreenUpdates(); [super viewWillStartLiveResize]; + [self setNeedsDisplay:NO]; + [self setHidden:YES]; } - (void)viewDidEndLiveResize { + NSEnableScreenUpdates(); + [self setHidden:NO]; [self setNeedsDisplay:YES]; [super setNeedsDisplay:YES]; [super viewDidEndLiveResize]; } +/*Core function of this class, generates expose events for redrawing.*/ - (void) generateExposeEvents: (HIMutableShapeRef) shape { @@ -865,6 +883,7 @@ ExposeRestrictProc( return; } + HIShapeGetBounds(shape, &updateBounds); serial = LastKnownRequestProcessed(Tk_Display(winPtr)); if (GenerateUpdates(shape, &updateBounds, winPtr) && @@ -875,7 +894,7 @@ ExposeRestrictProc( * just posted Expose events from generating new redraws. */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} /* * For smoother drawing, process Expose events and resulting redraws @@ -887,12 +906,13 @@ ExposeRestrictProc( UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {} - + Tk_RestrictEvents(oldProc, oldArg, &oldArg); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} - } - + } + } /*This is no-op on 10.7 and up because Apple has removed this widget, but leaving here for backwards compatibility.*/ @@ -964,7 +984,6 @@ ExposeRestrictProc( } @end - /* * Local Variables: |