summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWindowEvent.c
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2014-12-24 04:43:40 (GMT)
committerKevin Walzer <kw@codebykevin.com>2014-12-24 04:43:40 (GMT)
commit6137cff44fac896616e033bcba2aa90cd3d4adf5 (patch)
treea2529d63c5b9744d594aeae79995ce53a48e0d29 /macosx/tkMacOSXWindowEvent.c
parentc72a9f168448e8f6b17aa805d5308b4934cfa4d1 (diff)
downloadtk-6137cff44fac896616e033bcba2aa90cd3d4adf5.zip
tk-6137cff44fac896616e033bcba2aa90cd3d4adf5.tar.gz
tk-6137cff44fac896616e033bcba2aa90cd3d4adf5.tar.bz2
All on Tk/Cocoa: Improve view performance during resizing; implement custom drawing of scroller to remove flickering and ghosted appearance during window operations; reduce flickering of menubutton during resizing, but do not completely eliminate ghosted rendering when widget is unmapped
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r--macosx/tkMacOSXWindowEvent.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 6546070..7207859 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -769,6 +769,8 @@ Tk_MacOSXIsAppInFront(void)
@interface TKContentView(TKWindowEvent)
- (void) drawRect: (NSRect) rect;
- (void) generateExposeEvents: (HIMutableShapeRef) shape;
+- (BOOL) preservesContentDuringLiveResize;
+- (void) viewWillStartLiveResize;
- (void) viewDidEndLiveResize;
- (void) viewWillDraw;
- (BOOL) isOpaque;
@@ -780,15 +782,6 @@ Tk_MacOSXIsAppInFront(void)
@implementation TKContentView
@end
-double drawTime;
-
-/*
- * Set a minimum time for drawing to render. With removal of private NSView API's, default drawing
- * is slower and less responsive. This number, which seems feasible after some experimentatation, skips
- * some drawing to avoid lag.
- */
-
-#define MAX_DYNAMIC_TIME .000000001
/*Restrict event processing to Expose events.*/
static Tk_RestrictAction
@@ -805,10 +798,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];
@@ -816,11 +811,7 @@ ExposeRestrictProc(
NSCompositeSourceOver);
#endif
- NSDate *beginTime=[NSDate date];
-
- /*Skip drawing during live resize if redraw is too slow.*/
- if([self inLiveResize] && drawTime>MAX_DYNAMIC_TIME) return;
-
+
CGFloat height = [self bounds].size.height;
HIMutableShapeRef drawShape = HIShapeCreateMutable();
@@ -841,24 +832,35 @@ ExposeRestrictProc(
}
CFRelease(drawShape);
- drawTime=-[beginTime timeIntervalSinceNow];
- [super setNeedsDisplayInRect:rect];
}
-/*At conclusion of resize event, send notification and set view for redraw if earlier drawing was skipped because of lagginess.*/
+
+/*Provide more fine-grained control over resizing of content to reduce flicker after removal of private API's.*/
+
+- (BOOL) preservesContentDuringLiveResize
+{
+ return YES;
+}
+
+- (void)viewWillStartLiveResize
+{
+ [super viewWillStartLiveResize];
+ [self setNeedsDisplay:NO];
+}
+
+
- (void)viewDidEndLiveResize
{
- if(drawTime>MAX_DYNAMIC_TIME) {
+
[self setNeedsDisplay:YES];
+ [super setNeedsDisplay:YES];
[super viewDidEndLiveResize];
- }
+
}
--(void) viewWillDraw {
- [self setNeedsDisplay:YES];
- }
+/*Core function of this class, generates expose events for redrawing.*/
- (void) generateExposeEvents: (HIMutableShapeRef) shape
{