-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYBackgroundAwareWindow.m
99 lines (83 loc) · 1.81 KB
/
SSYBackgroundAwareWindow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#import "SSYBackgroundAwareWindow.h"
#import "SSYProcessTyper.h"
@implementation SSYBackgroundAwareWindow
- (BOOL)keepHidden {
return ([SSYProcessTyper currentType] != NSApplicationActivationPolicyRegular) ;
}
- (BOOL)canBecomeKeyWindow {
if ([self keepHidden]) {
return NO ;
}
return [super canBecomeKeyWindow] ;
}
- (BOOL)canBecomeMainWindow {
if ([self keepHidden]) {
return NO ;
}
return [super canBecomeMainWindow] ;
}
#if 0
#warning Experimenting with More Windowlessness
// I found it not necessary to override these methods, so I didn't.
// But maybe I didn't find all the corner cases. Someday, I might?
/*
@brief Override which becomes a no-op if the the current process is not a
foreground process (currentType != SSYProcessTyperTypeForeground), otherwise
invokes super
*/
- (void)displayIfNeeded {
if ([self keepHidden]) {
return ;
}
[super displayIfNeeded] ;
}
- (void)display {
if ([self keepHidden]) {
return ;
}
[super display] ;
}
- (void)orderFrontRegardless {
if ([self keepHidden]) {
return ;
}
[super orderFrontRegardless] ;
}
- (void)orderFront:(id)sender {
if ([self keepHidden]) {
return ;
}
[super display] ;
}
- (void)orderBack:(id)sender {
if ([self keepHidden]) {
return ;
}
[super orderFront:sender] ;
}
- (void)makeMainWindow {
if ([self keepHidden]) {
return ;
}
[super makeMainWindow] ;
}
- (void)makeKeyWindow {
if ([self keepHidden]) {
return ;
}
[super makeKeyWindow] ;
}
- (void)makeKeyAndOrderFront:(id)sender {
if ([self keepHidden]) {
return ;
}
[super makeKeyAndOrderFront:sender] ;
}
- (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber {
if ([self keepHidden]) {
return ;
}
[super orderWindow:orderingMode relativeTo:otherWindowNumber] ;
}
#endif
@end