summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2014-12-28 05:24:14 (GMT)
committerKevin Walzer <kw@codebykevin.com>2014-12-28 05:24:14 (GMT)
commit6c03075e924a24f235fe3d6156eb7f62299b9f4d (patch)
treee850e31e968dfe815ebde16bb2e02bc9eb19c0f9
parentf28383d3280d92c9ff8c3dbb11c8fb41615470af (diff)
downloadtk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.zip
tk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.tar.gz
tk-6c03075e924a24f235fe3d6156eb7f62299b9f4d.tar.bz2
Refinement of redraw during window resizing in Cocoa; refinement of button display
-rw-r--r--macosx/tkMacOSXButton.c4
-rw-r--r--macosx/tkMacOSXWindowEvent.c31
2 files changed, 27 insertions, 8 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index f0e1cbd..a84ac97 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -67,11 +67,11 @@ static NSRect TkMacOSXGetButtonFrame(TkButton *butPtr);
return;
}
- /* Do not draw if the widget is completely outside of its parent, or within 50 pixels of the right border; this prevents buttons from being drawn on peer widgets as scrolling occurs. */
+ /* Do not draw if the widget is completely outside of its parent, or within 20 pixels of the right border; this prevents buttons from being drawn on peer widgets as scrolling occurs. */
int parent_width = Tk_Width(Tk_Parent(tkwin));
int widget_width = Tk_Width(tkwin);
int x = Tk_X(tkwin);
- if (x > parent_width - 50 || x < 0) {
+ if (x > parent_width - 20 || x < 0) {
return;
}
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: