summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogelnew1@free.fr <fvogel>2015-01-02 15:23:43 (GMT)
committerfvogelnew1@free.fr <fvogel>2015-01-02 15:23:43 (GMT)
commit3065314348b624b03691f302be1387fffc318cfd (patch)
tree0096975153ebe68d3c0d36918be092d4bd6523d0
parent73bc5e2949628f5134f8e49b1b350ed62773461a (diff)
parentee11279857f8f750bbed1f7ac7cc5276c0d43687 (diff)
downloadtk-3065314348b624b03691f302be1387fffc318cfd.zip
tk-3065314348b624b03691f302be1387fffc318cfd.tar.gz
tk-3065314348b624b03691f302be1387fffc318cfd.tar.bz2
Merged core-8-5-branch to text-elided branch
-rw-r--r--doc/text.n2
-rw-r--r--macosx/GNUmakefile2
-rw-r--r--macosx/tkMacOSXButton.c6
-rw-r--r--macosx/tkMacOSXScrlbr.c117
-rw-r--r--macosx/tkMacOSXWindowEvent.c77
-rw-r--r--tests/ttk/spinbox.test2
6 files changed, 140 insertions, 66 deletions
diff --git a/doc/text.n b/doc/text.n
index b0fd514..a7eeffc 100644
--- a/doc/text.n
+++ b/doc/text.n
@@ -1870,7 +1870,7 @@ This command returns an empty string.
\fIpathName \fBwindow \fIoption \fR?\fIarg arg ...\fR?
This command is used to manipulate embedded windows.
The behavior of the command depends on the \fIoption\fR argument
-that follows the \fBtag\fR argument.
+that follows the \fBwindow\fR argument.
The following forms of the command are currently supported:
.RS
.TP
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile
index 333961c..f3299e2 100644
--- a/macosx/GNUmakefile
+++ b/macosx/GNUmakefile
@@ -132,7 +132,7 @@ wish := ${wish}-X11
override EMBEDDED_BUILD :=
endif
-INSTALL_TARGETS = install-binaries install-libraries
+INSTALL_TARGETS = install-binaries install-headers install-libraries
ifeq (${EMBEDDED_BUILD},)
INSTALL_TARGETS += install-private-headers install-demos
endif
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index b9ee7a3..a84ac97 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -38,7 +38,7 @@ static NSRect TkMacOSXGetButtonFrame(TkButton *butPtr);
*/
@interface TkNSButton: NSButton
-
+- (void)drawRect:(NSRect)dirtyRect;
@end
@implementation TkNSButton
@@ -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/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 3658f7e..38115ee 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -7,6 +7,8 @@
* Copyright (c) 1996 by Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+* Copyright (c) 2014 Marc Culler.
+ * Copyright (c) 2014 Kevin Walzer/WordTech Commununications LLC.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -31,52 +33,103 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr);
* aware of the state of its Tk parent. This subclass overrides the drawRect
* method so that it will not draw itself if the widget is completely outside
* of its container.
+ *
+ * Custom drawing of the knob seems to work around the flickering visible after
+ * private API's were removed. Based on technique outlined at
+ * http://stackoverflow.com/questions/1604682/nsscroller-
+ * graphical-glitches-lag. Only supported on 10.7 and above.
*/
+
@interface TkNSScroller: NSScroller
-(void) drawRect:(NSRect)dirtyRect;
-
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+-(BOOL) isHorizontal;
+-(void) drawKnob;
+- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag;
+- (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight;
+#endif
@end
@implementation TkNSScroller
- - (void)drawRect:(NSRect)dirtyRect
- {
- NSInteger tag = [self tag];
- if ( tag != -1) {
- TkScrollbar *scrollPtr = (TkScrollbar *)tag;
- MacDrawable* macWin = (MacDrawable *)scrollPtr;
- Tk_Window tkwin = scrollPtr->tkwin;
- NSRect Tkframe = TkMacOSXGetScrollFrame(scrollPtr);
- /* Do not draw if the widget is misplaced or unmapped. */
- if ( NSIsEmptyRect(Tkframe) ||
- ! macWin->winPtr->flags & TK_MAPPED ||
- ! NSEqualRects(Tkframe, [self frame])
- ) {
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+ NSInteger tag = [self tag];
+ if ( tag != -1) {
+ TkScrollbar *scrollPtr = (TkScrollbar *)tag;
+ MacDrawable* macWin = (MacDrawable *)scrollPtr;
+ Tk_Window tkwin = scrollPtr->tkwin;
+ NSRect Tkframe = TkMacOSXGetScrollFrame(scrollPtr);
+ /* Do not draw if the widget is misplaced or unmapped. */
+ if ( NSIsEmptyRect(Tkframe) ||
+ ! macWin->winPtr->flags & TK_MAPPED ||
+ ! NSEqualRects(Tkframe, [self frame])
+ ) {
+ return;
+ }
+
+ /*
+ * Do not draw if the widget is completely outside of its parent.
+ */
+ if (tkwin) {
+ int parent_height = Tk_Height(Tk_Parent(tkwin));
+ int widget_height = Tk_Height(tkwin);
+ int y = Tk_Y(tkwin);
+ if ( y > parent_height || y + widget_height < 0 ) {
return;
}
- /*
- * Do not draw if the widget is completely outside of its parent.
- */
- if (tkwin) {
- int parent_height = Tk_Height(Tk_Parent(tkwin));
- int widget_height = Tk_Height(tkwin);
- int y = Tk_Y(tkwin);
- if ( y > parent_height || y + widget_height < 0 ) {
- return;
- }
-
- int parent_width = Tk_Width(Tk_Parent(tkwin));
- int widget_width = Tk_Width(tkwin);
- int x = Tk_X(tkwin);
- if (x > parent_width || x + widget_width < 0) {
- return;
- }
+ int parent_width = Tk_Width(Tk_Parent(tkwin));
+ int widget_width = Tk_Width(tkwin);
+ int x = Tk_X(tkwin);
+ if (x > parent_width || x + widget_width < 0) {
+ return;
}
}
- [super drawRect:dirtyRect];
}
+ [super drawRect:dirtyRect];
+}
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+- (BOOL)isVertical {
+ NSRect bounds = [self bounds];
+ return NSWidth(bounds) < NSHeight (bounds);
+}
+
+
+- (void)drawKnob
+{
+ NSRect knobRect = [self rectForPart:NSScrollerKnob];
+
+ if ([self isVertical]) {
+ NSRect newRect = NSMakeRect(knobRect.origin.x + 3, knobRect.origin.y, knobRect.size.width - 6, knobRect.size.height);
+ NSBezierPath *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4];
+
+ [[NSColor lightGrayColor] set];
+ [scrollerPath fill];
+ } else {
+ NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y + 3, knobRect.size.width, knobRect.size.height - 6);
+ NSBezierPath *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4];
+
+ [[NSColor lightGrayColor] set];
+ [scrollerPath fill];
+ }
+
+}
+
+- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag
+{
+ // We don't want arrows
+}
+
+- (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight
+{
+
+}
+
+#endif
@end
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 5314dc9..c49fe15 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -80,6 +80,10 @@ extern NSString *opaqueTag;
NSWindow *w = [notification object];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+ /*Disable drawing until window is resized removes flicker and drawing artifacts;necessary after removal of private API.*/
+ NSDisableScreenUpdates();
+ [ [w contentView] setHidden:YES];
+
if (winPtr) {
WmInfo *wmPtr = winPtr->wmInfoPtr;
NSRect bounds = [w frame];
@@ -107,6 +111,8 @@ extern NSString *opaqueTag;
}
TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags);
}
+ [[w contentView] setHidden:NO];
+ NSEnableScreenUpdates();
}
- (void) windowExpanded: (NSNotification *) notification
@@ -771,6 +777,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;
@@ -782,15 +790,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
@@ -807,10 +806,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];
@@ -818,17 +819,12 @@ 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();
while (rectsBeingDrawnCount--) {
CGRect r = NSRectToCGRect(*rectsBeingDrawn++);
-
r.origin.y = height - (r.origin.y + r.size.height);
HIShapeUnionWithRect(drawShape, &r);
}
@@ -841,23 +837,47 @@ ExposeRestrictProc(
NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode,
nil]];
}
+
CFRelease(drawShape);
- drawTime=-[beginTime timeIntervalSinceNow];
+
+}
+
+
+/*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;
+}
+
+- (void)viewWillStartLiveResize
+{
+ NSDisableScreenUpdates();
+ [super viewWillStartLiveResize];
+ [self setNeedsDisplay:NO];
+ [self setHidden:YES];
}
-/*At conclusion of resize event, send notification and set view for redraw if earlier drawing was skipped because of lagginess.*/
+
- (void)viewDidEndLiveResize
{
- if(drawTime>MAX_DYNAMIC_TIME) {
+
+ NSEnableScreenUpdates();
+ [self setHidden:NO];
[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
{
@@ -869,6 +889,7 @@ ExposeRestrictProc(
return;
}
+
HIShapeGetBounds(shape, &updateBounds);
serial = LastKnownRequestProcessed(Tk_Display(winPtr));
if (GenerateUpdates(shape, &updateBounds, winPtr) &&
@@ -879,7 +900,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
@@ -891,12 +912,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.*/
@@ -968,7 +990,6 @@ ExposeRestrictProc(
}
@end
-
/*
* Local Variables:
diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test
index 3397e37..f7741c6 100644
--- a/tests/ttk/spinbox.test
+++ b/tests/ttk/spinbox.test
@@ -144,7 +144,7 @@ test spinbox-1.8.4 "-validate option: " -setup {
pack .sb
.sb set 50
focus .sb
- after 100 {set ::spinbox_wait 1} ; vwait ::spinbox_wait
+ after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait
set ::spinbox_test
} -cleanup {
destroy .sb