diff options
author | Kevin Walzer <kw@codebykevin.com> | 2014-07-25 17:04:32 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2014-07-25 17:04:32 (GMT) |
commit | 70e46f4111270421e799c112aa766a9f71a6d18e (patch) | |
tree | a56d353223531ad17562e901c4fc7a5163124835 /macosx/tkMacOSXWindowEvent.c | |
parent | c14530201df3f512c68f49728a3b8fcd2755bfcc (diff) | |
download | tk-70e46f4111270421e799c112aa766a9f71a6d18e.zip tk-70e46f4111270421e799c112aa766a9f71a6d18e.tar.gz tk-70e46f4111270421e799c112aa766a9f71a6d18e.tar.bz2 |
Add copyright notice to Marc Culler for extensive patch to alpha rendering on Mac/Cocoa; remove private API calls to comply with platform requirements.
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 309 |
1 files changed, 157 insertions, 152 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2e4a683..eff8484 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -806,13 +806,14 @@ ExposeRestrictProc( NSWindow *w = [self window]; - if ([self isOpaque] && [w showsResizeIndicator]) { - NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; + //remove private API calls here: not needed on systems >= 10.7 + // if ([self isOpaque] && [w showsResizeIndicator]) { + // NSRect bounds = [self convertRect:[w _growBoxRect] fromView:nil]; - if ([self needsToDrawRect:bounds]) { - NSEraseRect(bounds); - } - } + // if ([self needsToDrawRect:bounds]) { + // NSEraseRect(bounds); + // } + // } CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); @@ -946,152 +947,156 @@ ExposeRestrictProc( @end -#pragma mark TKContentViewPrivate - -/* - * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress - * normal AppKit subview drawing and make all drawing go through us. - * Overrides NSView internals. - */ - -@interface TKContentView(TKContentViewPrivate) -- (id) initWithFrame: (NSRect) frame; -- (void) _setAsideSubviews; -- (void) _restoreSubviews; -@end - -@interface NSView(TKContentViewPrivate) -- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect - isVisibleRect: (BOOL) isVisibleRect - rectIsVisibleRectForView: (NSView *) visibleView - topView: (BOOL) topView; -- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus - visRect: (NSRect) visRect; -- (void) _recursive: (BOOL) recurse - displayRectIgnoringOpacity: (NSRect) displayRect - inContext: (NSGraphicsContext *) context topView: (BOOL) topView; -- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; -- (BOOL) _drawRectIfEmpty; -- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; -- (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; -@end - -@implementation TKContentView(TKContentViewPrivate) - -- (id) initWithFrame: (NSRect) frame -{ - self = [super initWithFrame:frame]; - if (self) { - _savedSubviews = nil; - _subviewsSetAside = NO; - [self _setDrawsOwnDescendants:YES]; - } - return self; -} - -- (void) _setAsideSubviews -{ -#ifdef TK_MAC_DEBUG - if (_subviewsSetAside || _savedSubviews) { - Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); - } -#endif - _savedSubviews = _subviews; - _subviews = nil; - _subviewsSetAside = YES; -} - -- (void) _restoreSubviews -{ -#ifdef TK_MAC_DEBUG - if (!_subviewsSetAside || _subviews) { - Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); - } -#endif - _subviews = _savedSubviews; - _savedSubviews = nil; - _subviewsSetAside = NO; -} - -- (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect - isVisibleRect: (BOOL) isVisibleRect - rectIsVisibleRectForView: (NSView *) visibleView - topView: (BOOL) topView -{ - [self _setAsideSubviews]; - [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect - isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView - topView:topView]; - [self _restoreSubviews]; -} - -- (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus - visRect: (NSRect) visRect -{ - BOOL needToSetAsideSubviews = !_subviewsSetAside; - - if (needToSetAsideSubviews) { - [self _setAsideSubviews]; - } - [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus - visRect:visRect]; - if (needToSetAsideSubviews) { - [self _restoreSubviews]; - } -} - -- (void) _recursive: (BOOL) recurse - displayRectIgnoringOpacity: (NSRect) displayRect - inContext: (NSGraphicsContext *) context topView: (BOOL) topView -{ - [self _setAsideSubviews]; - [super _recursive:recurse - displayRectIgnoringOpacity:displayRect inContext:context - topView:topView]; - [self _restoreSubviews]; -} - -- (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect -{ - BOOL needToSetAsideSubviews = !_subviewsSetAside; - - if (needToSetAsideSubviews) { - [self _setAsideSubviews]; - } - [super _lightWeightRecursiveDisplayInRect:visRect]; - if (needToSetAsideSubviews) { - [self _restoreSubviews]; - } -} - -- (BOOL) _drawRectIfEmpty -{ - /* - * Our -drawRect manages subview drawing directly, so it needs to be called - * even if the area to be redrawn is completely obscured by subviews. - */ - - return YES; -} - -- (void) _drawRect: (NSRect) inRect clip: (BOOL) clip -{ -#ifdef TK_MAC_DEBUG_DRAWING - TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, - NSStringFromRect(inRect)); -#endif - BOOL subviewsWereSetAside = _subviewsSetAside; - - if (subviewsWereSetAside) { - [self _restoreSubviews]; - } - [super _drawRect:inRect clip:clip]; - if (subviewsWereSetAside) { - [self _setAsideSubviews]; - } -} - -@end +/*Remove private/non-documented API calls. This is strongly discouraged by Apple and may lead to breakage in the future.*/ + + +// #pragma mark TKContentViewPrivate + +// /* +// * Technique adapted from WebKit/WebKit/mac/WebView/WebHTMLView.mm to supress +// * normal AppKit subview drawing and make all drawing go through us. +// * Overrides NSView internals. +// */ + +// @interface TKContentView(TKContentViewPrivate) +// - (id) initWithFrame: (NSRect) frame; +// - (void) _setAsideSubviews; +// - (void) _restoreSubviews; +// @end + +// @interface NSView(TKContentViewPrivate) +// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect +// isVisibleRect: (BOOL) isVisibleRect +// rectIsVisibleRectForView: (NSView *) visibleView +// topView: (BOOL) topView; +// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus +// visRect: (NSRect) visRect; +// - (void) _recursive: (BOOL) recurse +// displayRectIgnoringOpacity: (NSRect) displayRect +// inContext: (NSGraphicsContext *) context topView: (BOOL) topView; +// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect; +// - (BOOL) _drawRectIfEmpty; +// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip; +// - (void) _setDrawsOwnDescendants: (BOOL) drawsOwnDescendants; +// @end +// #endif + +// @implementation TKContentView(TKContentViewPrivate) + +// - (id) initWithFrame: (NSRect) frame +// { +// self = [super initWithFrame:frame]; +// if (self) { +// _savedSubviews = nil; +// _subviewsSetAside = NO; +// [self _setDrawsOwnDescendants:YES]; +// } +// return self; +// } + +// - (void) _setAsideSubviews +// { +// #ifdef TK_MAC_DEBUG +// if (_subviewsSetAside || _savedSubviews) { +// Tcl_Panic("TKContentView _setAsideSubviews called incorrectly"); +// } +// #endif +// _savedSubviews = _subviews; +// _subviews = nil; +// _subviewsSetAside = YES; +// } + +// - (void) _restoreSubviews +// { +// #ifdef TK_MAC_DEBUG +// if (!_subviewsSetAside || _subviews) { +// Tcl_Panic("TKContentView _restoreSubviews called incorrectly"); +// } +// #endif +// _subviews = _savedSubviews; +// _savedSubviews = nil; +// _subviewsSetAside = NO; +// } + +// - (void) _recursiveDisplayRectIfNeededIgnoringOpacity: (NSRect) rect +// isVisibleRect: (BOOL) isVisibleRect +// rectIsVisibleRectForView: (NSView *) visibleView +// topView: (BOOL) topView +// { +// [self _setAsideSubviews]; +// [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect +// isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView +// topView:topView]; +// [self _restoreSubviews]; +// } + +// - (void) _recursiveDisplayAllDirtyWithLockFocus: (BOOL) needsLockFocus +// visRect: (NSRect) visRect +// { +// BOOL needToSetAsideSubviews = !_subviewsSetAside; + +// if (needToSetAsideSubviews) { +// [self _setAsideSubviews]; +// } +// [super _recursiveDisplayAllDirtyWithLockFocus:needsLockFocus +// visRect:visRect]; +// if (needToSetAsideSubviews) { +// [self _restoreSubviews]; +// } +// } + +// - (void) _recursive: (BOOL) recurse +// displayRectIgnoringOpacity: (NSRect) displayRect +// inContext: (NSGraphicsContext *) context topView: (BOOL) topView +// { +// [self _setAsideSubviews]; +// [super _recursive:recurse +// displayRectIgnoringOpacity:displayRect inContext:context +// topView:topView]; +// [self _restoreSubviews]; +// } + +// - (void) _lightWeightRecursiveDisplayInRect: (NSRect) visRect +// { +// BOOL needToSetAsideSubviews = !_subviewsSetAside; + +// if (needToSetAsideSubviews) { +// [self _setAsideSubviews]; +// } +// [super _lightWeightRecursiveDisplayInRect:visRect]; +// if (needToSetAsideSubviews) { +// [self _restoreSubviews]; +// } +// } + +// - (BOOL) _drawRectIfEmpty +// { +// /* +// * Our -drawRect manages subview drawing directly, so it needs to be called +// * even if the area to be redrawn is completely obscured by subviews. +// */ + +// return YES; +// } + +// - (void) _drawRect: (NSRect) inRect clip: (BOOL) clip +// { +// #ifdef TK_MAC_DEBUG_DRAWING +// TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, +// NSStringFromRect(inRect)); +// #endif +// BOOL subviewsWereSetAside = _subviewsSetAside; + +// if (subviewsWereSetAside) { +// [self _restoreSubviews]; +// } +// [super _drawRect:inRect clip:clip]; +// if (subviewsWereSetAside) { +// [self _setAsideSubviews]; +// } +// } + +// @end /* * Local Variables: |