From 8faca188c488af10facd0c8470314303f1b02c5b Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 21 Dec 2014 04:11:51 +0000 Subject: Minor optimization of drawing code in OSX --- macosx/tkMacOSXDraw.c | 4 ++-- macosx/tkMacOSXMenubutton.c | 17 +++++++++++++++-- macosx/tkMacOSXWindowEvent.c | 5 ++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 537b2e2..9e3435d 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1657,13 +1657,13 @@ TkMacOSXSetupDrawingContext( CGContextSetTextDrawingMode(dc.context, kCGTextFill); CGContextConcatCTM(dc.context, t); if (dc.clipRgn) { -#ifdef TK_MAC_DEBUG_DRAWING + #ifdef TK_MAC_DEBUG_DRAWING CGContextSaveGState(dc.context); ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); CGContextEOFillPath(dc.context); CGContextRestoreGState(dc.context); -#endif /* TK_MAC_DEBUG_DRAWING */ + #endif /* TK_MAC_DEBUG_DRAWING */ CGRect r; if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( *HIShapeGetBounds(dc.clipRgn, &r), diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index df42763..c79a9c1 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -60,12 +60,23 @@ static const BoundsFix boundsFixes[] = { #endif + + /* * Forward declarations for procedures defined later in this file: */ static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr); +/* + * The structure below defines menubutton class behavior by means of functions + * that can be invoked from generic window code. + */ + +Tk_ClassProcs tkpMenubuttonClass = { + sizeof(Tk_ClassProcs), /* size */ + TkMenuButtonWorldChanged, /* worldChangedProc */ +}; /* *---------------------------------------------------------------------- @@ -87,9 +98,11 @@ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { - MacMenuButton *macButtonPtr = ckalloc(sizeof(MacMenuButton)); + MacMenuButton *macButtonPtr = + (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); macButtonPtr->button = nil; + Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, (ClientData) macButtonPtr); return (TkMenuButton *) macButtonPtr; @@ -160,7 +173,7 @@ TkpDisplayMenuButton( if (!tkwin || !Tk_IsMapped(tkwin) || !view || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { return; - } + } CGContextConcatCTM(dc.context, t); Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, mbPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5d50278..6546070 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -839,8 +839,11 @@ ExposeRestrictProc( NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, nil]]; } + 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.*/ @@ -877,7 +880,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 -- cgit v0.12