@@ -44,30 +44,35 @@ CGImageRef createThemeAppIcon()
4444 return createAppIcon (getXcodeTheme ().sourceTextBackgroundColor .CGColor ,getXcodeTheme ().sourcePlainTextColor .CGColor ,getXcodeTheme ().sourceTextCurrentLineHighlightColor .CGColor );
4545}
4646
47+ dispatch_once_t windowControllerInitializeOnce;
48+
4749@implementation WindowController
4850
4951+(void )initialize
5052{
51- if (@available (macOS 11 ,*))
52- {
53- swizzle (@" NSColor" ,@" colorNamed:bundle:" ,false ,(IMP )hackFakeColor,(IMP *)&hackRealColor);
54- swizzle (@" NSTitlebarSeparatorView" ,@" updateLayer" ,true ,(IMP )returnNil,NULL );
55- }
56-
57- // TODO: uhh
58-
59- if (NSClassFromString (@" _TtC12SourceEditor21StickyHeaderStackView" ))
60- {
61- swizzle (@" _TtC12SourceEditor21StickyHeaderStackView" ,@" layout" ,true ,(IMP )hackFakeHeaderLayout,(IMP *)&hackRealHeaderLayout);
62-
63- swizzle (@" NSColor" ,@" shadowWithLevel:" ,true ,(IMP )hackFakeShadow,NULL );
64- swizzle (@" NSColor" ,@" highlightWithLevel:" ,true ,(IMP )hackFakeShadow,NULL );
65- }
66-
67- [NSNotificationCenter .defaultCenter addObserverForName: XcodeThemeChangedKey object: nil queue: nil usingBlock: ^(NSNotification * note)
53+ dispatch_once (&windowControllerInitializeOnce,^()
6854 {
69- [WindowController.allInstances makeObjectsPerformSelector: @selector (syncTheme )];
70- }];
55+ if (@available (macOS 11 ,*))
56+ {
57+ swizzle (@" NSColor" ,@" colorNamed:bundle:" ,false ,(IMP )hackFakeColor,(IMP *)&hackRealColor);
58+ swizzle (@" NSTitlebarSeparatorView" ,@" updateLayer" ,true ,(IMP )returnNil,NULL );
59+ }
60+
61+ // TODO: uhh
62+
63+ if (NSClassFromString (@" _TtC12SourceEditor21StickyHeaderStackView" ))
64+ {
65+ swizzle (@" _TtC12SourceEditor21StickyHeaderStackView" ,@" layout" ,true ,(IMP )hackFakeHeaderLayout,(IMP *)&hackRealHeaderLayout);
66+
67+ swizzle (@" NSColor" ,@" shadowWithLevel:" ,true ,(IMP )hackFakeShadow,NULL );
68+ swizzle (@" NSColor" ,@" highlightWithLevel:" ,true ,(IMP )hackFakeShadow,NULL );
69+ }
70+
71+ [NSNotificationCenter .defaultCenter addObserverForName: XcodeThemeChangedKey object: nil queue: nil usingBlock: ^(NSNotification * note)
72+ {
73+ [WindowController.allInstances makeObjectsPerformSelector: @selector (syncTheme )];
74+ }];
75+ });
7176}
7277
7378+(NSArray <WindowController*>*)allInstances
0 commit comments