@@ -39,118 +39,53 @@ public class WindowManager {
3939 private let SLSSpaceAddWindowsAndRemoveFromSpaces : @convention ( c) ( Int32 , Int32 , CFArray , Int32 ) -> Int32
4040
4141 private init ? ( ) {
42- guard let bundle = CFBundleCreate (
43- kCFAllocatorDefault,
44- NSURL (
45- fileURLWithPath: " /System/Library/PrivateFrameworks/SkyLight.framework "
46- )
47- ) else {
48- return nil
49- }
42+ guard let bundle = CFBundleCreate ( kCFAllocatorDefault, NSURL ( fileURLWithPath: " /System/Library/PrivateFrameworks/SkyLight.framework " ) ) else { return nil }
5043
5144 guard let SLSMainConnectionIDPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSMainConnectionID " as CFString ) else { return nil }
5245 typealias SLSMainConnectionIDAlias = @convention ( c) ( ) -> Int32
53- SLSMainConnectionID = unsafeBitCast (
54- SLSMainConnectionIDPointer,
55- to: SLSMainConnectionIDAlias . self
56- )
46+ SLSMainConnectionID = unsafeBitCast ( SLSMainConnectionIDPointer, to: SLSMainConnectionIDAlias . self)
5747
5848 guard let SLSSpaceCreatePointer = CFBundleGetFunctionPointerForName ( bundle, " SLSSpaceCreate " as CFString ) else { return nil }
5949 typealias SLSSpaceCreateAlias = @convention ( c) ( Int32 , Int32 , Int32 ) -> Int32
60- SLSSpaceCreate = unsafeBitCast (
61- SLSSpaceCreatePointer,
62- to: SLSSpaceCreateAlias . self
63- )
50+ SLSSpaceCreate = unsafeBitCast ( SLSSpaceCreatePointer, to: SLSSpaceCreateAlias . self)
6451
6552 guard let SLSSpaceDestroyPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSSpaceDestroy " as CFString ) else { return nil }
6653 typealias SLSSpaceDestroyAlias = @convention ( c) ( Int32 , Int32 ) -> Int32
67- SLSSpaceDestroy = unsafeBitCast (
68- SLSSpaceDestroyPointer,
69- to: SLSSpaceDestroyAlias . self
70- )
54+ SLSSpaceDestroy = unsafeBitCast ( SLSSpaceDestroyPointer, to: SLSSpaceDestroyAlias . self)
7155
7256 guard let SLSSpaceSetAbsoluteLevelPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSSpaceSetAbsoluteLevel " as CFString ) else { return nil }
7357 typealias SLSSpaceSetAbsoluteLevelAlias = @convention ( c) ( Int32 , Int32 , Int32 ) -> Int32
74- SLSSpaceSetAbsoluteLevel = unsafeBitCast (
75- SLSSpaceSetAbsoluteLevelPointer,
76- to: SLSSpaceSetAbsoluteLevelAlias . self
77- )
58+ SLSSpaceSetAbsoluteLevel = unsafeBitCast ( SLSSpaceSetAbsoluteLevelPointer, to: SLSSpaceSetAbsoluteLevelAlias . self)
7859
7960 guard let SLSShowSpacesPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSShowSpaces " as CFString ) else { return nil }
8061 typealias SLSShowSpacesAlias = @convention ( c) ( Int32 , CFArray ) -> Int32
81- SLSShowSpaces = unsafeBitCast (
82- SLSShowSpacesPointer,
83- to: SLSShowSpacesAlias . self
84- )
62+ SLSShowSpaces = unsafeBitCast ( SLSShowSpacesPointer, to: SLSShowSpacesAlias . self)
8563
8664 guard let SLSHideSpacesPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSHideSpaces " as CFString ) else { return nil }
8765 typealias SLSHideSpacesAlias = @convention ( c) ( Int32 , CFArray ) -> Int32
88- SLSHideSpaces = unsafeBitCast (
89- SLSHideSpacesPointer,
90- to: SLSHideSpacesAlias . self
91- )
66+ SLSHideSpaces = unsafeBitCast ( SLSHideSpacesPointer, to: SLSHideSpacesAlias . self)
9267
9368 guard let SLSSpaceAddWindowsAndRemoveFromSpacesPointer = CFBundleGetFunctionPointerForName ( bundle, " SLSSpaceAddWindowsAndRemoveFromSpaces " as CFString ) else { return nil }
9469 typealias SLSSpaceAddWindowsAndRemoveFromSpacesAlias = @convention ( c) ( Int32 , Int32 , CFArray , Int32 ) -> Int32
95- SLSSpaceAddWindowsAndRemoveFromSpaces = unsafeBitCast (
96- SLSSpaceAddWindowsAndRemoveFromSpacesPointer,
97- to: SLSSpaceAddWindowsAndRemoveFromSpacesAlias . self
98- )
70+ SLSSpaceAddWindowsAndRemoveFromSpaces = unsafeBitCast ( SLSSpaceAddWindowsAndRemoveFromSpacesPointer, to: SLSSpaceAddWindowsAndRemoveFromSpacesAlias . self)
9971
10072 connection = SLSMainConnectionID ( )
101- space = SLSSpaceCreate (
102- connection,
103- 1 ,
104- 0
105- )
73+ space = SLSSpaceCreate ( connection, 1 , 0 )
10674
107- let _ = SLSSpaceSetAbsoluteLevel (
108- connection,
109- space,
110- CGSSpaceLevel . kSLSSpaceAbsoluteLevelNotificationCenterAtScreenLock. rawValue
111- )
75+ let _ = SLSSpaceSetAbsoluteLevel ( connection, space, CGSSpaceLevel . kSLSSpaceAbsoluteLevelNotificationCenterAtScreenLock. rawValue)
11276
113- let _ = SLSShowSpaces (
114- connection,
115- [ space] as CFArray
116- )
77+ let _ = SLSShowSpaces ( connection, [ space] as CFArray )
11778 }
11879
11980 deinit {
120- let _ = SLSHideSpaces (
121- connection,
122- [ space] as CFArray
123- )
81+ let _ = SLSHideSpaces ( connection, [ space] as CFArray )
12482
125- let _ = SLSSpaceDestroy (
126- connection,
127- space
128- )
83+ let _ = SLSSpaceDestroy ( connection, space)
12984 }
13085
13186 func moveToLockScreen(
13287 _ window: NSWindow
13388 ) {
134- /**
135- Last arg is a option for what to do (ig)
136- 7 = 0b0111 = Remove, Add, Animate
137- 3 = 0b0011 = Remove, Add (no animation)
138- */
139- if #available( macOS 16 , * ) { // 26 won't work idk why
140- // let _ = SLSSpaceAddWindowsAndRemoveFromSpaces(
141- // connection,
142- // space,
143- // [window.windowNumber] as CFArray,
144- // 3
145- // )
146- } else {
147- // Keeping same for older version as it was working fine.
148- let _ = SLSSpaceAddWindowsAndRemoveFromSpaces (
149- connection,
150- space,
151- [ window. windowNumber] as CFArray ,
152- 7
153- )
154- }
89+ let _ = SLSSpaceAddWindowsAndRemoveFromSpaces ( connection, space, [ window. windowNumber] as CFArray , 7 )
15590 }
15691}
0 commit comments