native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #93 from supabitapp/issue-57-background-transparency

Add Ghostty background transparency support

authored by

khoi and committed by
GitHub
536ea38d 2edbb3c8

+82 -2
+13 -2
supacode/Infrastructure/Ghostty/GhosttyRuntime.swift
··· 472 472 return true 473 473 } 474 474 475 + func backgroundOpacity() -> Double { 476 + guard let config else { return 1 } 477 + var value: Double = 1 478 + let key = "background-opacity" 479 + _ = ghostty_config_get(config, &value, key, UInt(key.lengthOfBytes(using: .utf8))) 480 + return min(max(value, 0.001), 1) 481 + } 482 + 483 + func backgroundColor() -> NSColor { 484 + backgroundColorFromConfig() ?? NSColor.windowBackgroundColor 485 + } 486 + 475 487 func scrollbarAppearanceName() -> NSAppearance.Name { 476 - let backgroundColor = backgroundColorFromConfig() ?? NSColor.windowBackgroundColor 477 - return backgroundColor.isLightColor ? .aqua : .darkAqua 488 + backgroundColor().isLightColor ? .aqua : .darkAqua 478 489 } 479 490 480 491 private func backgroundColorFromConfig() -> NSColor? {
+69
supacode/Infrastructure/Ghostty/GhosttySurfaceView.swift
··· 181 181 self?.windowDidChangeScreen() 182 182 } 183 183 }) 184 + notificationObservers.append( 185 + center.addObserver( 186 + forName: NSWindow.didEnterFullScreenNotification, 187 + object: window, 188 + queue: .main 189 + ) { [weak self] _ in 190 + Task { @MainActor [weak self] in 191 + self?.applyWindowBackgroundAppearance() 192 + } 193 + }) 194 + notificationObservers.append( 195 + center.addObserver( 196 + forName: NSWindow.didExitFullScreenNotification, 197 + object: window, 198 + queue: .main 199 + ) { [weak self] _ in 200 + Task { @MainActor [weak self] in 201 + self?.applyWindowBackgroundAppearance() 202 + } 203 + }) 204 + notificationObservers.append( 205 + center.addObserver( 206 + forName: NSWindow.didBecomeKeyNotification, 207 + object: window, 208 + queue: .main 209 + ) { [weak self] _ in 210 + Task { @MainActor [weak self] in 211 + self?.applyWindowBackgroundAppearance() 212 + } 213 + }) 214 + notificationObservers.append( 215 + center.addObserver( 216 + forName: NSWindow.didChangeOcclusionStateNotification, 217 + object: window, 218 + queue: .main 219 + ) { [weak self] _ in 220 + Task { @MainActor [weak self] in 221 + self?.applyWindowBackgroundAppearance() 222 + } 223 + }) 224 + notificationObservers.append( 225 + center.addObserver( 226 + forName: .ghosttyRuntimeConfigDidChange, 227 + object: runtime, 228 + queue: .main 229 + ) { [weak self] _ in 230 + Task { @MainActor [weak self] in 231 + self?.applyWindowBackgroundAppearance() 232 + } 233 + }) 184 234 } 185 235 186 236 private func windowDidChangeScreen() { ··· 206 256 updateScreenObservers() 207 257 updateContentScale() 208 258 updateSurfaceSize() 259 + applyWindowBackgroundAppearance() 209 260 } 210 261 211 262 override func viewDidChangeBackingProperties() { ··· 241 292 242 293 override func resetCursorRects() { 243 294 addCursorRect(bounds, cursor: currentCursor) 295 + } 296 + 297 + private func applyWindowBackgroundAppearance() { 298 + guard let window, window.isVisible else { return } 299 + let opacity = runtime.backgroundOpacity() 300 + if !window.styleMask.contains(.fullScreen), opacity < 1 { 301 + window.isOpaque = false 302 + window.backgroundColor = .white.withAlphaComponent(0.001) 303 + if let app = runtime.app { 304 + ghostty_set_window_background_blur( 305 + app, 306 + Unmanaged.passUnretained(window).toOpaque() 307 + ) 308 + } 309 + return 310 + } 311 + window.isOpaque = true 312 + window.backgroundColor = runtime.backgroundColor().withAlphaComponent(1) 244 313 } 245 314 246 315 func focusDidChange(_ focused: Bool) {