Add an extra condition to the visibility check, which is similar to the previous version of this check, which now guards against the window it is hosted in not being visible. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
30 lines
470 B
Objective-C
30 lines
470 B
Objective-C
//
|
|
// NSView+Visibility.m
|
|
// Cog
|
|
//
|
|
// Created by Christopher Snowhill on 6/8/22.
|
|
//
|
|
|
|
#import "NSView+Visibility.h"
|
|
|
|
@implementation NSView (Visibility)
|
|
|
|
- (BOOL)visibleInWindow {
|
|
if(self.window == nil) {
|
|
return NO;
|
|
}
|
|
|
|
if(![self.window isVisible]) {
|
|
return NO;
|
|
}
|
|
|
|
// Might have zero opacity.
|
|
if(self.alphaValue == 0 || self.hiddenOrHasHiddenAncestor) {
|
|
return NO;
|
|
}
|
|
|
|
// Might be clipped by an ancestor.
|
|
return !NSIsEmptyRect(self.visibleRect);
|
|
}
|
|
|
|
@end
|