Created
May 25, 2020 19:45
-
-
Save aleclarson/8cb8530368393afeed1df91c6d346394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AppKit/AppKit.h> | |
// This window becomes main and key when the app loses focus, which ensures | |
// the "didBecomeKey" and "didBecomeMain" events are posted when they should be. | |
@interface Nothing : NSWindow <NSWindowDelegate> | |
- (instancetype)init; | |
- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag NS_DESIGNATED_INITIALIZER; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Nothing.h" | |
#import "DYApplication.h" | |
@implementation Nothing | |
- (instancetype)init | |
{ | |
return [self initWithContentRect:NSZeroRect | |
styleMask:NSWindowStyleMaskBorderless | |
backing:NSBackingStoreBuffered | |
defer:YES]; | |
} | |
- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag | |
{ | |
if (self = [super initWithContentRect:contentRect | |
styleMask:style | |
backing:backingStoreType | |
defer:flag] | |
) { | |
self.canHide = NO; | |
self.collectionBehavior = NSWindowCollectionBehaviorIgnoresCycle | NSWindowCollectionBehaviorStationary; | |
self.ignoresMouseEvents = YES; | |
self.releasedWhenClosed = NO; | |
self.delegate = self; | |
} | |
return self; | |
} | |
- (BOOL)canBecomeMainWindow | |
{ | |
return YES; | |
} | |
- (BOOL)canBecomeKeyWindow | |
{ | |
return YES; | |
} | |
- (void)windowDidBecomeKey:(NSNotification *)notification | |
{ | |
if (DYApp.isActive) { | |
[DYApp blur]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment