@@ -12,26 +12,29 @@ import Foundation
1212// Add a lightweight struct so we can decode only the flag we care about
1313private struct AKAppSettingsData : Codable {
1414 var hideTitleBar : Bool ?
15+ var floatingWindow : Bool ?
1516}
1617
1718class AKPlugin : NSObject , Plugin {
1819 required override init ( ) {
1920 super. init ( )
20- if hideTitleBarSetting == false {
21- return
22- }
2321 if let window = NSApplication . shared. windows. first {
24- // Enable all window management features
25- window. styleMask. insert ( [ . resizable, . fullSizeContentView] )
22+ window. styleMask. insert ( [ . resizable] )
2623 window. collectionBehavior = [ . fullScreenPrimary, . managed, . participatesInCycle]
27-
28- // Enable automatic window management
2924 window. isMovable = true
3025 window. isMovableByWindowBackground = true
31- window. titlebarAppearsTransparent = true
32- window. titleVisibility = . hidden
33- window. toolbar = nil
34- window. title = " "
26+
27+ if self . hideTitleBarSetting == true {
28+ window. styleMask. insert ( [ . fullSizeContentView] )
29+ window. titlebarAppearsTransparent = true
30+ window. titleVisibility = . hidden
31+ window. toolbar = nil
32+ window. title = " "
33+ }
34+
35+ if self . floatingWindowSetting == true {
36+ window. level = . floating
37+ }
3538 NSWindow . allowsAutomaticWindowTabbing = true
3639 }
3740
@@ -40,12 +43,20 @@ class AKPlugin: NSObject, Plugin {
4043 forName: NSWindow . didBecomeKeyNotification,
4144 object: nil ,
4245 queue: . main) { notif in
43- guard let win = notif. object as? NSWindow else { return }
44- win. styleMask. insert ( [ . resizable, . fullSizeContentView] )
45- win. titlebarAppearsTransparent = true
46- win. titleVisibility = . hidden
47- win. toolbar = nil
48- win. title = " "
46+ guard let win = notif. object as? NSWindow else { return }
47+ win. styleMask. insert ( [ . resizable] )
48+
49+ if self . hideTitleBarSetting == true {
50+ win. styleMask. insert ( [ . fullSizeContentView] )
51+ win. titlebarAppearsTransparent = true
52+ win. titleVisibility = . hidden
53+ win. toolbar = nil
54+ win. title = " "
55+ }
56+
57+ if self . floatingWindowSetting == true {
58+ win. level = . floating
59+ }
4960 }
5061 }
5162
@@ -265,17 +276,18 @@ class AKPlugin: NSObject, Plugin {
265276 }
266277
267278 /// Convenience instance property that exposes the cached static preference.
268- private var hideTitleBarSetting : Bool { Self . hideTitleBarPreference }
279+ private var hideTitleBarSetting : Bool { Self . akAppSettingsData? . hideTitleBar ?? false }
280+ private var floatingWindowSetting : Bool { Self . akAppSettingsData? . floatingWindow ?? false }
269281
270- fileprivate static var hideTitleBarPreference : Bool = {
282+ fileprivate static var akAppSettingsData : AKAppSettingsData ? = {
271283 let bundleIdentifier = Bundle . main. bundleIdentifier ?? " "
272284 let settingsURL = URL ( fileURLWithPath: " /Users/ \( NSUserName ( ) ) /Library/Containers/io.playcover.PlayCover " )
273285 . appendingPathComponent ( " App Settings " )
274286 . appendingPathComponent ( " \( bundleIdentifier) .plist " )
275287 guard let data = try ? Data ( contentsOf: settingsURL) ,
276288 let decoded = try ? PropertyListDecoder ( ) . decode ( AKAppSettingsData . self, from: data) else {
277- return false
289+ return nil
278290 }
279- return decoded. hideTitleBar ?? false
291+ return decoded
280292 } ( )
281293}
0 commit comments