     }
     
 }
+
+func isFullScreen() -> Bool? {
+    guard let windowInfoList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] else {
+        return nil
+    }
+    for info in windowInfoList {
+        if info[kCGWindowOwnerName as String] as? String == "Window Server",
+            info[kCGWindowName as String] as? String == "Menubar" {
+            return false
+        }
+    }
+    return true
+}

            $0.isOpaque = false
            $0.ignoresMouseEvents = true
            $0.level = .floating
        }
        
        window?.contentView?.addSubview(lyricsView)

        
        window?.contentView?.bind(.hidden, to: defaults, withDefaultName: .DesktopLyricsEnabled, options: [.valueTransformerName: NSValueTransformerName.negateBooleanTransformerName])
        
        defaultObservations += [
            defaults.observe(.DisableLyricsWhenSreenShot, options: [.new, .initial]) { [weak self] defaults, change in
                switch change.newValue {
                case true?: self?.window?.sharingType = .none
                case false?: self?.window?.sharingType = .readOnly
                case nil: break
                }
            },
            defaults.observe(keys: [
                .DesktopLyricsFontName,
                .DesktopLyricsFontSize,
                .DesktopLyricsFontNameFallback
            ], options: [.initial]) { [weak self] in
                self?.lyricsView.font = defaults.desktopLyricsFont
            },
            defaults.observe(.ChineseConversionIndex, options: [.new]) { [weak self] _, change in
                switch change.newValue {
                case 1?:
                    self?.chineseConverter = ChineseConverter(option: [.simplify])
                case 2?:
                    self?.chineseConverter = ChineseConverter(option: [.traditionalize])
                default:
                    self?.chineseConverter = nil
                }
            },
            defaults.observe(keys: [
                .DesktopLyricsInsetTopEnabled,
                .DesktopLyricsInsetBottomEnabled,
                .DesktopLyricsInsetLeftEnabled,
                .DesktopLyricsInsetRightEnabled,
                .DesktopLyricsInsetTop,
                .DesktopLyricsInsetBottom,
                .DesktopLyricsInsetLeft,
                .DesktopLyricsInsetRight,
                ], options: []) { [weak self] in
                    NSAnimationContext.runAnimationGroup({ context in
                        context.duration = 0.2
                        context.allowsImplicitAnimation = true
                        context.timingFunction = .mystery
                        self?.makeConstraints()
                        self?.window?.layoutIfNeeded()
                    })
            }
        ]
        
        notifications += [NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.activeSpaceDidChangeNotification, object: nil, queue: .main) { [weak self] _ in
            if let mainScreen = NSScreen.main {
                let frame = isFullScreen() == true ? mainScreen.frame : mainScreen.visibleFrame
                self?.window?.setFrame(frame, display: true, animate: true)
            }
        }]
    }
    
