Repository navigation
macos: opacity-toggle setting persists between tabs in a window and to a newly created window - #11583
Conversation
| @@ -313,14 +307,17 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr | |||
| tree: SplitTree<Ghostty.SurfaceView>, | |||
| position: NSPoint? = nil, | |||
| confirmUndo: Bool = true, | |||
| inheritBackgroundOpacityFrom parentController: TerminalController? = nil | |||
There was a problem hiding this comment.
Instead of passing TerminalController around, just use isBackgroundOpaque would be better
| guard let window, !window.styleMask.contains(.fullScreen) else { return } | ||
|
|
||
| let newValue = !isBackgroundOpaque | ||
| let controllers: [TerminalController] |
There was a problem hiding this comment.
There is a shared all that you can get all opened windows, so you can toggle them all.
And I think you can just call super here and move some of the stuff to Base so that quick terminal can also benefit from this
There was a problem hiding this comment.
There is a shared all that you can get all opened windows, so you can toggle them all.
I was hesitant at first to make the toggle apply to all (windows and tabs) because I didn't know if the current behavior was a design choice. However, I do agree with you that making it global is better since its rare that a user would want a different opacity setting between different tabs and/or windows. I added this to the new commit.
And I think you can just call super here
I ended up not calling super in TerminalController because I removed the
override func toggleBackgroundOpacity entirely.
There was a problem hiding this comment.
Also, when I was testing if my newest changes worked for quick terminal, I ran into an issue of not being able to open to quick terminal for just my debug build. I don't know why toggle_quick_terminal isn't in the command palette. I made a discussion post that might be worth checking out: #12130
| let newValue = !isBackgroundOpaque | ||
| let controllers = NSApplication.shared.windows.compactMap { | ||
| $0.windowController as? BaseTerminalController | ||
| } |
There was a problem hiding this comment.
I tried to use TerminalController.all like you said but I found that it excluded the quick terminal. Instead, I added this logic. It computes newValue, gathers all open terminal controllers, and applies. This change did include the quick terminal
bo2themax
left a comment
There was a problem hiding this comment.
This looks much cleaner to me, thanks, now we wait, please don't pin anyone
|
Tried, LGTM, please rebase to the latest, and I'll reapprove it 🙏 |
333a1b2 to
0e49204
Compare
Done. Thanks! |
|
Is there anything else I need to do? I use ghostty every day on one monitor and the current behavior is driving me crazy when it is above other windows while translucent. |
No, be patient, you can always build in release mode and use local build |
|
Hi is there any reason this hasn't been merged? The review has been approved for over a month and its a small change. |
When the user toggles `background_opacity` to fully opaque on an existing window, child windows created via `new_window` now start opaque too instead of reverting to the configured `background-opacity` value. Mirrors the macOS behavior from upstream e5c31e8 (ghostty-org#11583). The new_window action handler inspects the parent surface's HWND WS_EX_LAYERED bit: if it's clear while config opacity < 1.0, the parent was toggled to opaque, so the new Window is initialized with `force_opaque = true` which skips the WS_EX_LAYERED setup in Window.init. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Conversion of #11041 into a PR. My vouch request doubles as an Issue so I don't think I need to make a new issue in Issue Triage.
The opacity toggle setting is now reflected amongst all tabs. So now when you press the keybinding for toggle_background_opacity, all existing tabs and all new tabs created will have the same toggle setting.
There is also logic in
BaseTerminalController.swiftthat makes a new window inherit the current window's toggle state. There is no logic that changes the toggle state between all windows as I think the toggle logic should be per-window. This is a subjective design choice so let me know if you disagree.A suggestion for the future, if the user wants more fine-tuned control over the scope, maybe a configuration option like
toggle_background_opacity_scopeand have the options be
global, window, tabcould be useful but I think that might be too complex for a small issue like this.
edit: I just stumbled upon this post #4817. If this were to be implemented (themes at a tab or window level) then the design of this pr would have to rethought.
AI usage disclosure:
I used OpenAI Codex (GPT-5.3-Codex) for AI-assisted code editing and text drafting and for code review.
Extent: initial implementation and wording assistance.
I manually reviewed and edited the code and I understand how the changes work in
TerminalController.swiftandBaseTerminalController.swift