Skip to content

Keep window opacity constant when the window loses focus - #180

Merged
thdxg merged 1 commit into
mainfrom
claude/macterm-opacity-focus-d2a4f5
Jul 21, 2026
Merged

Keep window opacity constant when the window loses focus#180
thdxg merged 1 commit into
mainfrom
claude/macterm-opacity-focus-d2a4f5

Conversation

@thdxg

@thdxg thdxg commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Why

With liquid glass enabled, unfocusing the window faded in a desaturation tint over the glass (mirroring Ghostty's TerminalGlassView) — at 0.85 alpha on dark themes, a translucent window read as near-opaque the moment it lost focus. Keeping the appearance identical focused/unfocused looks better.

What

  • Remove the tintOverlay and its tintProperties (0.35 light / 0.85 dark constants) from MactermGlassView, plus the backgroundOpacity scaling that existed only to bound the tint.
  • Remove WindowAppearance.syncKeyStatus and its windowDidBecomeKey/windowDidResignKey call sites (delegate forwarding unchanged).
  • Remove the now-orphaned NSColor.luminance/isLightColor/adjustingSaturation helpers.
  • MactermGlassView's doc comment now records the deliberate divergence from Ghostty so the tint isn't reintroduced as a "missing feature".

The non-glass paths never varied with focus, so this only affects the macOS 26 glass appearance. Any residual inactive treatment the system applies to NSGlassEffectView itself is outside our control.

Testing

  • mise run format / lint / test all green.
  • Verified visually in the debug build: translucent glass window now renders identically focused and unfocused.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Style
    • Simplified window glass appearance handling.
    • Removed the inactive-window tint overlay, resulting in more consistent glass styling regardless of window focus.
  • Bug Fixes
    • Window appearance no longer changes through separate key-status synchronization when windows gain or lose focus.

…s focus changes

The tint overlay (mirroring Ghostty's TerminalGlassView desaturation) made
an unfocused translucent window read as far more opaque — 0.85 alpha on
dark themes. Keeping the glass identical whether or not the window is key
looks better; the doc comment now records the deliberate divergence from
Ghostty so it isn't reintroduced.
@github-actions github-actions Bot added the area:ui Views, Settings UI label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ec3d4aeb-5bb1-4e15-ba84-758aa0d7c6d8

📥 Commits

Reviewing files that changed from the base of the PR and between 491fd1b and 5deeb94.

📒 Files selected for processing (2)
  • Macterm/Views/MainWindow.swift
  • Macterm/Views/WindowAppearance.swift
💤 Files with no reviewable changes (1)
  • Macterm/Views/MainWindow.swift

📝 Walkthrough

Walkthrough

Window appearance removes inactive-glass tint overlay state and key-window synchronization. Delegate key-state callbacks now only forward notifications, while glass configuration uses style, tint, opacity, and corner radius.

Changes

Window appearance synchronization

Layer / File(s) Summary
Simplify glass appearance updates
Macterm/Views/WindowAppearance.swift, Macterm/Views/MainWindow.swift
MactermGlassView no longer maintains an inactive tint overlay or key-window state, and key-state delegate callbacks no longer invoke appearance synchronization.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • thdxg/macterm#178: Modifies the same key-window-dependent glass tint logic in WindowAppearance.swift.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: preserving opacity when focus changes.
Description check ✅ Passed The description covers why, what changed, and testing/verification, with only minor heading differences from the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/macterm-opacity-focus-d2a4f5

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Window-state benchmark

State Metric main@491fd1bda this branch Δ
focused CPU % 1.20 1.00 -17%
Memory (RSS MB) 107.8 108.8 +1%
CPU ms/s (powermetrics) 10.9 9.1 -17%
Wakeups/s (powermetrics) 187.4 189.3 +1%
unfocused CPU % 1.10 0.90 -18%
Memory (RSS MB) 112.2 113.4 +1%
CPU ms/s (powermetrics) 10.3 8.1 -22%
Wakeups/s (powermetrics) 174.2 176.1 +1%
minimized CPU % 0.20 0.20 +0%
Memory (RSS MB) 112.5 113.6 +1%
CPU ms/s (powermetrics) 1.9 1.5 -18%
Wakeups/s (powermetrics) 79.4 79.5 +0%
workload-focused CPU % 2.40 2.20 -8%
Memory (RSS MB) 163.4 164.8 +1%
CPU ms/s (powermetrics) 23.5 21.4 -9%
Wakeups/s (powermetrics) 250.1 268.9 +8%
workload-unfocused CPU % 2.50 2.10 -16%
Memory (RSS MB) 163.7 165.1 +1%
CPU ms/s (powermetrics) 24.1 18.9 -22%
Wakeups/s (powermetrics) 260.8 266.2 +2%
workload-minimized CPU % 0.30 0.30 +0%
Memory (RSS MB) 163.7 165.2 +1%
CPU ms/s (powermetrics) 3.3 2.6 -19%
Wakeups/s (powermetrics) 148.2 149.4 +1%

Reported value is the median of 3×10s windows per state (splitting the window and taking the median keeps one co-scheduled spike from skewing a state); CPU % is the process CPU-time delta over a window. Runs land on different shared runners, so treat small deltas as noise — 🔺/🔻 marks changes ≥25% that also clear the metric's absolute noise floor (CPU % ≥0.5, Memory (RSS MB) ≥25, CPU ms/s ≥5, Wakeups/s ≥50); CPU deltas off a noise-dominated baseline aren't flagged (CPU % baseline ≥1.5, CPU ms/s baseline ≥15). Flagged changes add the benchmark:regression / benchmark:improvement label.

@thdxg
thdxg merged commit e2b9a0a into main Jul 21, 2026
9 checks passed
@thdxg
thdxg deleted the claude/macterm-opacity-focus-d2a4f5 branch July 21, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ui Views, Settings UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant